Exemple #1
0
def ParseCreateNodePoolOptionsBase(args):
  """Parses the flags provided with the node pool creation command."""
  enable_autorepair = cmd_util.GetAutoRepair(args)
  flags.WarnForNodeModification(args, enable_autorepair)
  metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                  args.metadata_from_file)
  return api_adapter.CreateNodePoolOptions(
      accelerators=args.accelerator,
      machine_type=args.machine_type,
      disk_size_gb=utils.BytesToGb(args.disk_size),
      scopes=args.scopes,
      node_version=args.node_version,
      num_nodes=args.num_nodes,
      local_ssd_count=args.local_ssd_count,
      tags=args.tags,
      node_labels=args.node_labels,
      node_taints=args.node_taints,
      enable_autoscaling=args.enable_autoscaling,
      max_nodes=args.max_nodes,
      min_cpu_platform=args.min_cpu_platform,
      min_nodes=args.min_nodes,
      image_type=args.image_type,
      image=args.image,
      image_project=args.image_project,
      image_family=args.image_family,
      preemptible=args.preemptible,
      enable_autorepair=enable_autorepair,
      enable_autoupgrade=cmd_util.GetAutoUpgrade(args),
      service_account=args.service_account,
      disk_type=args.disk_type,
      metadata=metadata,
      max_pods_per_node=args.max_pods_per_node)
Exemple #2
0
def ParseCreateNodePoolOptionsBase(args):
    """Parses the flags provided with the node pool creation command."""
    enable_autorepair = cmd_util.GetAutoRepair(args)
    flags.WarnForNodeModification(args, enable_autorepair)
    flags.ValidateSurgeUpgradeSettings(args)
    metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                    args.metadata_from_file)
    return api_adapter.CreateNodePoolOptions(
        accelerators=args.accelerator,
        boot_disk_kms_key=args.boot_disk_kms_key,
        machine_type=args.machine_type,
        disk_size_gb=utils.BytesToGb(args.disk_size),
        scopes=args.scopes,
        node_version=args.node_version,
        num_nodes=args.num_nodes,
        local_ssd_count=args.local_ssd_count,
        tags=args.tags,
        threads_per_core=args.threads_per_core,
        node_labels=args.node_labels,
        node_taints=args.node_taints,
        enable_autoscaling=args.enable_autoscaling,
        max_nodes=args.max_nodes,
        min_cpu_platform=args.min_cpu_platform,
        min_nodes=args.min_nodes,
        image_type=args.image_type,
        image=args.image,
        image_project=args.image_project,
        image_family=args.image_family,
        preemptible=args.preemptible,
        enable_autorepair=enable_autorepair,
        enable_autoupgrade=cmd_util.GetAutoUpgrade(args),
        service_account=args.service_account,
        disk_type=args.disk_type,
        metadata=metadata,
        max_pods_per_node=args.max_pods_per_node,
        enable_autoprovisioning=args.enable_autoprovisioning,
        workload_metadata=args.workload_metadata,
        workload_metadata_from_node=args.workload_metadata_from_node,
        shielded_secure_boot=args.shielded_secure_boot,
        shielded_integrity_monitoring=args.shielded_integrity_monitoring,
        reservation_affinity=args.reservation_affinity,
        reservation=args.reservation,
        sandbox=args.sandbox,
        max_surge_upgrade=args.max_surge_upgrade,
        max_unavailable_upgrade=args.max_unavailable_upgrade,
        node_group=args.node_group,
        system_config_from_file=args.system_config_from_file,
        pod_ipv4_range=args.pod_ipv4_range,
        create_pod_ipv4_range=args.create_pod_ipv4_range,
        gvnic=args.enable_gvnic,
        enable_image_streaming=args.enable_image_streaming,
        spot=args.spot,
        enable_confidential_nodes=args.enable_confidential_nodes,
        enable_blue_green_update=args.enable_blue_green_update,
        enable_rolling_update=args.enable_rolling_update,
        node_pool_soak_duration=args.node_pool_soak_duration,
        standard_rollout_policy=args.standard_rollout_policy,
        enable_private_nodes=args.enable_private_nodes)
