예제 #1
0
 def ParseUpdateOptions(self, args, locations):
     get_default = lambda key: getattr(args, key)
     flags.ValidateNotificationConfigFlag(args)
     opts = container_command_util.ParseUpdateOptionsBase(args, locations)
     opts.resource_usage_bigquery_dataset = args.resource_usage_bigquery_dataset
     opts.clear_resource_usage_bigquery_dataset = \
         args.clear_resource_usage_bigquery_dataset
     opts.enable_network_egress_metering = args.enable_network_egress_metering
     opts.enable_resource_consumption_metering = \
         args.enable_resource_consumption_metering
     opts.enable_intra_node_visibility = args.enable_intra_node_visibility
     opts.enable_master_global_access = args.enable_master_global_access
     opts.enable_shielded_nodes = args.enable_shielded_nodes
     opts.release_channel = args.release_channel
     opts.cloud_run_config = flags.GetLegacyCloudRunFlag(
         '{}_config', args, get_default)
     flags.ValidateCloudRunConfigUpdateArgs(opts.cloud_run_config,
                                            args.disable_addons)
     if args.disable_addons and api_adapter.NODELOCALDNS in args.disable_addons:
         # NodeLocalDNS is being enabled or disabled
         console_io.PromptContinue(
             message=
             'Enabling/Disabling NodeLocal DNSCache causes a re-creation '
             'of all cluster nodes at versions 1.15 or above. '
             'This operation is long-running and will block other '
             'operations on the cluster (including delete) until it has run '
             'to completion.',
             cancel_on_no=True)
     opts.disable_default_snat = args.disable_default_snat
     opts.notification_config = args.notification_config
     return opts
