Ejemplo n.º 1
0
def _AddMutuallyExclusiveArgs(mutex_group, release_track):
    """Add all arguments that need to be mutually exclusive from each other."""
    if release_track in [base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA]:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(
                spec={
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                    api_adapter.NETWORK_POLICY: _ParseAddonDisabled,
                    api_adapter.ISTIO: _ParseAddonDisabled,
                    api_adapter.CLOUDRUN: _ParseAddonDisabled,
                    api_adapter.APPLICATIONMANAGER: _ParseAddonDisabled,
                }),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED
{istio}=ENABLED|DISABLED
{application_manager}=ENABLED|DISABLED
{network_policy}=ENABLED|DISABLED
{cloudrun}=ENABLED|DISABLED""".format(
                hpa=api_adapter.HPA,
                ingress=api_adapter.INGRESS,
                dashboard=api_adapter.DASHBOARD,
                network_policy=api_adapter.NETWORK_POLICY,
                istio=api_adapter.ISTIO,
                application_manager=api_adapter.APPLICATIONMANAGER,
                cloudrun=api_adapter.CLOUDRUN,
            ))

    else:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(
                spec={
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                    api_adapter.NETWORK_POLICY: _ParseAddonDisabled,
                }),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED
{network_policy}=ENABLED|DISABLED""".format(
                hpa=api_adapter.HPA,
                ingress=api_adapter.INGRESS,
                dashboard=api_adapter.DASHBOARD,
                network_policy=api_adapter.NETWORK_POLICY,
            ))

    mutex_group.add_argument(
        '--generate-password',
        action='store_true',
        default=None,
        help='Ask the server to generate a secure password and use that as the '
        'basic auth password, keeping the existing username.')
    mutex_group.add_argument(
        '--set-password',
        action='store_true',
        default=None,
        help='Set the basic auth password to the specified value, keeping the '
        'existing username.')

    flags.AddBasicAuthFlags(mutex_group)
Ejemplo n.º 2
0
def _AddMutuallyExclusiveArgs(mutex_group, release_track):
    """Add all arguments that need to be mutually exclusive from each other."""
    mutex_group.add_argument(
        '--monitoring-service',
        help='The monitoring service to use for the cluster. Options '
        'are: "monitoring.googleapis.com" (the Google Cloud Monitoring '
        'service),  "none" (no metrics will be exported from the cluster)')

    # Network policy is only for alpha/beta
    if release_track in [base.ReleaseTrack.BETA, base.ReleaseTrack.ALPHA]:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(
                spec={
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                    api_adapter.NETWORK_POLICY: _ParseAddonDisabled,
                }),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED
{network_policy}=ENABLED|DISABLED""".format(
                hpa=api_adapter.HPA,
                ingress=api_adapter.INGRESS,
                dashboard=api_adapter.DASHBOARD,
                network_policy=api_adapter.NETWORK_POLICY))

    else:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(
                spec={
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                }),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED""".format(hpa=api_adapter.HPA,
                                       ingress=api_adapter.INGRESS,
                                       dashboard=api_adapter.DASHBOARD))

    mutex_group.add_argument(
        '--generate-password',
        action='store_true',
        default=None,
        help='Ask the server to generate a secure password and use that as the '
        'basic auth password, keeping the existing username.')
    mutex_group.add_argument(
        '--set-password',
        action='store_true',
        default=None,
        help='Set the basic auth password to the specified value, keeping the '
        'existing username.')

    flags.AddBasicAuthFlags(mutex_group, None, None)
