Пример #1
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',
                        metavar='NAME',
                        help='The name of the cluster to upgrade.')
    flags.AddClusterVersionFlag(parser,
                                help="""\
The Kubernetes release version to which to upgrade the cluster's nodes.

If desired cluster version is omitted, *node* upgrades default to the current
*master* version and *master* upgrades default to the default cluster version,
which can be found in the server config.

You can find the list of allowed versions for upgrades by running:

  $ gcloud container get-server-config
""")
    parser.add_argument('--node-pool', help='The node pool to upgrade.')
    parser.add_argument(
        '--master',
        help='Upgrade the cluster\'s master to the latest version of Kubernetes'
        ' supported on Kubernetes Engine. Nodes cannot be upgraded at the same'
        ' time as the master.',
        action='store_true')
    flags.AddAsyncFlag(parser)
    flags.AddImageTypeFlag(parser, 'cluster/node pool')
    flags.AddImageFlag(parser, hidden=True)
    flags.AddImageProjectFlag(parser, hidden=True)
Пример #2
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',
      metavar='NAME',
      help='The name of the cluster to upgrade.')
  flags.AddClusterVersionFlag(
      parser,
      help="""\
The Kubernetes release version to which to upgrade the cluster's nodes.

If provided, the --cluster-version must be no greater than the cluster
master's minor version (x.*X*.x), and must be a latest patch version
(x.x.*X*).

You can find the list of allowed versions for upgrades by running:

  $ gcloud container get-server-config
""")
  parser.add_argument(
      '--node-pool',
      help='The node pool to upgrade.')
  parser.add_argument(
      '--master',
      help='Upgrade the cluster\'s master to the latest version of Kubernetes'
      ' supported on Container Engine. Nodes cannot be upgraded at the same'
      ' time as the master.',
      action='store_true')
  flags.AddAsyncFlag(parser)
  flags.AddImageTypeFlag(parser, 'cluster/node pool')
Пример #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=3600,
        hidden=True,
        help='Timeout (seconds) for waiting on the operation to complete.')
    flags.AddAsyncFlag(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.

If you omit this option, a range is chosen automatically.  The automatically
chosen range is randomly selected from 10.0.0.0/8 and will not include IP
address ranges allocated to VMs, existing routes, or ranges allocated to other
clusters. The automatically chosen range might conflict with reserved IP
addresses, dynamic routes, or routes within VPCs that peer with this cluster.
You should specify `--cluster-ipv4-cidr` to prevent conflicts.
""")

    parser.display_info.AddFormat(util.CLUSTERS_FORMAT)
Пример #4
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 this cluster.')
        parser.add_argument('--size',
                            required=True,
                            type=int,
                            help=('Target number of nodes in the cluster.'))
        parser.add_argument('--node-pool', help='The node pool to resize.')
        flags.AddAsyncFlag(parser)
Пример #5
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('names',
                            metavar='NAME',
                            nargs='+',
                            help='The names of the clusters to delete.')
        parser.add_argument('--timeout',
                            type=int,
                            default=1800,
                            help=argparse.SUPPRESS)
        flags.AddAsyncFlag(parser)
Пример #6
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.
    """
        # TODO(b/28639250): Support remote completion when the SDK supports it.
        flags.AddNodePoolNameArg(parser,
                                 'The name of the node pool to delete.')
        parser.add_argument('--timeout',
                            type=int,
                            default=1800,
                            help=argparse.SUPPRESS)
        flags.AddAsyncFlag(parser)
        flags.AddNodePoolClusterFlag(
            parser, 'The cluster from which to delete the node pool.')
Пример #7
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.
    """

    flags.AddAsyncFlag(parser)
    flags.AddNodePoolNameArg(parser, 'The name of the node pool to rollback.')
    flags.AddNodePoolClusterFlag(
        parser, 'The cluster from which to rollback the node pool.')
    parser.add_argument(
        '--timeout',
        type=int,
        default=1800,  # Seconds
        hidden=True,
        help='THIS ARGUMENT NEEDS HELP TEXT.')
Пример #8
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('names',
                            metavar='NAME',
                            nargs='+',
                            help='The names of the clusters to delete.')
        parser.add_argument(
            '--timeout',
            type=int,
            default=3600,
            hidden=True,
            help='Timeout (seconds) for waiting on the operation to complete.')
        flags.AddAsyncFlag(parser)
Пример #9
0
def _AddCommonArgs(parser):
    """Register common 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',
                        metavar='NAME',
                        help='The name of the cluster to update.')
    parser.add_argument('--node-pool', help='Node pool to be updated.')
    # Timeout in seconds for the operation, default 3600 seconds (60 minutes)
    parser.add_argument(
        '--timeout',
        type=int,
        default=3600,
        hidden=True,
        help='Timeout (seconds) for waiting on the operation to complete.')
    flags.AddAsyncFlag(parser)