Exemple #3
0
def ParseCreateNodePoolOptionsBase(args):
    """Parses the flags provided with the node pool creation command."""
    if (args.IsSpecified('enable_cloud_endpoints')
            and properties.VALUES.container.new_scopes_behavior.GetBool()):
        raise util.Error(
            'Flag --[no-]enable-cloud-endpoints is not allowed if '
            'property container/ new_scopes_behavior is set to true.')
    if args.IsSpecified('enable_autorepair'):
        enable_autorepair = args.enable_autorepair
    else:
        # Node pools using COS support auto repairs, enable it for them by default.
        # Other node pools using (Ubuntu, custom images) don't support node auto
        # repairs, attempting to enable autorepair for them will result in API call
        # failing so don't do it.
        enable_autorepair = ((args.image_type or '').lower() in ['', 'cos'])
    flags.WarnForNodeModification(args, enable_autorepair)
    metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                    args.metadata_from_file)
    return api_adapter.CreateNodePoolOptions(
        accelerators=args.accelerator,
        machine_type=args.machine_type,
        disk_size_gb=utils.BytesToGb(args.disk_size),
        scopes=args.scopes,
        node_version=args.node_version,
        enable_cloud_endpoints=args.enable_cloud_endpoints,
        num_nodes=args.num_nodes,
        local_ssd_count=args.local_ssd_count,
        tags=args.tags,
        node_labels=args.node_labels,
        node_taints=args.node_taints,
        enable_autoscaling=args.enable_autoscaling,
        max_nodes=args.max_nodes,
        min_cpu_platform=args.min_cpu_platform,
        min_nodes=args.min_nodes,
        image_type=args.image_type,
        image=args.image,
        image_project=args.image_project,
        image_family=args.image_family,
        preemptible=args.preemptible,
        enable_autorepair=enable_autorepair,
        enable_autoupgrade=args.enable_autoupgrade,
        service_account=args.service_account,
        disk_type=args.disk_type,
        metadata=metadata,
        max_pods_per_node=args.max_pods_per_node)
Exemple #4
0
def ParseCreateNodePoolOptionsBase(args):
    """Parses the flags provided with the node pool creation command."""
    enable_autorepair = cmd_util.GetAutoRepair(args)
    flags.WarnForNodeModification(args, enable_autorepair)
    flags.ValidateSurgeUpgradeSettings(args)
    metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                    args.metadata_from_file)
    return api_adapter.CreateNodePoolOptions(
        accelerators=args.accelerator,
        machine_type=args.machine_type,
        disk_size_gb=utils.BytesToGb(args.disk_size),
        scopes=args.scopes,
        node_version=args.node_version,
        num_nodes=args.num_nodes,
        local_ssd_count=args.local_ssd_count,
        tags=args.tags,
        node_labels=args.node_labels,
        node_taints=args.node_taints,
        enable_autoscaling=args.enable_autoscaling,
        max_nodes=args.max_nodes,
        min_cpu_platform=args.min_cpu_platform,
        min_nodes=args.min_nodes,
        image_type=args.image_type,
        image=args.image,
        image_project=args.image_project,
        image_family=args.image_family,
        preemptible=args.preemptible,
        enable_autorepair=enable_autorepair,
        enable_autoupgrade=cmd_util.GetAutoUpgrade(args),
        service_account=args.service_account,
        disk_type=args.disk_type,
        metadata=metadata,
        max_pods_per_node=args.max_pods_per_node,
        enable_autoprovisioning=args.enable_autoprovisioning,
        workload_metadata=args.workload_metadata,
        workload_metadata_from_node=args.workload_metadata_from_node,
        shielded_secure_boot=args.shielded_secure_boot,
        shielded_integrity_monitoring=args.shielded_integrity_monitoring,
        reservation_affinity=args.reservation_affinity,
        reservation=args.reservation,
        sandbox=args.sandbox,
        max_surge_upgrade=args.max_surge_upgrade,
        max_unavailable_upgrade=args.max_unavailable_upgrade)