Ejemplo n.º 3
0
def _Args(parser):
    """Register flags for this command.

  Args:
    parser: An argparse.ArgumentParser-like object. It is mocked out in order to
      capture some information, but behaves like an ArgumentParser.
  """
    parser.add_argument('name',
                        help="""\
The name of the cluster to create.

The name may contain only lowercase alphanumerics and '-', must start with a
letter and end with an alphanumeric, and must be no longer than 40
characters.
""")
    # Timeout in seconds for operation
    parser.add_argument('--timeout',
                        type=int,
                        default=1800,
                        hidden=True,
                        help='THIS ARGUMENT NEEDS HELP TEXT.')
    flags.AddAsyncFlag(parser)
    parser.add_argument(
        '--num-nodes',
        type=arg_parsers.BoundedInt(1),
        help=
        'The number of nodes to be created in each of the cluster\'s zones.',
        default=3)
    flags.AddMachineTypeFlag(parser)
    parser.add_argument('--subnetwork',
                        help="""\
The Google Compute Engine subnetwork
(https://cloud.google.com/compute/docs/subnetworks) to which the cluster is
connected. The subnetwork must belong to the network specified by --network.

Cannot be used with the "--create-subnetwork" option.
""")
    parser.add_argument(
        '--network',
        help='The Compute Engine Network that the cluster will connect to. '
        'Google Kubernetes Engine will use this network when creating routes '
        'and firewalls for the clusters. Defaults to the \'default\' network.')
    parser.add_argument(
        '--cluster-ipv4-cidr',
        help='The IP address range for the pods in this cluster in CIDR '
        'notation (e.g. 10.0.0.0/14).  Prior to Kubernetes version 1.7.0 '
        'this must be a subset of 10.0.0.0/8; however, starting with version '
        '1.7.0 can be any RFC 1918 IP range.')
    parser.add_argument('--enable-cloud-logging',
                        action='store_true',
                        default=True,
                        help='Automatically send logs from the cluster to the '
                        'Google Cloud Logging API.')
    parser.set_defaults(enable_cloud_logging=True)
    parser.add_argument(
        '--enable-cloud-monitoring',
        action='store_true',
        default=True,
        help='Automatically send metrics from pods in the cluster to the '
        'Google Cloud Monitoring API. VM metrics will be collected by Google '
        'Compute Engine regardless of this setting.')
    parser.set_defaults(enable_cloud_monitoring=True)
    parser.add_argument('--disk-size',
                        type=arg_parsers.BinarySize(lower_bound='10GB'),
                        help='Size for node VM boot disks. Defaults to 100GB.')
    flags.AddBasicAuthFlags(parser)
    parser.add_argument(
        '--max-nodes-per-pool',
        type=arg_parsers.BoundedInt(100, api_adapter.MAX_NODES_PER_POOL),
        help='The maximum number of nodes to allocate per default initial node '
        'pool. Kubernetes Engine will automatically create enough nodes pools '
        'such that each node pool contains less than '
        '--max-nodes-per-pool nodes. Defaults to {nodes} nodes, but can be set '
        'as low as 100 nodes per pool on initial create.'.format(
            nodes=api_adapter.MAX_NODES_PER_POOL))
    flags.AddImageTypeFlag(parser, 'cluster')
    flags.AddImageFlag(parser, hidden=True)
    flags.AddImageProjectFlag(parser, hidden=True)
    flags.AddImageFamilyFlag(parser, hidden=True)
    flags.AddNodeLabelsFlag(parser)
    flags.AddTagsFlag(
        parser, """\
Applies the given Compute Engine tags (comma separated) on all nodes in the new
node-pool. Example:

  $ {command} example-cluster --tags=tag1,tag2

New nodes, including ones created by resize or recreate, will have these tags
on the Compute Engine API instance object and can be used in firewall rules.
See https://cloud.google.com/sdk/gcloud/reference/compute/firewall-rules/create
for examples.
""")
    parser.display_info.AddFormat(util.CLUSTERS_FORMAT)
    flags.AddIssueClientCertificateFlag(parser)
    flags.AddAcceleratorArgs(parser)
    flags.AddDiskTypeFlag(parser)
    flags.AddMetadataFlags(parser)
