Scaffold Argo CD: self-managed install, app-of-apps, apps/ ApplicationSet
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2d26549dd8
commit
a5a2d23761
13 changed files with 250 additions and 0 deletions
57
README.md
57
README.md
|
|
@ -1,2 +1,59 @@
|
|||
# argocd
|
||||
|
||||
GitOps for the homelab k3s cluster (`k3s-design.md`). Argo CD watches this repo
|
||||
on Forgejo and deploys whatever is on `main`.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
bootstrap/root.yaml the only thing applied by hand: the "root" Application -> cluster/
|
||||
cluster/ cluster-level Argo objects (app-of-apps)
|
||||
argocd.yaml Argo CD manages its own install from argocd/
|
||||
apps.yaml ApplicationSet: one Application per folder in apps/
|
||||
argocd/ Argo CD install (upstream install.yaml pinned + small patches)
|
||||
apps/<name>/ one app per folder, deployed to namespace <name>
|
||||
```
|
||||
|
||||
Argo reads the repo at `http://10.0.0.14:3000/un-oeil/argocd.git` (Forgejo's
|
||||
internal address): pods can't reach `forgejo.un-oeil.fr` because the host has no
|
||||
hairpin NAT. The repo is public, so no credentials are needed.
|
||||
|
||||
## Bootstrap (once)
|
||||
|
||||
Over WireGuard, with `KUBECONFIG=~/.kube/k3s-homelab.yaml`. Push this repo first:
|
||||
Argo pulls from Forgejo, not from your laptop.
|
||||
|
||||
```bash
|
||||
kubectl apply --server-side -k argocd/
|
||||
kubectl -n argocd rollout status deploy/argocd-server
|
||||
kubectl apply -f bootstrap/root.yaml
|
||||
```
|
||||
|
||||
Admin password (user `admin`), then change it in the UI and delete the secret:
|
||||
|
||||
```bash
|
||||
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d; echo
|
||||
```
|
||||
|
||||
UI: either `kubectl -n argocd port-forward svc/argocd-server 8080:80` →
|
||||
http://localhost:8080, or add `10.0.0.141 argocd.un-oeil.fr` to `/etc/hosts` →
|
||||
http://argocd.un-oeil.fr. Argo CD is admin-only: **don't add it to Caddy**.
|
||||
|
||||
## Launching an app
|
||||
|
||||
1. Create `apps/<name>/` (copy `apps/whoami/`). Its contents can be:
|
||||
- plain manifests, or
|
||||
- a `kustomization.yaml` (Helm charts work too via `helmCharts:`), or
|
||||
- a `Chart.yaml` (umbrella chart with the real chart as a dependency + `values.yaml`).
|
||||
2. Commit and push. Argo picks it up within ~3 min (or hit *Refresh* in the UI)
|
||||
and creates namespace `<name>`.
|
||||
3. To make it public: add an Ingress with host `<name>.un-oeil.fr`, then a Caddy
|
||||
vhost (LXC 100) pointing at Traefik on `10.0.0.141-143:80`.
|
||||
|
||||
Removing a folder deletes the app **and its resources, PVCs included**.
|
||||
|
||||
## Not there yet
|
||||
|
||||
- Storage: only k3s `local-path` (data stuck on one node). Longhorn is the next app.
|
||||
- Secrets: nothing yet. Don't commit plain Secrets; add Sealed Secrets or SOPS first.
|
||||
- Forgejo webhook → Argo for instant syncs instead of 3 min polling.
|
||||
|
|
|
|||
26
apps/whoami/deployment.yaml
Normal file
26
apps/whoami/deployment.yaml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: whoami
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: whoami
|
||||
spec:
|
||||
containers:
|
||||
- name: whoami
|
||||
image: traefik/whoami:v1.11.0
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
resources:
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 16Mi
|
||||
limits:
|
||||
memory: 32Mi
|
||||
20
apps/whoami/ingress.yaml
Normal file
20
apps/whoami/ingress.yaml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Public only once a matching vhost exists in Caddy (LXC 100) pointing at
|
||||
# Traefik on 10.0.0.141-143:80. Test before that, over WireGuard:
|
||||
# curl -H 'Host: whoami.un-oeil.fr' http://10.0.0.141
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: whoami.un-oeil.fr
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: whoami
|
||||
port:
|
||||
name: http
|
||||
7
apps/whoami/kustomization.yaml
Normal file
7
apps/whoami/kustomization.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Example app: copy this folder to start a new one.
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- ingress.yaml
|
||||
11
apps/whoami/service.yaml
Normal file
11
apps/whoami/service.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: whoami
|
||||
spec:
|
||||
selector:
|
||||
app: whoami
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: http
|
||||
8
argocd/argocd-cm.yaml
Normal file
8
argocd/argocd-cm.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: argocd-cm
|
||||
data:
|
||||
url: http://argocd.un-oeil.fr
|
||||
# Lets an app's kustomization.yaml pull Helm charts via `helmCharts:`.
|
||||
kustomize.buildOptions: --enable-helm
|
||||
8
argocd/argocd-cmd-params-cm.yaml
Normal file
8
argocd/argocd-cmd-params-cm.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# TLS is terminated in front of Argo CD (Traefik over WireGuard, or port-forward),
|
||||
# so the API server serves plain HTTP.
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: argocd-cmd-params-cm
|
||||
data:
|
||||
server.insecure: "true"
|
||||
19
argocd/ingress.yaml
Normal file
19
argocd/ingress.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Admin-only: do NOT add this host to Caddy. Reach it over WireGuard with
|
||||
# `10.0.0.141 argocd.un-oeil.fr` in the laptop's /etc/hosts.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: argocd-server
|
||||
spec:
|
||||
ingressClassName: traefik
|
||||
rules:
|
||||
- host: argocd.un-oeil.fr
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: argocd-server
|
||||
port:
|
||||
name: http
|
||||
13
argocd/kustomization.yaml
Normal file
13
argocd/kustomization.yaml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Argo CD itself. Used once by hand for the bootstrap (see README), then
|
||||
# Argo CD manages its own install from here (cluster/argocd.yaml).
|
||||
# Upgrade: bump the version in the URL below and push.
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: argocd
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- https://raw.githubusercontent.com/argoproj/argo-cd/v3.5.4/manifests/install.yaml
|
||||
- ingress.yaml
|
||||
patches:
|
||||
- path: argocd-cmd-params-cm.yaml
|
||||
- path: argocd-cm.yaml
|
||||
4
argocd/namespace.yaml
Normal file
4
argocd/namespace.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: argocd
|
||||
19
bootstrap/root.yaml
Normal file
19
bootstrap/root.yaml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# The only manifest applied by hand. Everything else is reached from cluster/.
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: root
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: http://10.0.0.14:3000/un-oeil/argocd.git
|
||||
targetRevision: main
|
||||
path: cluster
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: argocd
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
35
cluster/apps.yaml
Normal file
35
cluster/apps.yaml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# One Argo CD Application per folder in apps/, deployed to a namespace of the
|
||||
# same name. Argo detects the folder type: Chart.yaml -> Helm,
|
||||
# kustomization.yaml -> Kustomize, otherwise plain manifests.
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: ApplicationSet
|
||||
metadata:
|
||||
name: apps
|
||||
namespace: argocd
|
||||
spec:
|
||||
goTemplate: true
|
||||
goTemplateOptions: ["missingkey=error"]
|
||||
generators:
|
||||
- git:
|
||||
repoURL: http://10.0.0.14:3000/un-oeil/argocd.git
|
||||
revision: main
|
||||
directories:
|
||||
- path: apps/*
|
||||
template:
|
||||
metadata:
|
||||
name: "{{.path.basename}}"
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: http://10.0.0.14:3000/un-oeil/argocd.git
|
||||
targetRevision: main
|
||||
path: "{{.path.path}}"
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: "{{.path.basename}}"
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
23
cluster/argocd.yaml
Normal file
23
cluster/argocd.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Argo CD manages its own install (argocd/).
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: argocd
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: http://10.0.0.14:3000/un-oeil/argocd.git
|
||||
targetRevision: main
|
||||
path: argocd
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: argocd
|
||||
syncPolicy:
|
||||
automated:
|
||||
# No prune: a bad commit here must not be able to delete Argo CD itself.
|
||||
prune: false
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
# The Argo CD CRDs are too big for client-side apply annotations.
|
||||
- ServerSideApply=true
|
||||
Loading…
Add table
Reference in a new issue