Exemple #5
0
def ParseCreateNodePoolOptionsBase(args):
    """Parses the flags provided with the node pool creation command."""
    if (args.IsSpecified('enable_cloud_endpoints')
            and properties.VALUES.container.new_scopes_behavior.GetBool()):
        raise util.Error(
            'Flag --[no-]enable-cloud-endpoints is not allowed if '
            'property container/ new_scopes_behavior is set to true.')
    enable_autorepair = cmd_util.GetAutoRepair(args)
    flags.WarnForNodeModification(args, enable_autorepair)
    metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                    args.metadata_from_file)
    return api_adapter.CreateNodePoolOptions(
        accelerators=args.accelerator,
        machine_type=args.machine_type,
        disk_size_gb=utils.BytesToGb(args.disk_size),
        scopes=args.scopes,
        node_version=args.node_version,
        enable_cloud_endpoints=args.enable_cloud_endpoints,
        num_nodes=args.num_nodes,
        local_ssd_count=args.local_ssd_count,
        tags=args.tags,
        node_labels=args.node_labels,
        node_taints=args.node_taints,
        enable_autoscaling=args.enable_autoscaling,
        max_nodes=args.max_nodes,
        min_cpu_platform=args.min_cpu_platform,
        min_nodes=args.min_nodes,
        image_type=args.image_type,
        image=args.image,
        image_project=args.image_project,
        image_family=args.image_family,
        preemptible=args.preemptible,
        enable_autorepair=enable_autorepair,
        enable_autoupgrade=cmd_util.GetAutoUpgrade(args),
        service_account=args.service_account,
        disk_type=args.disk_type,
        metadata=metadata,
        max_pods_per_node=args.max_pods_per_node)
Exemple #6
0
def ParseCreateOptionsBase(args):
    """Parses the flags provided with the cluster creation command."""
    if not (args.IsSpecified('enable_basic_auth')
            or args.IsSpecified('username')):
        log.warning('Starting in 1.12, new clusters will have basic '
                    'authentication disabled by default. Basic authentication '
                    'can be enabled (or disabled) manually using the '
                    '`--[no-]enable-basic-auth` flag.')
    if not args.IsSpecified('issue_client_certificate'):
        log.warning(
            'Starting in 1.12, new clusters will not have a client '
            'certificate issued. You can manually enable (or disable) the '
            'issuance of the client certificate using the '
            '`--[no-]issue-client-certificate` flag.')
    if 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.MungeBasicAuthFlags(args)

    if args.IsSpecified('issue_client_certificate') and not (
            args.IsSpecified('enable_basic_auth')
            or args.IsSpecified('username')):
        log.warning(
            'If `--issue-client-certificate` is specified but '
            '`--enable-basic-auth` or `--username` is not, our API will '
            'treat that as `--no-enable-basic-auth`.')

    enable_autorepair = cmd_util.GetAutoRepair(args)
    flags.WarnForNodeModification(args, enable_autorepair)
    metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                    args.metadata_from_file)
    return api_adapter.CreateClusterOptions(
        accelerators=args.accelerator,
        additional_zones=args.additional_zones,
        addons=args.addons,
        cluster_ipv4_cidr=args.cluster_ipv4_cidr,
        cluster_secondary_range_name=args.cluster_secondary_range_name,
        cluster_version=args.cluster_version,
        node_version=args.node_version,
        create_subnetwork=args.create_subnetwork,
        disk_type=args.disk_type,
        enable_autorepair=enable_autorepair,
        enable_autoscaling=args.enable_autoscaling,
        enable_autoupgrade=cmd_util.GetAutoUpgrade(args),
        enable_stackdriver_kubernetes=args.enable_stackdriver_kubernetes,
        enable_cloud_logging=args.enable_cloud_logging,
        enable_cloud_monitoring=args.enable_cloud_monitoring,
        enable_ip_alias=args.enable_ip_alias,
        enable_kubernetes_alpha=args.enable_kubernetes_alpha,
        enable_legacy_authorization=args.enable_legacy_authorization,
        enable_master_authorized_networks=args.enable_master_authorized_networks,
        enable_network_policy=args.enable_network_policy,
        enable_private_nodes=args.enable_private_nodes,
        enable_private_endpoint=args.enable_private_endpoint,
        image_type=args.image_type,
        image=args.image,
        image_project=args.image_project,
        image_family=args.image_family,
        issue_client_certificate=args.issue_client_certificate,
        labels=args.labels,
        local_ssd_count=args.local_ssd_count,
        maintenance_window=args.maintenance_window,
        master_authorized_networks=args.master_authorized_networks,
        master_ipv4_cidr=args.master_ipv4_cidr,
        max_nodes=args.max_nodes,
        max_nodes_per_pool=args.max_nodes_per_pool,
        min_cpu_platform=args.min_cpu_platform,
        min_nodes=args.min_nodes,
        network=args.network,
        node_disk_size_gb=utils.BytesToGb(args.disk_size),
        node_labels=args.node_labels,
        node_locations=args.node_locations,
        node_machine_type=args.machine_type,
        node_taints=args.node_taints,
        num_nodes=args.num_nodes,
        password=args.password,
        preemptible=args.preemptible,
        scopes=args.scopes,
        service_account=args.service_account,
        services_ipv4_cidr=args.services_ipv4_cidr,
        services_secondary_range_name=args.services_secondary_range_name,
        subnetwork=args.subnetwork,
        tags=args.tags,
        user=args.username,
        metadata=metadata,
        default_max_pods_per_node=args.default_max_pods_per_node,
        max_pods_per_node=args.max_pods_per_node,
        enable_tpu=args.enable_tpu,
        tpu_ipv4_cidr=args.tpu_ipv4_cidr,
        resource_usage_bigquery_dataset=args.resource_usage_bigquery_dataset,
        enable_network_egress_metering=args.enable_network_egress_metering,
        enable_resource_consumption_metering=\
            args.enable_resource_consumption_metering)