Ejemplo n.º 4
0
def _AddMutuallyExclusiveArgs(mutex_group, release_track):
    """Add all arguments that need to be mutually exclusive from each other."""
    if release_track == base.ReleaseTrack.ALPHA:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(spec=dict(
                {
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                    api_adapter.NETWORK_POLICY: _ParseAddonDisabled,
                    api_adapter.ISTIO: _ParseAddonDisabled,
                    api_adapter.APPLICATIONMANAGER: _ParseAddonDisabled,
                    api_adapter.CLOUDBUILD: _ParseAddonDisabled,
                    api_adapter.NODELOCALDNS: _ParseAddonDisabled,
                    api_adapter.GCEPDCSIDRIVER: _ParseAddonDisabled,
                    api_adapter.CONFIGCONNECTOR: _ParseAddonDisabled,
                }, **{
                    k: _ParseAddonDisabled
                    for k in api_adapter.CLOUDRUN_ADDONS
                }), ),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED
{istio}=ENABLED|DISABLED
{application_manager}=ENABLED|DISABLED
{network_policy}=ENABLED|DISABLED
{cloudrun}=ENABLED|DISABLED
{cloudbuild}=ENABLED|DISABLED
{configconnector}=ENABLED|DISABLED
{nodelocaldns}=ENABLED|DISABLED
{gcepdcsidriver}=ENABLED|DISABLED""".format(
                hpa=api_adapter.HPA,
                ingress=api_adapter.INGRESS,
                dashboard=api_adapter.DASHBOARD,
                network_policy=api_adapter.NETWORK_POLICY,
                istio=api_adapter.ISTIO,
                application_manager=api_adapter.APPLICATIONMANAGER,
                cloudrun=api_adapter.CLOUDRUN_ADDONS[0],
                cloudbuild=api_adapter.CLOUDBUILD,
                configconnector=api_adapter.CONFIGCONNECTOR,
                nodelocaldns=api_adapter.NODELOCALDNS,
                gcepdcsidriver=api_adapter.GCEPDCSIDRIVER,
            ))

    elif release_track == base.ReleaseTrack.BETA:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(spec=dict(
                {
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                    api_adapter.NETWORK_POLICY: _ParseAddonDisabled,
                    api_adapter.ISTIO: _ParseAddonDisabled,
                    api_adapter.APPLICATIONMANAGER: _ParseAddonDisabled,
                    api_adapter.NODELOCALDNS: _ParseAddonDisabled,
                    api_adapter.GCEPDCSIDRIVER: _ParseAddonDisabled,
                    api_adapter.CONFIGCONNECTOR: _ParseAddonDisabled,
                }, **{
                    k: _ParseAddonDisabled
                    for k in api_adapter.CLOUDRUN_ADDONS
                }), ),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED
{istio}=ENABLED|DISABLED
{application_manager}=ENABLED|DISABLED
{network_policy}=ENABLED|DISABLED
{cloudrun}=ENABLED|DISABLED
{configconnector}=ENABLED|DISABLED
{nodelocaldns}=ENABLED|DISABLED
{gcepdcsidriver}=ENABLED|DISABLED""".format(
                hpa=api_adapter.HPA,
                ingress=api_adapter.INGRESS,
                dashboard=api_adapter.DASHBOARD,
                network_policy=api_adapter.NETWORK_POLICY,
                istio=api_adapter.ISTIO,
                application_manager=api_adapter.APPLICATIONMANAGER,
                cloudrun=api_adapter.CLOUDRUN_ADDONS[0],
                configconnector=api_adapter.CONFIGCONNECTOR,
                nodelocaldns=api_adapter.NODELOCALDNS,
                gcepdcsidriver=api_adapter.GCEPDCSIDRIVER,
            ))

    else:
        mutex_group.add_argument(
            '--update-addons',
            type=arg_parsers.ArgDict(spec=dict(
                {
                    api_adapter.INGRESS: _ParseAddonDisabled,
                    api_adapter.HPA: _ParseAddonDisabled,
                    api_adapter.DASHBOARD: _ParseAddonDisabled,
                    api_adapter.NETWORK_POLICY: _ParseAddonDisabled,
                    api_adapter.NODELOCALDNS: _ParseAddonDisabled,
                    api_adapter.CONFIGCONNECTOR: _ParseAddonDisabled,
                    api_adapter.GCEPDCSIDRIVER: _ParseAddonDisabled,
                }, **{
                    k: _ParseAddonDisabled
                    for k in api_adapter.CLOUDRUN_ADDONS
                }), ),
            dest='disable_addons',
            metavar='ADDON=ENABLED|DISABLED',
            help="""Cluster addons to enable or disable. Options are
{hpa}=ENABLED|DISABLED
{ingress}=ENABLED|DISABLED
{dashboard}=ENABLED|DISABLED
{network_policy}=ENABLED|DISABLED
{cloudrun}=ENABLED|DISABLED
{configconnector}=ENABLED|DISABLED
{nodelocaldns}=ENABLED|DISABLED
{gcepdcsidriver}=ENABLED|DISABLED""".format(
                hpa=api_adapter.HPA,
                ingress=api_adapter.INGRESS,
                dashboard=api_adapter.DASHBOARD,
                network_policy=api_adapter.NETWORK_POLICY,
                cloudrun=api_adapter.CLOUDRUN_ADDONS[0],
                configconnector=api_adapter.CONFIGCONNECTOR,
                nodelocaldns=api_adapter.NODELOCALDNS,
                gcepdcsidriver=api_adapter.GCEPDCSIDRIVER,
            ))

    mutex_group.add_argument(
        '--generate-password',
        action='store_true',
        default=None,
        help='Ask the server to generate a secure password and use that as the '
        'basic auth password, keeping the existing username.')
    mutex_group.add_argument(
        '--set-password',
        action='store_true',
        default=None,
        help='Set the basic auth password to the specified value, keeping the '
        'existing username.')

    flags.AddBasicAuthFlags(mutex_group)