/home/by-natures/dev*

データ界隈で働くエンジニアとしての技術的なメモと、たまに普通の日記。

2024/07/03 Colima 環境での Airbyte ローカル環境構築

Airbyte のローカル環境へのインストール時のメモです。

公式ドキュメントでは abctl local install するだけ、と書いてあるのですが、Kuberenetes の環境として Colima を利用する際に少し設定変更が必要だったのでメモです。

Colima での Docker ソケットファイルを認識させる

$ abctl local install
  INFO    Using Kubernetes provider:
            Provider: kind
            Kubeconfig: /Users/<myname>/.airbyte/abctl/abctl.kubeconfig
            Context: kind-airbyte-abctl
  ERROR   Could not create Docker client                                                                                                                             
  ERROR   Unable to determine if Docker is installed                                                                                                                 
  ERROR   could not determine docker installation status: error communicating with docker: could not create client: error communicating with docker: could not create docker client: (could not ping docker client: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, could not ping docker client: Cannot connect to the Docker daemon at unix:///Users/<myname>/.docker/run/docker.sock. Is the docker daemon running?)

  INFO    An error occurred while communicating with the Docker daemon.                                                                                              
          Ensure that Docker is running and is accessible.  You may need to upgrade to a newer version of Docker.
          For additional help please visit https://docs.docker.com/get-docker/

Colima で Docker 環境を準備していますが、 Cannot connect to the Docker daemon at unix:///Users/<myname>/.docker/run/docker.sock (myname は私のローカルアカウント名) と出ています。

検索すると、Github の Airbyte リポジトリで同じ問題についてのスレッドが見つかりました:

[abctl] Could not communicate with the Docker daemon · Issue #38071 · airbytehq/airbyte · GitHub

Colima ではソケットインタフェースを ~/.colima/default/docker.sock に作成するため、これを何らかの方法でクライアントに認識させなければいけないとのこと。公式FAQにも紹介されていて、IDEに設定するか、 DOCKER_HOST に上記パスを設定するか、シンボリックリンクを張るかの3つの方法があると紹介されています:

colima/docs/FAQ.md at main · abiosoft/colima · GitHub

今回はローカル環境だったので、シンボリックリンクを張る方法で回避しました:

$ ls -al ~/.colima/default/
colima.yaml  daemon/      docker.sock 
$ sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock

github.com

リソース不足で失敗

$ colima start --kubernetes

上記コマンドで実行した場合、デフォルトの2 CPUs, 2GiB memory and 60GiB storage で環境構築されるようです:

GitHub - abiosoft/colima: Container runtimes on macOS (and Linux) with minimal setup

このリソースでは Airbyte のインストールに失敗してしまいます:

$ abctl local install
  INFO    Using Kubernetes provider:
            Provider: kind
            Kubeconfig: /Users/<myname>/.airbyte/abctl/abctl.kubeconfig
            Context: kind-airbyte-abctl
 SUCCESS  Found Docker installation: version 26.1.1                                                                                                                                                               
 SUCCESS  Port 8000 appears to be available                                                                                                                                                                       
  INFO    No existing cluster found, cluster 'airbyte-abctl' will be created                                                                                                                                      
 SUCCESS  Cluster 'airbyte-abctl' created                                                                                                                                                                         
  INFO    Namespace 'airbyte-abctl' created                                                                                                                                                                       
  INFO    Persistent volume 'airbyte-minio-pv' created                                                                                                                                                            
  INFO    Persistent volume 'airbyte-volume-db' created                                                                                                                                                           
  INFO    Persistent volume claim 'airbyte-minio-pv-claim-airbyte-minio-0' created                                                                                                                                
  INFO    Persistent volume claim 'airbyte-volume-db-airbyte-db-0' created                                                                                                                                        
  ERROR   Failed to install airbyte/airbyte Helm Chart                                                                                                                                                            
  ERROR   Unable to install Airbyte locally                                                                                                                                                                       
  ERROR   could not install airbyte chart: could not install helm: etcdserver: request timed out

リソースを増やして環境構築

Colima に割り当てるリソースを増やし、再実行:

$ colima start --cpu 8 --memory 12 --disk 160 --kubernetes
$ abctl local install
  INFO    Using Kubernetes provider:
            Provider: kind
            Kubeconfig: /Users/<myname>/.airbyte/abctl/abctl.kubeconfig
            Context: kind-airbyte-abctl
 SUCCESS  Found Docker installation: version 26.1.1                                                                                                                  
 SUCCESS  Port 8000 appears to be available                                                                                                                          
  INFO    No existing cluster found, cluster 'airbyte-abctl' will be created                                                                                         
 SUCCESS  Cluster 'airbyte-abctl' created                                                                                                                            
  INFO    Namespace 'airbyte-abctl' created                                                                                                                          
  INFO    Persistent volume 'airbyte-minio-pv' created                                                                                                               
  INFO    Persistent volume 'airbyte-volume-db' created                                                                                                              
  INFO    Persistent volume claim 'airbyte-minio-pv-claim-airbyte-minio-0' created                                                                                   
  INFO    Persistent volume claim 'airbyte-volume-db-airbyte-db-0' created
...

インストール完了後、Airbyte の管理画面がブラウザで立ち上がりました。

KUBECONFIG を指定してクラスタの確認

上記出力から分かる通り、Kubernetes に airbyte-abctl というクラスタが作成されています。

また Kubernetes の設定ファイルも上記ログに出ていますが、/Users/<myname>/.airbyte/abctl/abctl.kubeconfig に作成されているため、クラスタの状況を確認するにはこの設定ファイルを渡さなければいけません。Kubernetes の設定ファイルの渡し方は以下公式ページで紹介されています: Organizing Cluster Access Using kubeconfig Files | Kubernetes

今回は環境変数に渡して確認をしました:

$ export KUBECONFIG=/Users/<myname>/.airbyte/abctl/abctl.kubeconfig
$ kubectl config get-contexts
CURRENT   NAME                 CLUSTER              AUTHINFO             NAMESPACE
*         kind-airbyte-abctl   kind-airbyte-abctl   kind-airbyte-abctl   
$ kubectl get namespaces
NAME                 STATUS   AGE
airbyte-abctl        Active   6h2m
default              Active   6h2m
ingress-nginx        Active   6h
kube-node-lease      Active   6h2m
kube-public          Active   6h2m
kube-system          Active   6h2m
local-path-storage   Active   6h2m
$ kubectl get pods -n airbyte-abctl
NAME                                                     READY   STATUS      RESTARTS   AGE
airbyte-abctl-airbyte-api-server-56f478bb66-qtmjj        1/1     Running     0          6h2m
airbyte-abctl-airbyte-bootloader                         0/1     Completed   0          6h2m
airbyte-abctl-connector-builder-server-6bf9954cc-4v2ml   1/1     Running     0          6h2m
airbyte-abctl-cron-c49456cf5-5d4sj                       1/1     Running     0          6h2m
airbyte-abctl-pod-sweeper-pod-sweeper-bccfd8bd5-r48l7    1/1     Running     0          6h2m
airbyte-abctl-server-7f8689bcc6-v4gbp                    1/1     Running     0          6h2m
airbyte-abctl-temporal-757586cb6-6k6jr                   1/1     Running     0          6h2m
airbyte-abctl-webapp-75498bcfbc-8w4zd                    1/1     Running     0          6h2m
airbyte-abctl-worker-74d4b9cf7c-7b774                    1/1     Running     0          6h2m
airbyte-db-0                                             1/1     Running     0          6h2m
airbyte-minio-0                                          1/1     Running     0          6h2m