Exemple #7
0
def ParseCreateOptionsBase(args):
  """Parses the flags provided with the cluster creation command."""
  if not (args.IsSpecified('enable_basic_auth') or
          args.IsSpecified('username')):
    log.warning('Starting in 1.12, new clusters will have basic '
                'authentication disabled by default. Basic authentication '
                'can be enabled (or disabled) manually using the '
                '`--[no-]enable-basic-auth` flag.')
  if not args.IsSpecified('issue_client_certificate'):
    log.warning('Starting in 1.12, new clusters will not have a client '
                'certificate issued. You can manually enable (or disable) the '
                'issuance of the client certificate using the '
                '`--[no-]issue-client-certificate` flag.')

  flags.MungeBasicAuthFlags(args)

  if args.IsSpecified('issue_client_certificate') and not (
      args.IsSpecified('enable_basic_auth') or args.IsSpecified('username')):
    log.warning('If `--issue-client-certificate` is specified but '
                '`--enable-basic-auth` or `--username` is not, our API will '
                'treat that as `--no-enable-basic-auth`.')

  if (args.IsSpecified('enable_cloud_endpoints') and
      properties.VALUES.container.new_scopes_behavior.GetBool()):
    raise util.Error('Flag --[no-]enable-cloud-endpoints is not allowed if '
                     'property container/ new_scopes_behavior is set to true.')
  if args.IsSpecified('enable_autorepair'):
    enable_autorepair = args.enable_autorepair
  else:
    # Node pools using COS support auto repairs, enable it for them by default.
    # Other node pools using (Ubuntu, custom images) don't support node auto
    # repairs, attempting to enable autorepair for them will result in API call
    # failing so don't do it.
    enable_autorepair = ((args.image_type or '').lower() in ['', 'cos'])
  flags.WarnForUnspecifiedIpAllocationPolicy(args)
  flags.WarnForNodeModification(args, enable_autorepair)
  metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                  args.metadata_from_file)
  return api_adapter.CreateClusterOptions(
      accelerators=args.accelerator,
      additional_zones=args.additional_zones,
      addons=args.addons,
      cluster_ipv4_cidr=args.cluster_ipv4_cidr,
      cluster_secondary_range_name=args.cluster_secondary_range_name,
      cluster_version=args.cluster_version,
      node_version=args.node_version,
      create_subnetwork=args.create_subnetwork,
      disk_type=args.disk_type,
      enable_autorepair=enable_autorepair,
      enable_autoscaling=args.enable_autoscaling,
      enable_autoupgrade=args.enable_autoupgrade,
      enable_cloud_endpoints=args.enable_cloud_endpoints,
      enable_cloud_logging=args.enable_cloud_logging,
      enable_cloud_monitoring=args.enable_cloud_monitoring,
      enable_ip_alias=args.enable_ip_alias,
      enable_kubernetes_alpha=args.enable_kubernetes_alpha,
      enable_legacy_authorization=args.enable_legacy_authorization,
      enable_master_authorized_networks=args.enable_master_authorized_networks,
      enable_network_policy=args.enable_network_policy,
      enable_private_nodes=args.enable_private_nodes,
      enable_private_endpoint=args.enable_private_endpoint,
      image_type=args.image_type,
      image=args.image,
      image_project=args.image_project,
      image_family=args.image_family,
      issue_client_certificate=args.issue_client_certificate,
      labels=args.labels,
      local_ssd_count=args.local_ssd_count,
      maintenance_window=args.maintenance_window,
      master_authorized_networks=args.master_authorized_networks,
      master_ipv4_cidr=args.master_ipv4_cidr,
      max_nodes=args.max_nodes,
      max_nodes_per_pool=args.max_nodes_per_pool,
      min_cpu_platform=args.min_cpu_platform,
      min_nodes=args.min_nodes,
      network=args.network,
      node_disk_size_gb=utils.BytesToGb(args.disk_size),
      node_labels=args.node_labels,
      node_locations=args.node_locations,
      node_machine_type=args.machine_type,
      node_taints=args.node_taints,
      num_nodes=args.num_nodes,
      password=args.password,
      preemptible=args.preemptible,
      scopes=args.scopes,
      service_account=args.service_account,
      services_ipv4_cidr=args.services_ipv4_cidr,
      services_secondary_range_name=args.services_secondary_range_name,
      subnetwork=args.subnetwork,
      tags=args.tags,
      user=args.username,
      metadata=metadata,
      default_max_pods_per_node=args.default_max_pods_per_node,
      max_pods_per_node=args.max_pods_per_node)
