Stefano G.
Stefano G.

Reputation: 309

How to access at airflow by kubectl on google-cluoud-composer and airflow 1.10

I'm using the GCP Composer, to manage Apache on GCP.

For a new project I'm using the new version of Composer/Airflow (composer: 1.6.1, Airflow:1.10)

To connect at airflow by shell for check a broken DAG the GCP documentation tells:

  1. open GCP shell

  2. Connect to the GKE cluster

  3. myuser@cloudshell:~ kubectl get pods

  4. myuser@cloudshell:~ kubectl exec -it airflow-worker-1a2b3c-xyz12 -c airflow-worker -- /bin/bash

This work fine with Airflow 1.9 but on Airflow 1.10 kubectl get pods don't show worker pod, and I' haven't find documentation about how to access to airflow by kubeclt on AF 1.10

Someone can help me?

_myuser_@cloudshell:~ (_Myproject_)$ kubectl get pods 
NAME                                                        READY     STATUS      RESTARTS   AGE
airflow-monitoring-564c8c7dc5-hxb62                         1/1       Running     0          17h
airflow-redis-0                                             1/1       Running     0          17h
airflow-sqlproxy-594dbf87b7-nmtbh                           1/1       Running     0          17h
composer-agent-1a871e5e-fa97-4fa3-8843-d0b06718f7f6-rb4rj   0/1       Completed   0          12h
composer-agent-41ee85f8-90f2-45a1-a148-883421775651-jfjz6   0/1       Completed   0          12h
composer-agent-6984c0ef-4a0b-4150-bc6e-8a2996a5c38f-sd45f   0/1       Completed   0          17h
composer-agent-97de1623-5772-496d-a0c0-54adefc00c5a-rq9w6   0/1       Completed   0          12h
composer-agent-b3bc0dc6-6e95-4c9c-91d0-735755c2210f-tcxgg   0/1       Completed   0          73m
composer-fluentd-daemon-bkn28                               1/1       Running     133        17h
composer-fluentd-daemon-jvdlc                               1/1       Running     133        17h
composer-fluentd-daemon-lchq9                               1/1       Running     133        17h
composer-fluentd-daemon-wfzzr                               1/1       Running     133        17h

Upvotes: 1

Views: 2747

Answers (1)

hexacyanide
hexacyanide

Reputation: 91649

To accommodate in-place version upgrades, Cloud Composer now runs version-specific pods (the worker and the scheduler) in a non-default namespace that is named after the running versions. For example, this is what it might look like:

$ kubectl get ns | grep composer  # ns = namespaces
composer-1-6-1-airflow-1-10-1-04c210ec   Active   2d

You can then look for cluster resources specifically in that namespace:

$ kubectl get pods --namespace=composer-1-6-1-airflow-1-10-1-04c210ec
NAME                                 READY   STATUS      RESTARTS   AGE
airflow-database-init-job-mhn87      0/1     Completed   0          2d
airflow-scheduler-748ff8dc88-g2k5q   2/2     Running     0          2d
airflow-worker-5767579d-csvcg        2/2     Running     0          2d
airflow-worker-5767579d-d8fgd        2/2     Running     0          2d
airflow-worker-5767579d-tlwpc        2/2     Running     0          2d

If more convenient, you can also list resources in all namespaces:

$ kubectl get pods --all-namespaces  # or -A
$ kubectl get pods -A | grep airflow
composer-1-6-1-airflow-1-10-1-04c210ec   airflow-database-init-job-mhn87                                  0/1     Completed   0          2d
composer-1-6-1-airflow-1-10-1-04c210ec   airflow-scheduler-748ff8dc88-g2k5q                               2/2     Running     0          2d
composer-1-6-1-airflow-1-10-1-04c210ec   airflow-worker-5767579d-csvcg                                    2/2     Running     0          2d
composer-1-6-1-airflow-1-10-1-04c210ec   airflow-worker-5767579d-d8fgd                                    2/2     Running     0          2d
composer-1-6-1-airflow-1-10-1-04c210ec   airflow-worker-5767579d-tlwpc                                    2/2     Running     0          2d
default                                  airflow-monitoring-f78cd5c75-2n727                               1/1     Running     0          2d
default                                  airflow-redis-0                                                  1/1     Running     0          2d
default                                  airflow-sqlproxy-57b7976d59-qnkm7                                1/1     Running     0          2d

Example for how to SSH to one of the worker or scheduler pods:

# Long form
$ kubectl exec \
   --stdin --tty \
   --namespace=composer-1-8-1-airflow-1-10-3-6e595c80 
   airflow-scheduler-58948b8956-4sxwt /bin/bash

# Short form
$ kubectl exec -it \
   -n composer-1-8-1-airflow-1-10-3-6e595c80
   airflow-scheduler-58948b8956-4sxwt bash

Upvotes: 5

Related Questions