Пример #10
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',
      metavar='NAME',
      help='The name of the cluster to upgrade.')
  flags.AddClusterVersionFlag(
      parser,
      help="""\
The Kubernetes release version to which to upgrade the cluster's nodes.

When upgrading nodes, the minor version (*X.Y*.Z) must be no greater than the
cluster master's minor version (i.e. if the master's version is 1.2.34, the
nodes cannot be upgraded to 1.3.45). For any minor version, only the latest
patch version (X.Y.*Z*) is allowed (i.e. if there exists a version 1.2.34, the
nodes cannot be upgraded to 1.2.33). Omit to upgrade to the same version as the
master.

When upgrading master, the only valid value is the latest supported version.
Omit to have the server automatically select the latest version.

You can find the list of allowed versions for upgrades by running:

  $ gcloud container get-server-config
""")
  parser.add_argument(
      '--node-pool',
      help='The node pool to upgrade.')
  parser.add_argument(
      '--master',
      help='Upgrade the cluster\'s master to the latest version of Kubernetes'
      ' supported on Kubernetes Engine. Nodes cannot be upgraded at the same'
      ' time as the master.',
      action='store_true')
  flags.AddAsyncFlag(parser)
  flags.AddImageTypeFlag(parser, 'cluster/node pool')
  flags.AddImageFlag(parser, hidden=True)
  flags.AddImageProjectFlag(parser, hidden=True)
Пример #11
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 this cluster.')
        group = parser.add_mutually_exclusive_group(required=True)
        group.add_argument('--size',
                           type=int,
                           dest='num_nodes',
                           action=actions.DeprecationAction(
                               '--size',
                               warn='The {flag_name} flag is now '
                               'deprecated. Please use `--num-nodes` '
                               'instead.'),
                           help='Target number of nodes in the cluster.')
        group.add_argument('--num-nodes',
                           type=int,
                           help='Target number of nodes in the cluster.')
        parser.add_argument('--node-pool', help='The node pool to resize.')
        flags.AddAsyncFlag(parser)
Пример #12
0
def _AddCommonArgs(parser):
    parser.add_argument('name',
                        metavar='NAME',
                        help='The name of the cluster to update.')
    parser.add_argument('--node-pool', help='Node pool to be updated.')
    flags.AddAsyncFlag(parser)
