Beispiel #1
0
    def Args(parser):
        _CommonArgs(parser)

        # Private IP falgs without ranges missing in alpha.
        flags.AddPrivateIpEnvironmentFlags(parser, False)

        # Adding alpha arguments
        parser.add_argument(
            '--airflow-executor-type',
            hidden=True,
            choices={
                'CELERY': 'Task instances will run by CELERY executor',
                'KUBERNETES': 'Task instances will run by KUBERNETES executor'
            },
            help=
            """The type of executor by which task instances are run on Airflow;
        currently supported executor types are CELERY and KUBERNETES.
        Defaults to CELERY. Cannot be updated.""")
Beispiel #2
0
def _CommonArgs(parser):
  """Common arguments that apply to all ReleaseTracks."""
  resource_args.AddEnvironmentResourceArg(parser, 'to create')
  base.ASYNC_FLAG.AddToParser(parser)
  parser.add_argument(
      '--node-count',
      type=int,
      help='The number of nodes to create to run the environment.')
  parser.add_argument(
      '--zone',
      help='The Compute Engine zone in which the environment will '
      'be created. For example `--zone=us-central1-a`.')
  parser.add_argument(
      '--machine-type',
      help='The Compute Engine machine type '
      '(https://cloud.google.com/compute/docs/machine-types) to use for '
      'nodes. For example `--machine-type=n1-standard-1`.')
  parser.add_argument(
      '--disk-size',
      default='100GB',
      type=arg_parsers.BinarySize(
          lower_bound='20GB',
          upper_bound='64TB',
          suggested_binary_size_scales=['GB', 'TB']),
      help='The disk size for each VM node in the environment. The minimum '
      'size is 20GB, and the maximum is 64TB. Specified value must be an '
      'integer multiple of gigabytes. Cannot be updated after the '
      'environment has been created. If units are not provided, defaults to '
      'GB.')
  networking_group = parser.add_group(help='Virtual Private Cloud networking')
  networking_group.add_argument(
      '--network',
      required=True,
      help='The Compute Engine Network to which the environment will '
      'be connected. If a \'Custom Subnet Network\' is provided, '
      '`--subnetwork` must be specified as well.')
  networking_group.add_argument(
      '--subnetwork',
      help='The Compute Engine subnetwork '
      '(https://cloud.google.com/compute/docs/subnetworks) to which the '
      'environment will be connected.')
  labels_util.AddCreateLabelsFlags(parser)
  flags.CREATE_ENV_VARS_FLAG.AddToParser(parser)
  # Default is provided by API server.
  parser.add_argument(
      '--service-account',
      help='The Google Cloud Platform service account to be used by the node '
      'VMs. If a service account is not specified, the "default" Compute '
      'Engine service account for the project is used. Cannot be updated.')
  # Default is provided by API server.
  parser.add_argument(
      '--oauth-scopes',
      help='The set of Google API scopes to be made available on all of the '
      'node VMs. Defaults to '
      '[\'https://www.googleapis.com/auth/cloud-platform\']. Cannot be '
      'updated.',
      type=arg_parsers.ArgList(),
      metavar='SCOPE',
      action=arg_parsers.UpdateAction)
  parser.add_argument(
      '--tags',
      help='The set of instance tags applied to all node VMs. Tags are used '
      'to identify valid sources or targets for network firewalls. Each tag '
      'within the list must comply with RFC 1035. Cannot be updated.',
      type=arg_parsers.ArgList(),
      metavar='TAG',
      action=arg_parsers.UpdateAction)

  # API server will validate key/value pairs.
  parser.add_argument(
      '--airflow-configs',
      help="""\
A list of Airflow software configuration override KEY=VALUE pairs to set. For
information on how to structure KEYs and VALUEs, run
`$ {top_command} help composer environments update`.""",
      type=arg_parsers.ArgDict(),
      metavar='KEY=VALUE',
      action=arg_parsers.UpdateAction)

  parser.add_argument(
      '--python-version',
      type=str,
      choices={
          '2': 'Created environment will use Python 2',
          '3': 'Created environment will use Python 3'
      },
      help='The Python version to be used within the created environment. '
      'Supplied value should represent the desired major Python version. '
      'Cannot be updated.')

  version_group = parser.add_mutually_exclusive_group()
  airflow_version_type = arg_parsers.RegexpValidator(
      r'^(\d+\.\d+(?:\.\d+)?)', 'must be in the form X.Y[.Z].')
  version_group.add_argument(
      '--airflow-version',
      type=airflow_version_type,
      help="""Version of Airflow to run in the environment.

      Must be of the form `X.Y[.Z]`.

      The latest supported Cloud Composer version will be used within
      the created environment.""")

  image_version_type = arg_parsers.RegexpValidator(
      r'^composer-(\d+\.\d+.\d+(?:-[a-z]+\.\d+)?|latest)-airflow-(\d+\.\d+(?:\.\d+)?)',
      'must be in the form \'composer-A.B.C[-D.E]-airflow-X.Y[.Z]\' or '
      '\'latest\' can be provided in place of the Cloud Composer version '
      'string. For example: \'composer-latest-airflow-1.10.0\'.')
  version_group.add_argument(
      '--image-version',
      type=image_version_type,
      help="""Version of the image to run in the environment.

      The image version encapsulates the versions of both Cloud Composer
      and Apache Airflow. Must be of the form
      `composer-A.B.C[-D.E]-airflow-X.Y[.Z]`.

      The Cloud Composer and Airflow versions are semantic versions.
      `latest` can be provided instead of an explicit Cloud Composer
      version number indicating that the server will replace `latest`
      with the current Cloud Composer version. For the Apache Airflow
      portion, the patch version can be omitted and the current
      version will be selected. The version numbers that are used will
      be stored.""")
  flags.AddIpAliasEnvironmentFlags(parser)
  flags.AddPrivateIpEnvironmentFlags(parser)