예제 #2
0
def ParseCreateOptionsBase(args, is_autopilot, get_default, location,
                           project_id):
    """Parses the flags provided with the cluster creation command."""
    if hasattr(args, 'addons') and args.IsSpecified('addons') and \
        api_adapter.DASHBOARD in args.addons:
        log.warning(
            'The `KubernetesDashboard` addon is deprecated, and will be removed as '
            'an option for new clusters starting in 1.15. It is recommended to use '
            'the Cloud Console to manage and monitor your Kubernetes clusters, '
            'workloads and applications. See: '
            'https://cloud.google.com/kubernetes-engine/docs/concepts/dashboards'
        )

    flags.LogBasicAuthDeprecationWarning(args)
    flags.MungeBasicAuthFlags(args)
    MaybeLogAuthWarning(args)
    MaybeLogReleaseChannelDefaultWarning(args)

    enable_ip_alias = get_default('enable_ip_alias')
    if hasattr(args, 'enable_ip_alias'):
        flags.WarnForUnspecifiedIpAllocationPolicy(args)

    enable_autorepair = None
    if hasattr(args, 'enable_autorepair'):
        enable_autorepair = cmd_util.GetAutoRepair(args)
        if enable_autorepair:
            flags.WarnForNodeModification(args, enable_autorepair)

    metadata = metadata_utils.ConstructMetadataDict(
        get_default('metadata'), get_default('metadata_from_file'))

    cloud_run_config = flags.GetLegacyCloudRunFlag('{}_config', args,
                                                   get_default)
    flags.ValidateCloudRunConfigCreateArgs(cloud_run_config,
                                           get_default('addons'))

    MaybeLogCloudNatHelpText(args, is_autopilot, location, project_id)

    flags.ValidateNotificationConfigFlag(args)

    return api_adapter.CreateClusterOptions(
        accelerators=get_default('accelerator'),
        additional_zones=get_default('additional_zones'),
        addons=get_default('addons'),
        boot_disk_kms_key=get_default('boot_disk_kms_key'),
        cluster_ipv4_cidr=get_default('cluster_ipv4_cidr'),
        cluster_secondary_range_name=get_default('cluster_secondary_range_name'),
        cluster_version=get_default('cluster_version'),
        cloud_run_config=cloud_run_config,
        node_version=get_default('node_version'),
        create_subnetwork=get_default('create_subnetwork'),
        disable_default_snat=get_default('disable_default_snat'),
        disk_type=get_default('disk_type'),
        enable_autorepair=enable_autorepair,
        enable_autoscaling=get_default('enable_autoscaling'),
        enable_autoupgrade=(cmd_util.GetAutoUpgrade(args) if
                            hasattr(args, 'enable_autoupgrade')
                            else None),
        enable_binauthz=get_default('enable_binauthz'),
        enable_stackdriver_kubernetes=_GetEnableStackdriver(args),
        enable_cloud_logging=args.enable_cloud_logging if (hasattr(args, 'enable_cloud_logging') and args.IsSpecified('enable_cloud_logging')) else None,
        enable_cloud_monitoring=args.enable_cloud_monitoring if (hasattr(args, 'enable_cloud_monitoring') and args.IsSpecified('enable_cloud_monitoring')) else None,
        enable_workload_monitoring_eap=get_default('enable_workload_monitoring_eap'),
        enable_ip_alias=enable_ip_alias,
        enable_intra_node_visibility=get_default('enable_intra_node_visibility'),
        enable_kubernetes_alpha=get_default('enable_kubernetes_alpha'),
        enable_cloud_run_alpha=flags.GetLegacyCloudRunFlag('enable_{}_alpha', args, get_default),
        enable_legacy_authorization=get_default('enable_legacy_authorization'),
        enable_master_authorized_networks=\
          get_default('enable_master_authorized_networks'),
        enable_master_global_access=get_default('enable_master_global_access'),
        enable_network_policy=get_default('enable_network_policy'),
        enable_private_nodes=get_default('enable_private_nodes'),
        enable_private_endpoint=get_default('enable_private_endpoint'),
        enable_gke_oidc=getattr(args, 'enable_gke_oidc', None),
        image_type=get_default('image_type'),
        image=get_default('image'),
        image_project=get_default('image_project'),
        image_family=get_default('image_family'),
        issue_client_certificate=get_default('issue_client_certificate'),
        labels=get_default('labels'),
        local_ssd_count=get_default('local_ssd_count'),
        maintenance_window=get_default('maintenance_window'),
        maintenance_window_start=get_default('maintenance_window_start'),
        maintenance_window_end=get_default('maintenance_window_end'),
        maintenance_window_recurrence=get_default('maintenance_window_recurrence'),
        master_authorized_networks=get_default('master_authorized_networks'),
        master_ipv4_cidr=get_default('master_ipv4_cidr'),
        max_nodes=get_default('max_nodes'),
        max_nodes_per_pool=get_default('max_nodes_per_pool'),
        min_cpu_platform=get_default('min_cpu_platform'),
        min_nodes=get_default('min_nodes'),
        network=get_default('network'),
        node_disk_size_gb=utils.BytesToGb(args.disk_size) if hasattr(args, 'disk_size') else None,
        node_labels=get_default('node_labels'),
        node_locations=get_default('node_locations'),
        node_machine_type=get_default('machine_type'),
        node_taints=get_default('node_taints'),
        num_nodes=get_default('num_nodes'),
        password=get_default('password'),
        preemptible=get_default('preemptible'),
        scopes=get_default('scopes'),
        service_account=get_default('service_account'),
        services_ipv4_cidr=get_default('services_ipv4_cidr'),
        services_secondary_range_name=get_default('services_secondary_range_name'),
        subnetwork=get_default('subnetwork'),
        system_config_from_file=get_default('system_config_from_file'),
        private_ipv6_google_access_type=get_default('private_ipv6_google_access_type'),
        tags=get_default('tags'),
        user=get_default('username'),
        metadata=metadata,
        default_max_pods_per_node=get_default('default_max_pods_per_node'),
        max_pods_per_node=get_default('max_pods_per_node'),
        enable_tpu=get_default('enable_tpu'),
        tpu_ipv4_cidr=get_default('tpu_ipv4_cidr'),
        resource_usage_bigquery_dataset=get_default('resource_usage_bigquery_dataset'),
        enable_network_egress_metering=get_default('enable_network_egress_metering'),
        enable_resource_consumption_metering=get_default('enable_resource_consumption_metering'),
        database_encryption_key=get_default('database_encryption_key'),
        workload_pool=get_default('workload_pool'),
        identity_provider=get_default('identity_provider'),
        workload_metadata=get_default('workload_metadata'),
        workload_metadata_from_node=get_default('workload_metadata_from_node'),
        enable_vertical_pod_autoscaling=get_default('enable_vertical_pod_autoscaling'),
        enable_autoprovisioning=get_default('enable_autoprovisioning'),
        autoprovisioning_config_file=get_default('autoprovisioning_config_file'),
        autoprovisioning_service_account=get_default('autoprovisioning_service_account'),
        autoprovisioning_scopes=get_default('autoprovisioning_scopes'),
        autoprovisioning_locations=get_default('autoprovisioning_locations'),
        autoprovisioning_max_surge_upgrade=get_default('autoprovisioning_max_surge_upgrade'),
        autoprovisioning_max_unavailable_upgrade=get_default('autoprovisioning_max_unavailable_upgrade'),
        enable_autoprovisioning_autorepair=get_default('enable_autoprovisioning_autorepair'),
        enable_autoprovisioning_autoupgrade=get_default('enable_autoprovisioning_autoupgrade'),
        autoprovisioning_min_cpu_platform=get_default('autoprovisioning_min_cpu_platform'),
        min_cpu=get_default('min_cpu'),
        max_cpu=get_default('max_cpu'),
        min_memory=get_default('min_memory'),
        max_memory=get_default('max_memory'),
        min_accelerator=get_default('min_accelerator'),
        max_accelerator=get_default('max_accelerator'),
        shielded_secure_boot=get_default('shielded_secure_boot'),
        shielded_integrity_monitoring=get_default('shielded_integrity_monitoring'),
        reservation_affinity=get_default('reservation_affinity'),
        reservation=get_default('reservation'),
        release_channel=get_default('release_channel'),
        enable_shielded_nodes=get_default('enable_shielded_nodes'),
        max_surge_upgrade=get_default('max_surge_upgrade'),
        max_unavailable_upgrade=get_default('max_unavailable_upgrade'),
        autopilot=is_autopilot)
