【问题标题】:Running docker operator from Google Cloud Composer从 Google Cloud Composer 运行 docker 运算符
【发布时间】:2018-07-05 07:24:27
【问题描述】:

至于文档,Google Cloud Composer 气流工作节点由专用的 kubernetes 集群提供服务:

我有一个包含 Docker 的 ETL 步骤,我想使用气流运行,最好在托管工人的同一个 Kubernetes 上或在专用集群上。

从 Cloud Composer 气流环境启动 Docker Operation 的最佳做法是什么?

务实的解决方案是❤️

【问题讨论】:

标签: google-cloud-platform google-cloud-composer


【解决方案1】:

Google Cloud Composer 刚刚发布到正式版,您现在可以使用 KubernetesPodOperator 将 pod 启动到托管气流使用的同一 GKE 集群中。

确保您的 Composer 环境至少为 1.0.0

一个示例运算符:

import datetime

from airflow import models
from airflow.contrib.operators import kubernetes_pod_operator

with models.DAG(
    dag_id='composer_sample_kubernetes_pod',
    schedule_interval=datetime.timedelta(days=1),
    start_date=YESTERDAY) as dag:
# Only name, namespace, image, and task_id are required to create a
# KubernetesPodOperator. In Cloud Composer, currently the operator defaults
# to using the config file found at `/home/airflow/composer_kube_config if
# no `config_file` parameter is specified. By default it will contain the
# credentials for Cloud Composer's Google Kubernetes Engine cluster that is
# created upon environment creation.
kubernetes_min_pod = kubernetes_pod_operator.KubernetesPodOperator(
    # The ID specified for the task.
    task_id='pod-ex-minimum',
    # Name of task you want to run, used to generate Pod ID.
    name='pod-ex-minimum',
    # The namespace to run within Kubernetes, default namespace is
    # `default`. There is the potential for the resource starvation of
    # Airflow workers and scheduler within the Cloud Composer environment,
    # the recommended solution is to increase the amount of nodes in order
    # to satisfy the computing requirements. Alternatively, launching pods
    # into a custom namespace will stop fighting over resources.
    namespace='default',
    # Docker image specified. Defaults to hub.docker.com, but any fully
    # qualified URLs will point to a custom repository. Supports private
    # gcr.io images if the Composer Environment is under the same
    # project-id as the gcr.io images.
    image='gcr.io/gcp-runtimes/ubuntu_16_0_4')

其他资源:

【讨论】:

  • 我正在使用 gitlab Ci Yaml 运行 google cloud composer 环境,但出现错误:为 gke-cluster-name 生成 kubeconfig 条目 ERROR: (gcloud.beta.composer.environments.run) No running找到 GKE pod。如果环境是最近启动的,请稍候再试。
猜你喜欢
  • 2022-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多