Пример #13
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)
Пример #14
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 this cluster.')
    # Timeout in seconds for operation
    parser.add_argument('--timeout',
                        type=int,
                        default=1800,
                        help=argparse.SUPPRESS)
    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)
    parser.add_argument('--additional-zones',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='ZONE',
                        help="""\
The set of additional zones in which the specified node footprint should be
replicated. All zones must be in the same region as the cluster's primary zone.
If additional-zones is not specified, all nodes will be in the cluster's primary
zone.

Note that `NUM_NODES` nodes will be created in each zone, such that if you
specify `--num-nodes=4` and choose one additional zone, 8 nodes will be created.

Multiple locations can be specified, separated by commas. For example:

  $ {command} example-cluster --zone us-central1-a --additional-zones us-central1-b,us-central1-c
""")
    parser.add_argument(
        '--machine-type',
        '-m',
        help='The type of machine to use for nodes. Defaults to n1-standard-1.'
    )
    parser.add_argument(
        '--subnetwork',
        help='The name of the Google Compute Engine subnetwork '
        '(https://cloud.google.com/compute/docs/subnetworks) to which the '
        'cluster is connected. If specified, the cluster\'s network must be a '
        '"custom subnet" network.'
        ''
        'Can not be used with the "--create-subnetwork" option.')
    parser.add_argument(
        '--disable-addons',
        type=arg_parsers.ArgList(
            choices=[api_adapter.INGRESS, api_adapter.HPA]),
        help='List of cluster addons to disable. Options are {0}'.format(
            ', '.join([api_adapter.INGRESS, api_adapter.HPA])))
    parser.add_argument(
        '--network',
        help='The Compute Engine Network that the cluster will connect to. '
        'Google Container 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(
        '--password',
        help='The password to use for cluster auth. Defaults to a '
        'server-specified randomly-generated string.')
    parser.add_argument('--scopes',
                        type=arg_parsers.ArgList(min_length=1),
                        metavar='SCOPE',
                        help="""\
Specifies scopes for the node instances. The project's default
service account is used. Examples:

  $ {{command}} example-cluster --scopes https://www.googleapis.com/auth/devstorage.read_only

  $ {{command}} example-cluster --scopes bigquery,storage-rw,compute-ro

Multiple SCOPEs can specified, separated by commas. The scopes
necessary for the cluster to function properly (compute-rw, storage-ro),
are always added, even if not explicitly specified.

SCOPE can be either the full URI of the scope or an alias.
Available aliases are:

[format="csv",options="header"]
|========
Alias,URI
{aliases}
|========
""".format(aliases=compute_constants.ScopesForHelp()))
    parser.add_argument(
        '--enable-cloud-endpoints',
        action='store_true',
        default=True,
        help='Automatically enable Google Cloud Endpoints to take advantage of '
        'API management features.')
    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=int,
        help='Size in GB for node VM boot disks. Defaults to 100GB.')
    parser.add_argument('--username',
                        '-u',
                        help='The user name to use for cluster auth.',
                        default='admin')
    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. Container 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.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.
""")
    flags.AddClusterVersionFlag(parser)
    flags.AddDiskTypeFlag(parser, suppressed=True)
    parser.display_info.AddFormat(util.CLUSTERS_FORMAT)
Пример #15
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 this cluster.')
    # Timeout in seconds for operation
    parser.add_argument('--timeout',
                        type=int,
                        default=1800,
                        help=argparse.SUPPRESS)
    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)
    parser.add_argument(
        '--machine-type',
        '-m',
        help='The type of machine to use for nodes. Defaults to n1-standard-1.'
    )
    parser.add_argument(
        '--subnetwork',
        help='The name of the Google Compute Engine subnetwork '
        '(https://cloud.google.com/compute/docs/subnetworks) to which the '
        'cluster is connected. If specified, the cluster\'s network must be a '
        '"custom subnet" network.'
        ''
        'Can not be used with the "--create-subnetwork" option.')
    parser.add_argument(
        '--network',
        help='The Compute Engine Network that the cluster will connect to. '
        'Google Container 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(
        '--password',
        help='The password to use for cluster auth. Defaults to a '
        'server-specified randomly-generated string.')
    parser.add_argument(
        '--enable-cloud-endpoints',
        action='store_true',
        default=True,
        help='Automatically enable Google Cloud Endpoints to take advantage of '
        'API management features.')
    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=int,
        help='Size in GB for node VM boot disks. Defaults to 100GB.')
    parser.add_argument('--username',
                        '-u',
                        help='The user name to use for cluster auth.',
                        default='admin')
    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. Container 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.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.
""")
    flags.AddClusterVersionFlag(parser)
    flags.AddDiskTypeFlag(parser, suppressed=True)
    parser.display_info.AddFormat(util.CLUSTERS_FORMAT)