예제 #3
0
    def ParseUpdateOptions(self, args, locations):
        get_default = lambda key: getattr(args, key)
        flags.ValidateNotificationConfigFlag(args)
        opts = container_command_util.ParseUpdateOptionsBase(args, locations)
        opts.autoscaling_profile = args.autoscaling_profile
        opts.enable_pod_security_policy = args.enable_pod_security_policy
        opts.resource_usage_bigquery_dataset = args.resource_usage_bigquery_dataset
        opts.clear_resource_usage_bigquery_dataset = \
            args.clear_resource_usage_bigquery_dataset
        opts.security_profile = args.security_profile
        opts.istio_config = args.istio_config
        opts.cloud_run_config = flags.GetLegacyCloudRunFlag(
            '{}_config', args, get_default)
        opts.enable_intra_node_visibility = args.enable_intra_node_visibility
        opts.enable_network_egress_metering = args.enable_network_egress_metering
        opts.enable_resource_consumption_metering = args.enable_resource_consumption_metering
        opts.workload_identity_certificate_authority = args.workload_identity_certificate_authority
        opts.disable_workload_identity_certificates = args.disable_workload_identity_certificates
        flags.ValidateIstioConfigUpdateArgs(args.istio_config,
                                            args.disable_addons)
        flags.ValidateCloudRunConfigUpdateArgs(opts.cloud_run_config,
                                               args.disable_addons)
        if args.disable_addons and api_adapter.NODELOCALDNS in args.disable_addons:
            # NodeLocalDNS is being enabled or disabled
            console_io.PromptContinue(
                message=
                'Enabling/Disabling NodeLocal DNSCache causes a re-creation '
                'of all cluster nodes at versions 1.15 or above. '
                'This operation is long-running and will block other '
                'operations on the cluster (including delete) until it has run '
                'to completion.',
                cancel_on_no=True)
        opts.enable_stackdriver_kubernetes = args.enable_stackdriver_kubernetes
        opts.enable_logging_monitoring_system_only = args.enable_logging_monitoring_system_only
        opts.no_master_logs = args.no_master_logs
        opts.master_logs = args.master_logs
        opts.enable_master_metrics = args.enable_master_metrics
        opts.release_channel = args.release_channel
        opts.enable_tpu = args.enable_tpu
        opts.tpu_ipv4_cidr = args.tpu_ipv4_cidr
        opts.enable_tpu_service_networking = args.enable_tpu_service_networking

        # Top-level update options are automatically forced to be
        # mutually-exclusive, so we don't need special handling for these two.
        opts.identity_provider = args.identity_provider
        opts.enable_shielded_nodes = args.enable_shielded_nodes
        opts.disable_default_snat = args.disable_default_snat
        opts.enable_cost_management = args.enable_cost_management
        opts.enable_master_global_access = args.enable_master_global_access
        opts.enable_gvnic = args.enable_gvnic
        opts.notification_config = args.notification_config
        opts.kubernetes_objects_changes_target = args.kubernetes_objects_changes_target
        opts.kubernetes_objects_snapshots_target = args.kubernetes_objects_snapshots_target
        opts.enable_gke_oidc = args.enable_gke_oidc
        opts.enable_workload_monitoring_eap = args.enable_workload_monitoring_eap
        opts.disable_autopilot = args.disable_autopilot
        opts.enable_l4_ilb_subsetting = args.enable_l4_ilb_subsetting
        opts.cluster_dns = args.cluster_dns
        opts.cluster_dns_scope = args.cluster_dns_scope
        opts.cluster_dns_domain = args.cluster_dns_domain
        if opts.cluster_dns and opts.cluster_dns.lower() == 'clouddns':
            console_io.PromptContinue(
                message=
                'Enabling CloudDNS is a one-way operation. Once enabled, '
                'this configuration cannot be disabled.'
                'All the node-pools in the cluster need to be re-created by the user '
                'to start using CloudDNS for DNS lookups. It is highly recommended to'
                ' complete this step shortly after enabling CloudDNS.',
                cancel_on_no=True)

        return opts