【Airflow】Apache Airflow ~ 環境構築 / Kubernetes 編 ~

■ はじめに

https://dk521123.hatenablog.com/entry/2021/07/18/004531
https://dk521123.hatenablog.com/entry/2021/10/11/134840

の続き。

今回は、久しぶりに、Apache Airflow で、
Kubernetes で環境構築していく。

目次

【0】今回学べること
【1】前提条件
【2】Airflow のインストール
 1)Artifact hub から調べる

【0】今回学べること

[1] Airflow の Kubernetes での導入
[2] Artifact hub の利用方法

【1】前提条件

https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/kubernetes.html

に載っている。

[1] Kubernetes がインストールされていること

* インストールについては、以下の関連記事を参照のこと

KubernetesWindows / 環境構築編 ~
https://dk521123.hatenablog.com/entry/2020/05/01/000000
Kubernetes ~ 基本編 / minikube ~
https://dk521123.hatenablog.com/entry/2023/05/07/214515

[2] kubectl がインストールされていること

* インストールについては、
 以下の関連記事の「kubectlのインストール」を参照のこと

https://dk521123.hatenablog.com/entry/2023/05/10/220241

[3] helm がインストールされていること

* インストールについては、以下の関連記事を参照のこと

https://dk521123.hatenablog.com/entry/2023/05/11/000840

【2】Airflow のインストール

* 公式サイトに記載されている

https://airflow.apache.org/docs/helm-chart/stable/index.html

1)Artifact hub から調べる

[1] Artifact hub にアクセス

* 以下のサイトをブラウザからアクセスする

https://artifacthub.io/

[2] 検索ボックスからインストールしたいモジュールを検索

* 今回の場合、「airflow」
 => 検索にHitしたら、クリックし、詳細を表示

[3] 画面左の「INSTALL」ボタンをクリックし、インストール方法をコピー

# ★コピーのみで、実行はしない

# Add repository
helm repo add apache-airflow https://airflow.apache.org/

# Install chart
helm install my-airflow apache-airflow/airflow --version 1.9.0

補足1:画面左の「DEFAULT VALUES」ボタンをクリックし、設定ファイルをダウンロード可能

* YAMLファイル「values-airflow.yaml」ってファイルをダウンロードして
 そのファイルをインストールする際に適用可能

補足2:Airflow公式サイトから
https://airflow.apache.org/docs/helm-chart/stable/index.html

# より

# リポジトリの追加
helm repo add apache-airflow https://airflow.apache.org

# Airflow のインストール (Namespace「airflow」も作ってくれる)
helm upgrade --install airflow apache-airflow/airflow --namespace airflow --create-namespace

2)インストールする

[1] クラスタを起動

minikube start

# Minikube の稼働状況を確認
minikube status

[2] インストールを実行する

# Add repository
helm repo add apache-airflow https://airflow.apache.org/
# 「helm repo add apache-airflow https://airflow.apache.org」と表示

# 個別でNamespace を作成する場合
# kubectl create namespace airflow

# Install chart(名前は変更し、デバッグ用に「--debug」を追加)
helm install demo-airflow apache-airflow/airflow --create-namespace -n airflow -f values-airflow.yaml --debug

【3】後片付け

1)アンインストールする

# 確認
helm ls

# Namespace を指定した場合
# helm ls --namespace airflow

# アンインストールする
helm uninstall my-airflow
# 「release "my-airflow" uninstalled」が表示

# helm uninstall my-airflow --namespace airflow

# 「Error: failed to delete release: airflow」って言われたので
# helm status で確認(「STATUS: uninstalling」???)
helm status my-airflow --namespace airflow

# 確認(なんもなかった。。。)
helm ls --namespace airflow

参考文献

https://zenn.dev/shorter/articles/dcf694061bb4bf
https://qiita.com/chan-p/items/8d31346dbaa0ee90bccf

関連記事

Apache Airflow ~ 環境構築編 ~
https://dk521123.hatenablog.com/entry/2021/07/18/004531
Apache Airflow ~ 環境構築 / Docker 編 ~
https://dk521123.hatenablog.com/entry/2021/10/11/134840
Apache Airflow ~ 基礎知識編 ~
https://dk521123.hatenablog.com/entry/2021/09/28/135510
Apache Airflow ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2021/07/24/233012
Apache Airflow ~ 基本編 ~
https://dk521123.hatenablog.com/entry/2021/07/28/234319
Kubernetes ~ 基本編 / Helm ~
https://dk521123.hatenablog.com/entry/2023/05/11/000840
Apache Flink ~ 環境構築 / Kubernetes 編 ~
https://dk521123.hatenablog.com/entry/2023/05/09/235256