Exemple #8
0
def ParseCreateOptionsBase(args, is_autogke, get_default):
    """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)

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

    enable_autorepair = False
    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'))

    flags.ValidateCloudRunConfigCreateArgs(get_default('cloud_run_config'),
                                           get_default('addons'))
    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=get_default('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_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=args.enable_cloud_run_alpha if (hasattr(args, 'enable_cloud_run_alpha') and args.IsSpecified('enable_cloud_run_alpha')) else None,
        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'),
        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'),
        auto_gke=is_autogke)
Exemple #9
0
def ParseCreateOptionsBase(args):
    """Parses the flags provided with the cluster creation command."""
    if 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.MungeBasicAuthFlags(args)

    if args.IsSpecified('issue_client_certificate') and not (
            args.IsSpecified('enable_basic_auth')
            or args.IsSpecified('username')):
        log.warning(
            'If `--issue-client-certificate` is specified but '
            '`--enable-basic-auth` or `--username` is not, our API will '
            'treat that as `--no-enable-basic-auth`.')

    flags.WarnForUnspecifiedIpAllocationPolicy(args)
    enable_autorepair = cmd_util.GetAutoRepair(args)
    flags.WarnForNodeModification(args, enable_autorepair)
    metadata = metadata_utils.ConstructMetadataDict(args.metadata,
                                                    args.metadata_from_file)

    return api_adapter.CreateClusterOptions(
        accelerators=args.accelerator,
        additional_zones=args.additional_zones,
        addons=args.addons,
        cluster_ipv4_cidr=args.cluster_ipv4_cidr,
        cluster_secondary_range_name=args.cluster_secondary_range_name,
        cluster_version=args.cluster_version,
        node_version=args.node_version,
        create_subnetwork=args.create_subnetwork,
        disk_type=args.disk_type,
        enable_autorepair=enable_autorepair,
        enable_autoscaling=args.enable_autoscaling,
        enable_autoupgrade=cmd_util.GetAutoUpgrade(args),
        enable_binauthz=args.enable_binauthz,
        enable_stackdriver_kubernetes=args.enable_stackdriver_kubernetes if args.IsSpecified('enable_stackdriver_kubernetes') else None,
        enable_cloud_logging=args.enable_cloud_logging if args.IsSpecified('enable_cloud_logging') else None,
        enable_cloud_monitoring=args.enable_cloud_monitoring if args.IsSpecified('enable_cloud_monitoring') else None,
        enable_ip_alias=args.enable_ip_alias,
        enable_intra_node_visibility=args.enable_intra_node_visibility,
        enable_kubernetes_alpha=args.enable_kubernetes_alpha,
        enable_cloud_run_alpha=args.enable_cloud_run_alpha if args.IsSpecified('enable_cloud_run_alpha') else None,
        enable_legacy_authorization=args.enable_legacy_authorization,
        enable_master_authorized_networks=args.enable_master_authorized_networks,
        enable_network_policy=args.enable_network_policy,
        enable_private_nodes=args.enable_private_nodes,
        enable_private_endpoint=args.enable_private_endpoint,
        image_type=args.image_type,
        image=args.image,
        image_project=args.image_project,
        image_family=args.image_family,
        issue_client_certificate=args.issue_client_certificate,
        labels=args.labels,
        local_ssd_count=args.local_ssd_count,
        maintenance_window=args.maintenance_window,
        maintenance_window_start=args.maintenance_window_start,
        maintenance_window_end=args.maintenance_window_end,
        maintenance_window_recurrence=args.maintenance_window_recurrence,
        master_authorized_networks=args.master_authorized_networks,
        master_ipv4_cidr=args.master_ipv4_cidr,
        max_nodes=args.max_nodes,
        max_nodes_per_pool=args.max_nodes_per_pool,
        min_cpu_platform=args.min_cpu_platform,
        min_nodes=args.min_nodes,
        network=args.network,
        node_disk_size_gb=utils.BytesToGb(args.disk_size),
        node_labels=args.node_labels,
        node_locations=args.node_locations,
        node_machine_type=args.machine_type,
        node_taints=args.node_taints,
        num_nodes=args.num_nodes,
        password=args.password,
        preemptible=args.preemptible,
        scopes=args.scopes,
        service_account=args.service_account,
        services_ipv4_cidr=args.services_ipv4_cidr,
        services_secondary_range_name=args.services_secondary_range_name,
        subnetwork=args.subnetwork,
        tags=args.tags,
        user=args.username,
        metadata=metadata,
        default_max_pods_per_node=args.default_max_pods_per_node,
        max_pods_per_node=args.max_pods_per_node,
        enable_tpu=args.enable_tpu,
        tpu_ipv4_cidr=args.tpu_ipv4_cidr,
        resource_usage_bigquery_dataset=args.resource_usage_bigquery_dataset,
        enable_network_egress_metering=args.enable_network_egress_metering,
        enable_resource_consumption_metering=\
            args.enable_resource_consumption_metering,
        database_encryption_key=args.database_encryption_key,
        enable_vertical_pod_autoscaling=args.enable_vertical_pod_autoscaling,
        enable_autoprovisioning=args.enable_autoprovisioning,
        autoprovisioning_config_file=args.autoprovisioning_config_file,
        autoprovisioning_service_account=args.autoprovisioning_service_account,
        autoprovisioning_scopes=args.autoprovisioning_scopes,
        autoprovisioning_locations=args.autoprovisioning_locations,
        autoprovisioning_max_surge_upgrade=getattr(args, 'autoprovisioning_max_surge_upgrade', None),
        autoprovisioning_max_unavailable_upgrade=getattr(args, 'autoprovisioning_max_unavailable_upgrade', None),
        enable_autoprovisioning_autorepair=getattr(args, 'enable_autoprovisioning_autorepair', None),
        enable_autoprovisioning_autoupgrade=getattr(args, 'enable_autoprovisioning_autoupgrade', None),
        min_cpu=args.min_cpu,
        max_cpu=args.max_cpu,
        min_memory=args.min_memory,
        max_memory=args.max_memory,
        min_accelerator=args.min_accelerator,
        max_accelerator=args.max_accelerator,
        shielded_secure_boot=args.shielded_secure_boot,
        shielded_integrity_monitoring=args.shielded_integrity_monitoring,
        reservation_affinity=getattr(args, 'reservation_affinity', None),
        reservation=getattr(args, 'reservation', None),
        enable_shielded_nodes=args.enable_shielded_nodes,
        max_surge_upgrade=args.max_surge_upgrade,
        max_unavailable_upgrade=args.max_unavailable_upgrade)