Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))。

## ディレクトリ
Expand Down Expand Up @@ -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/_<name>/` に置いてある。`_` で始まるディレクトリは 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/_<name> apps/<name>`。いまは無い。

**アプリの多くはこのリポジトリに無い。** 各アプリのリポジトリの `deploy/` に置いてあり、
`bootstrap/argocd/repos.yaml` の ApplicationSet が拾う(上の「仕組み」)。
`bootstrap/argocd-repos.yaml` の ApplicationSet が拾う(上の「仕組み」)。
`kubectl -n argocd get applications` が実際の一覧。

2 changes: 1 addition & 1 deletion apps/forgejo/argocd-creds.yaml
Original file line number Diff line number Diff line change
@@ -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 ← 組織名を変えたらここも直す(接頭辞で照合する)
Expand Down
11 changes: 7 additions & 4 deletions bootstrap/README.md
Original file line number Diff line number Diff line change
@@ -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)「層の分け方」。

| | 何を | いつ |
Expand All @@ -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 にも渡さない。
Expand All @@ -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)、
Expand Down
Original file line number Diff line number Diff line change
@@ -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 もまだ無い)で
Expand Down
9 changes: 5 additions & 4 deletions bootstrap/argocd-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/render.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

# 秘密の値は <name>-secret-values.sops.yaml を <name>-values.yaml に重ねる。infisical は chart がパスワードを
Expand Down
2 changes: 1 addition & 1 deletion deploy/argocd.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# このリポジトリの Application の設定(bootstrap/argocd/repos.yaml の ApplicationSet が読む)
# このリポジトリの Application の設定(bootstrap/argocd-repos.yaml の ApplicationSet が読む)
name: gitops
namespace: ''

Expand Down
2 changes: 1 addition & 1 deletion docs/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 を超える。
Expand Down
2 changes: 1 addition & 1 deletion recovery/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading