Skip to content

Commit 142a9a6

Browse files
pavel-salnikovriathakkar
authored andcommitted
Remove templated config_file path, fix parameter comments (GoogleCloudPlatform#12653)
* Remove templated config_file path, fix parameter comments * Add back templated params info, capitalize Docker
1 parent a57b8c6 commit 142a9a6

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

composer/workflows/kubernetes_pod_operator_c2.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
schedule_interval=datetime.timedelta(days=1),
6464
start_date=YESTERDAY,
6565
) as dag:
66-
# Only name, namespace, image, and task_id are required to create a
66+
# Only name, image, and task_id are required to create a
6767
# KubernetesPodOperator. In Cloud Composer, the config file found at
6868
# `/home/airflow/composer_kube_config` contains credentials for
6969
# Cloud Composer's Google Kubernetes Engine cluster that is created
@@ -79,7 +79,8 @@
7979
cmds=["echo"],
8080
# The namespace to run within Kubernetes. In Composer 2 environments
8181
# after December 2022, the default namespace is
82-
# `composer-user-workloads`.
82+
# `composer-user-workloads`. Always use the
83+
# `composer-user-workloads` namespace with Composer 3.
8384
namespace="composer-user-workloads",
8485
# Docker image specified. Defaults to hub.docker.com, but any fully
8586
# qualified URLs will point to a custom repository. Supports private
@@ -100,27 +101,26 @@
100101
name="ex-kube-templates",
101102
namespace="composer-user-workloads",
102103
image="bash",
103-
# All parameters below are able to be templated with jinja -- cmds,
104-
# arguments, env_vars, and config_file. For more information visit:
105-
# https://airflow.apache.org/docs/apache-airflow/stable/macros-ref.html
104+
# All parameters below can be templated with Jinja. For more information
105+
# and the list of variables available in Airflow, see
106+
# the Airflow templates reference:
107+
# https://airflow.apache.org/docs/apache-airflow/stable/templates-ref.html
106108
# Entrypoint of the container, if not specified the Docker container's
107109
# entrypoint is used. The cmds parameter is templated.
108110
cmds=["echo"],
109-
# DS in jinja is the execution date as YYYY-MM-DD, this docker image
110-
# will echo the execution date. Arguments to the entrypoint. The docker
111+
# DS in Jinja is the execution date as YYYY-MM-DD, this Docker image
112+
# will echo the execution date. Arguments to the entrypoint. The Docker
111113
# image's CMD is used if this is not provided. The arguments parameter
112114
# is templated.
113115
arguments=["{{ ds }}"],
114116
# The var template variable allows you to access variables defined in
115117
# Airflow UI. In this case we are getting the value of my_value and
116118
# setting the environment variable `MY_VALUE`. The pod will fail if
117-
# `my_value` is not set in the Airflow UI.
119+
# `my_value` is not set in the Airflow UI. The env_vars parameter
120+
# is templated.
118121
env_vars={"MY_VALUE": "{{ var.value.my_value }}"},
119-
# Sets the config file to a kubernetes config file specified in
120-
# airflow.cfg. If the configuration file does not exist or does
121-
# not provide validcredentials the pod will fail to launch. If not
122-
# specified, config_file defaults to ~/.kube/config
123-
config_file="{{ conf.get('core', 'kube_config') }}",
122+
# Specifies path to Kubernetes config. The config_file is templated.
123+
config_file="/home/airflow/composer_kube_config",
124124
# Identifier of connection that should be used
125125
kubernetes_conn_id="kubernetes_default",
126126
)
@@ -135,9 +135,11 @@
135135
# The secrets to pass to Pod, the Pod will fail to create if the
136136
# secrets you specify in a Secret object do not exist in Kubernetes.
137137
secrets=[secret_env, secret_volume],
138+
# Entrypoint of the container, if not specified the Docker container's
139+
# entrypoint is used. The cmds parameter is templated.
138140
cmds=["echo"],
139141
# env_vars allows you to specify environment variables for your
140-
# container to use. env_vars is templated.
142+
# container to use. The env_vars parameter is templated.
141143
env_vars={
142144
"EXAMPLE_VAR": "/example/value",
143145
"GOOGLE_APPLICATION_CREDENTIALS": "/var/secrets/google/service-account.json",
@@ -157,7 +159,7 @@
157159
# Entrypoint of the container, if not specified the Docker container's
158160
# entrypoint is used. The cmds parameter is templated.
159161
cmds=["perl"],
160-
# Arguments to the entrypoint. The docker image's CMD is used if this
162+
# Arguments to the entrypoint. The Docker image's CMD is used if this
161163
# is not provided. The arguments parameter is templated.
162164
arguments=["-Mbignum=bpi", "-wle", "print bpi(2000)"],
163165
# The secrets to pass to Pod, the Pod will fail to create if the
@@ -167,8 +169,8 @@
167169
labels={"pod-label": "label-name"},
168170
# Timeout to start up the Pod, default is 600.
169171
startup_timeout_seconds=600,
170-
# The environment variables to be initialized in the container
171-
# env_vars are templated.
172+
# The environment variables to be initialized in the container.
173+
# The env_vars parameter is templated.
172174
env_vars={"EXAMPLE_VAR": "/example/value"},
173175
# If true, logs stdout output of container. Defaults to True.
174176
get_logs=True,

0 commit comments

Comments
 (0)