ArgoCDで複数のapp of appsを作成できるか検証する

背景

  • アプリケーションが増えた
  • アプリケーションを管理するチームごとで地味にリリースフローが変化する
  • 複数のクラスターが存在する
  • kustomizationの変数の使い方が競合する

Kubernetes環境をローカルにセットアップする

ArgoCDの環境を作成する

$ brew install minikube
# minikubeを起動する
$ minikube start --vm=true

ArgoCDをインストールする

  • https://argo-cd.readthedocs.io/en/stable/getting_started/
$ kubectl create namespace argocd
# ドキュメントだと core-instal.yaml を指定されているが、これだとargocd serverがセットアップされない
$ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

ArgoCD Serverにアクセスする

argocd-serverをPort Forwardしてブラウザからアクセスできる状態にします。

$ kubectl get svc -n argocd                                                                                         火  1/18 12:45:23 2022
NAME                    TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
argocd-dex-server       ClusterIP   10.109.95.218   <none>        5556/TCP,5557/TCP,5558/TCP   4m5s
argocd-metrics          ClusterIP   10.96.98.228    <none>        8082/TCP                     11m
argocd-redis            ClusterIP   10.104.172.83   <none>        6379/TCP                     11m
argocd-repo-server      ClusterIP   10.98.75.150    <none>        8081/TCP,8084/TCP            11m
argocd-server           ClusterIP   10.107.72.31    <none>        80/TCP,443/TCP               4m5s
argocd-server-metrics   ClusterIP   10.106.75.140   <none>        8083/TCP                     4m5s
$ kubectl port-forward svc/argocd-server -n argocd 8080:443

http://localhost:8080でアクセス可能ですが、パスワード変更が必要です。

パスワード変更

練習用のため

# まずはadminユーザーのパスワードを取得
$ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

# ユーザー名 admin、パスワードは前述の結果を入力してログイン
$ argocd login 127.0.0.1:8080

# ログインが完了したらパスワードを更新
$ argocd account update-password

app of appsを作成する

argocd app create apps \
  --repo https://github.com/Himenon/argocd-apps.git \
  --path overlays/local \
  --dest-server https://kubernetes.default.svc \
  --revision master \
  --dest-namespace argocd

これでまずはapp of appsを試します。

別名でできるか

argocd app create myworkspace-apps \
  --repo https://github.com/Himenon/argocd-apps.git \
  --path overlays/local \
  --dest-server https://kubernetes.default.svc \
  --revision master \
  --dest-namespace argocd

→ できる