Beispiel #3
0
def _CommonArgs(parser, support_max_pods_per_node, release_track):
    """Common arguments that apply to all ReleaseTracks."""
    resource_args.AddEnvironmentResourceArg(parser, 'to create')
    base.ASYNC_FLAG.AddToParser(parser)
    parser.add_argument(
        '--node-count',
        type=int,
        help='The number of nodes to create to run the environment.')
    parser.add_argument(
        '--zone',
        help='The Compute Engine zone in which the environment will '
        'be created. For example `--zone=us-central1-a`.')
    parser.add_argument(
        '--machine-type',
        help='The Compute Engine machine type '
        '(https://cloud.google.com/compute/docs/machine-types) to use for '
        'nodes. For example `--machine-type=n1-standard-1`.')
    parser.add_argument(
        '--disk-size',
        type=arg_parsers.BinarySize(lower_bound='20GB',
                                    upper_bound='64TB',
                                    suggested_binary_size_scales=['GB', 'TB']),
        help='The disk size for each VM node in the environment. The minimum '
        'size is 20GB, and the maximum is 64TB. Specified value must be an '
        'integer multiple of gigabytes. Cannot be updated after the '
        'environment has been created. If units are not provided, defaults to '
        'GB.',
        action=flags.V1ExclusiveStoreAction)
    networking_group = parser.add_group(
        help='Virtual Private Cloud networking')
    networking_group.add_argument(
        '--network',
        required=True,
        help='The Compute Engine Network to which the environment will '
        'be connected. If a \'Custom Subnet Network\' is provided, '
        '`--subnetwork` must be specified as well.')
    networking_group.add_argument(
        '--subnetwork',
        help='The Compute Engine subnetwork '
        '(https://cloud.google.com/compute/docs/subnetworks) to which the '
        'environment will be connected.')
    labels_util.AddCreateLabelsFlags(parser)
    flags.CREATE_ENV_VARS_FLAG.AddToParser(parser)
    # Default is provided by API server.
    parser.add_argument(
        '--service-account',
        help='The Google Cloud Platform service account to be used by the node '
        'VMs. If a service account is not specified, the "default" Compute '
        'Engine service account for the project is used. Cannot be updated.')
    # Default is provided by API server.
    parser.add_argument(
        '--oauth-scopes',
        help='The set of Google API scopes to be made available on all of the '
        'node VMs. Defaults to '
        '[\'https://www.googleapis.com/auth/cloud-platform\']. Cannot be '
        'updated.',
        type=arg_parsers.ArgList(),
        metavar='SCOPE',
        action=arg_parsers.UpdateAction)
    parser.add_argument(
        '--tags',
        help='The set of instance tags applied to all node VMs. Tags are used '
        'to identify valid sources or targets for network firewalls. Each tag '
        'within the list must comply with RFC 1035. Cannot be updated.',
        type=arg_parsers.ArgList(),
        metavar='TAG',
        action=arg_parsers.UpdateAction)

    # API server will validate key/value pairs.
    parser.add_argument('--airflow-configs',
                        help="""\
A list of Airflow software configuration override KEY=VALUE pairs to set. For
information on how to structure KEYs and VALUEs, run
`$ {top_command} help composer environments update`.""",
                        type=arg_parsers.ArgDict(),
                        metavar='KEY=VALUE',
                        action=arg_parsers.UpdateAction)

    parser.add_argument(
        '--python-version',
        type=str,
        choices={
            '2': 'Created environment will use Python 2',
            '3': 'Created environment will use Python 3'
        },
        action=flags.V1ExclusiveStoreAction,
        help='The Python version to be used within the created environment. '
        'Supplied value should represent the desired major Python version. '
        'Cannot be updated.')

    version_group = parser.add_mutually_exclusive_group()
    airflow_version_type = arg_parsers.RegexpValidator(
        r'^(\d+(?:\.\d+(?:\.\d+)?)?)', 'must be in the form X[.Y[.Z]].')
    version_group.add_argument(
        '--airflow-version',
        type=airflow_version_type,
        help="""Version of Apache Airflow to run in the environment.

      Must be of the form `X[.Y[.Z]]`, where `[]` denotes optional fragments.

      The current Cloud Composer version will be used within the created
      environment. The Apache Airflow version is a semantic version or an alias
      in the form of major or major.minor version numbers, resolved to the
      latest matching Apache Airflow version supported in the current Cloud
      Composer version. The resolved version is stored in the created
      environment.""")

    image_version_type = arg_parsers.RegexpValidator(
        r'^composer-(\d+(?:\.\d+.\d+(?:-[a-z]+\.\d+)?)?|latest)-airflow-(\d+(?:\.\d+(?:\.\d+)?)?)',
        'must be in the form \'composer-A[.B.C[-D.E]]-airflow-X[.Y[.Z]]\' or '
        '\'latest\' can be provided in place of the Cloud Composer version '
        'string. For example: \'composer-latest-airflow-1.10.0\'.')
    version_group.add_argument(
        '--image-version',
        type=image_version_type,
        help="""Version of the image to run in the environment.

      The image version encapsulates the versions of both Cloud Composer
      and Apache Airflow. Must be of the form
      `composer-A[.B.C[-D.E]]-airflow-X[.Y[.Z]]`, where `[]` denotes optional
      fragments.

      The Cloud Composer portion of the image version is a semantic version or
      an alias in the form of major version number or `latest`, resolved to the
      current Cloud Composer version. The Apache Airflow portion of the image
      version is a semantic version or an alias in the form of major or
      major.minor version numbers, resolved to the latest matching Apache
      Airflow version supported in the given Cloud Composer version. The
      resolved versions are stored in the created environment.""")
    flags.AddIpAliasEnvironmentFlags(parser, support_max_pods_per_node)
    flags.AddPrivateIpEnvironmentFlags(parser)
    web_server_group = parser.add_mutually_exclusive_group()
    flags.WEB_SERVER_ALLOW_IP.AddToParser(web_server_group)
    flags.WEB_SERVER_ALLOW_ALL.AddToParser(web_server_group)
    flags.WEB_SERVER_DENY_ALL.AddToParser(web_server_group)
    flags.CLOUD_SQL_MACHINE_TYPE.AddToParser(parser)
    flags.WEB_SERVER_MACHINE_TYPE.AddToParser(parser)
    flags.AddMaintenanceWindowFlagsGroup(parser)

    permission_info = '{} must hold permission {}'.format(
        "The 'Cloud Composer Service Agent' service account",
        "'Cloud KMS CryptoKey Encrypter/Decrypter'")
    kms_resource_args.AddKmsKeyResourceArg(parser,
                                           'environment',
                                           permission_info=permission_info)

    if release_track == base.ReleaseTrack.GA:
        flags.ENVIRONMENT_SIZE_GA.choice_arg.AddToParser(parser)
    elif release_track == base.ReleaseTrack.BETA:
        flags.ENVIRONMENT_SIZE_BETA.choice_arg.AddToParser(parser)
    elif release_track == base.ReleaseTrack.ALPHA:
        flags.ENVIRONMENT_SIZE_ALPHA.choice_arg.AddToParser(parser)

    autoscaling_group_parser = parser.add_argument_group(
        flags.AUTOSCALING_FLAG_GROUP_DESCRIPTION)
    flags.SCHEDULER_CPU.AddToParser(autoscaling_group_parser)
    flags.WORKER_CPU.AddToParser(autoscaling_group_parser)
    flags.WEB_SERVER_CPU.AddToParser(autoscaling_group_parser)
    flags.SCHEDULER_MEMORY.AddToParser(autoscaling_group_parser)
    flags.WORKER_MEMORY.AddToParser(autoscaling_group_parser)
    flags.WEB_SERVER_MEMORY.AddToParser(autoscaling_group_parser)
    flags.SCHEDULER_STORAGE.AddToParser(autoscaling_group_parser)
    flags.WORKER_STORAGE.AddToParser(autoscaling_group_parser)
    flags.WEB_SERVER_STORAGE.AddToParser(autoscaling_group_parser)
    flags.MIN_WORKERS.AddToParser(autoscaling_group_parser)
    flags.MAX_WORKERS.AddToParser(autoscaling_group_parser)
    flags.NUM_SCHEDULERS.AddToParser(autoscaling_group_parser)
Beispiel #4
0
 def Args(parser):
     _CommonArgs(parser)
     flags.AddPrivateIpEnvironmentFlags(parser, True)
Beispiel #5
0
 def AlphaAndBetaArgs(parser):
     Create.Args(parser)
     flags.AddPrivateIpEnvironmentFlags(parser)
     flags.AddIpAliasEnvironmentFlags(parser)