diff --git a/README.md b/README.md index 6090d2d3..dc93df12 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ ## 仕組み -[`bootstrap/argocd/repos.yaml`](bootstrap/argocd/repos.yaml) の ApplicationSet が org 内のリポジトリを走査し、 +[`bootstrap/argocd-repos.yaml`](bootstrap/argocd-repos.yaml) の ApplicationSet が org 内のリポジトリを走査し、 各リポジトリの `deploy/argocd.yaml` を見つけて Argo CD の Application を生成する。 このリポジトリがどうデプロイされるか(同期対象パス・autoSync 等)もクラスタ側ではなく [`deploy/argocd.yaml`](deploy/argocd.yaml) で決まる。**Argo CD が同期するのは `apps/` 以下だけ** -(`bootstrap/` は machine config 側。Argo CD が見るのは `bootstrap/argocd/repos.yaml` の 1 本だけ)。 +(`bootstrap/` は machine config 側。Argo CD が見るのは `bootstrap/argocd-repos.yaml` の 1 本だけ)。 -`repos.yaml` は Argo CD の chart が作る `apps` Application が拾うので、**まっさらなクラスタでも CI を待たずに走りはじめる** +`argocd-repos.yaml` は Argo CD の chart が作る `apps` Application が拾うので、**まっさらなクラスタでも CI を待たずに走りはじめる** (詳しくは [`bootstrap/README.md`](bootstrap/README.md))。 ## ディレクトリ @@ -90,10 +90,10 @@ headlamp が 1 文字なのは、規則どおりだと head + lamp でも hubble | [`rybbit/`](apps/rybbit/) | Rybbit(`rt.doany.io`、アクセス解析。クッキー無し)+ ClickHouse + PostgreSQL + Redis。トドロクの離脱をファネル・ジャーニー・セッションリプレイで見る。**使い始めは [apps/rybbit/README.md](apps/rybbit/README.md)** | **動かしていないもの**は `apps/_/` に置いてある。`_` で始まるディレクトリは Argo CD が同期しない -([bootstrap/argocd/repos.yaml](bootstrap/argocd/repos.yaml) の `directory.exclude`。全リポジトリ共通の決まり)ので、 +([bootstrap/argocd-repos.yaml](bootstrap/argocd-repos.yaml) の `directory.exclude`。全リポジトリ共通の決まり)ので、 クラスタには何も作らない。動かすときは `git mv apps/_ apps/`。いまは無い。 **アプリの多くはこのリポジトリに無い。** 各アプリのリポジトリの `deploy/` に置いてあり、 -`bootstrap/argocd/repos.yaml` の ApplicationSet が拾う(上の「仕組み」)。 +`bootstrap/argocd-repos.yaml` の ApplicationSet が拾う(上の「仕組み」)。 `kubectl -n argocd get applications` が実際の一覧。 diff --git a/apps/forgejo/argocd-creds.yaml b/apps/forgejo/argocd-creds.yaml index abe48e75..5388175c 100644 --- a/apps/forgejo/argocd-creds.yaml +++ b/apps/forgejo/argocd-creds.yaml @@ -1,5 +1,5 @@ # ArgoCD が Forgejo の doa/* を読むための資格情報(repo-creds)。 -# bootstrap/argocd/repos.yaml の gitea scmProvider の API スキャンにも同じトークンを使う。 +# bootstrap/argocd-repos.yaml の gitea scmProvider の API スキャンにも同じトークンを使う。 # # Infisical /argocd/forgejo-repo-creds に 3 つ: # url https://fj.doany.io/doa ← 組織名を変えたらここも直す(接頭辞で照合する) diff --git a/bootstrap/README.md b/bootstrap/README.md index 632190dc..7e9b2dd9 100644 --- a/bootstrap/README.md +++ b/bootstrap/README.md @@ -1,7 +1,7 @@ # bootstrap クラスタそのものを組む層。**ここにあるものは全部 machine config に載る**([render.sh](render.sh) が描く)。 -ArgoCD はここを見ない(例外は [argocd/repos.yaml](argocd/repos.yaml) だけ。下の「ArgoCD が当てるもの」)。 +ArgoCD はここを見ない(例外は [argocd-repos.yaml](argocd-repos.yaml) だけ。下の「ArgoCD が当てるもの」)。 層の分け方は [docs/decisions.md](../docs/decisions.md)「層の分け方」。 | | 何を | いつ | @@ -26,7 +26,7 @@ ArgoCD はここを見ない(例外は [argocd/repos.yaml](argocd/repos.yaml) | [cert-manager-cloudflare-secret.sops.yaml](cert-manager-cloudflare-secret.sops.yaml) | DNS-01 の Cloudflare のトークン | | [apiserver-rbac.yaml](apiserver-rbac.yaml) / [apiserver-ca.crt](apiserver-ca.crt) | API サーバの入口の RBAC と CA(下の「API サーバの入口」) | | [local-path.yaml](local-path.yaml) | local-path-provisioner | -| [argocd/repos.yaml](argocd/repos.yaml) | ArgoCD が当てる唯一のファイル(下の「ArgoCD が当てるもの」) | +| [argocd-repos.yaml](argocd-repos.yaml) | ArgoCD が当てる唯一のファイル(下の「ArgoCD が当てるもの」) | **SOPS(age)で暗号化したファイルは名前を `*.sops.yaml` で終える**(`.sops.yaml` の規則もその名前にしか一致しないので、 別の名前では暗号化できない)。復号鍵はクラスタにも CI にも渡さない。 @@ -36,9 +36,12 @@ ArgoCD はここを見ない(例外は [argocd/repos.yaml](argocd/repos.yaml) ## ArgoCD が当てるもの -**ここで ArgoCD が当てるのは [argocd/repos.yaml](argocd/repos.yaml) だけ。** machine config に載っている +**ここで ArgoCD が当てるのは [argocd-repos.yaml](argocd-repos.yaml) だけ。** machine config に載っている `apps` の Application(`argocd-values.yaml` の `extraObjects`)が拾い、そこから ApplicationSet が `apps/` を当てる。 -場所が machine config に焼いてあるので、このファイルだけディレクトリに入っている(動かすと machine config を当て直すことになる)。 +場所(`path: bootstrap` と `include: argocd-repos.yaml`)が machine config に焼いてあるので、名前を変えると machine config を当て直すことになる。 +そのときは **main にマージしてから当てる**。マージから当てるまでの間、`apps` は古い path が無くて ComparisonError で止まるだけ +(何も消さない)。逆に先に当てると、新しい include が main の何にも当たらず空の描き出しになる(自動同期は空にする +prune を `allowEmpty` 無しでは拒むが、頼らない)。 ArgoCD の平文のマニフェストは `apps/` にある: [apps/gateway/](../apps/gateway/)(Gateway と http → https)、[apps/auth/](../apps/auth/)(SSO の oauth2-proxy)、 diff --git a/bootstrap/argocd/repos.yaml b/bootstrap/argocd-repos.yaml similarity index 98% rename from bootstrap/argocd/repos.yaml rename to bootstrap/argocd-repos.yaml index edf04568..d8064728 100644 --- a/bootstrap/argocd/repos.yaml +++ b/bootstrap/argocd-repos.yaml @@ -1,4 +1,4 @@ -# bootstrap/ で ArgoCD が当てるのはこのファイルだけ(machine config の `apps` が拾う。場所は argocd-values.yaml の +# bootstrap/ で ArgoCD が当てるのはこのファイルだけ(machine config の `apps` が拾う。場所と名前は argocd-values.yaml の # extraObjects に焼いてあるので、動かすと machine config を当て直すことになる)。平文のマニフェストは apps/ にある。 # Forgejo 側は別の ApplicationSet(下の `repos-forgejo`)に分ける。generator が 1 つでも失敗すると # Application を 1 本も作らないので、まっさらなクラスタ(Forgejo も forgejo-repo-creds もまだ無い)で diff --git a/bootstrap/argocd-values.yaml b/bootstrap/argocd-values.yaml index d8210f65..61cafc03 100644 --- a/bootstrap/argocd-values.yaml +++ b/bootstrap/argocd-values.yaml @@ -79,12 +79,13 @@ notifications: - on-sync-result - on-health-change # ArgoCD が自分を管理し始める種。chart は各要素を `tpl` に通すので、Go テンプレートを含むもの -# (ApplicationSet)は repos.yaml に置く。 +# (ApplicationSet)は argocd-repos.yaml に置く。 extraObjects: # danything/* を読む GitHub App の repo-creds(git から取れないのでここに置く)。名前は UI で作ったときのもの。 # 鍵は argocd-secret-values.sops.yaml。リストは値ファイルを重ねると丸ごと置き換わるので、map を toYaml して 1 要素にする。 - '{{ toYaml .Values.githubAppRepoCreds }}' - # app-of-apps。include を広げると bootstrap/ の他のファイルまで prune/selfHeal の対象になり、消すと ArgoCD が消える。 + # app-of-apps。path は bootstrap/ そのものなので include で 1 ファイルに絞る。広げると bootstrap/ の他のファイル + # (chart の値や SOPS 済み)まで当てようとし、prune/selfHeal の対象になって、消すと ArgoCD が消える。 - apiVersion: argoproj.io/v1alpha1 kind: Application metadata: @@ -95,9 +96,9 @@ extraObjects: source: repoURL: https://github.com/danything/gitops.git targetRevision: main - path: bootstrap/argocd + path: bootstrap directory: - include: repos.yaml + include: argocd-repos.yaml destination: server: https://kubernetes.default.svc namespace: argocd diff --git a/bootstrap/render.sh b/bootstrap/render.sh index 6c94542a..9f86f12d 100755 --- a/bootstrap/render.sh +++ b/bootstrap/render.sh @@ -123,7 +123,7 @@ chart cilium kube-system --api-versions gateway.networking.k8s.io/v1/GatewayClas inline local-path < bootstrap/local-path.yaml > "$WORK/inline-local-path.yaml" -# CI と人の RBAC。締め出されても直せるよう ArgoCD に載せない(ArgoCD は bootstrap/ を repos.yaml しか見ない)。 +# CI と人の RBAC。締め出されても直せるよう ArgoCD に載せない(ArgoCD は bootstrap/ を argocd-repos.yaml しか見ない)。 inline apiserver-rbac < bootstrap/apiserver-rbac.yaml > "$WORK/inline-apiserver-rbac.yaml" # 秘密の値は -secret-values.sops.yaml を -values.yaml に重ねる。infisical は chart がパスワードを diff --git a/deploy/argocd.yaml b/deploy/argocd.yaml index bc59670d..f4492218 100644 --- a/deploy/argocd.yaml +++ b/deploy/argocd.yaml @@ -1,4 +1,4 @@ -# このリポジトリの Application の設定(bootstrap/argocd/repos.yaml の ApplicationSet が読む) +# このリポジトリの Application の設定(bootstrap/argocd-repos.yaml の ApplicationSet が読む) name: gitops namespace: '' diff --git a/docs/decisions.md b/docs/decisions.md index 0a74652f..fc665331 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -98,7 +98,7 @@ Talos には helm-controller が無く、inlineManifests は Helm を実行で | 層 | 中身 | 資格情報 | | --- | --- | --- | -| **machine config** | **`bootstrap/` の全部**(`argocd/repos.yaml` を除く)。inline が 8 つ(cilium / local-path / `apiserver-rbac.yaml` / argocd / cert-manager / infisical / SOPS の Secret 2 つ)、CRD だけ URL で 5 つ(gateway-api / argocd ×3 / cert-manager) | 入力(`bootstrap/talos-secrets.sops.yaml` など)が SOPS 済みで、生成物は git に置かない | +| **machine config** | **`bootstrap/` の全部**(`argocd-repos.yaml` を除く)。inline が 8 つ(cilium / local-path / `apiserver-rbac.yaml` / argocd / cert-manager / infisical / SOPS の Secret 2 つ)、CRD だけ URL で 5 つ(gateway-api / argocd ×3 / cert-manager) | 入力(`bootstrap/talos-secrets.sops.yaml` など)が SOPS 済みで、生成物は git に置かない | | **ArgoCD** | `apps/`。`ClusterIssuer`・Gateway・auth・`InfisicalSecret` など、本体が machine config に居る部品の平文のマニフェストもここ(2026-10 までは `bootstrap/` に混ぜて Application `bootstrap` が当てていた)。**infisical の本体は来ない**(下の「infisical だけは ArgoCD に移せない」) | — | - **CRD だけ URL で渡すのは大きさの都合。** 埋めると machine config が 341 KB → 4 MB を超える。 diff --git a/recovery/README.md b/recovery/README.md index 41438375..b3e3d5bd 100644 --- a/recovery/README.md +++ b/recovery/README.md @@ -113,7 +113,7 @@ kubectl get gatewayclass # cilium が Accepted(無いと Gateway が `Waiting ## 5. Gateway・auth などが入るのを見る(ArgoCD) -手ですることは無い。ArgoCD の `gitops` の Application([../bootstrap/argocd/repos.yaml](../bootstrap/argocd/repos.yaml) の ApplicationSet が作る)が `apps/` の +手ですることは無い。ArgoCD の `gitops` の Application([../bootstrap/argocd-repos.yaml](../bootstrap/argocd-repos.yaml) の ApplicationSet が作る)が `apps/` の `ClusterIssuer`・Gateway・auth・`InfisicalSecret` を当てる。 ```shell