create argocd apps declaratively

This commit is contained in:
Roger Oriol
2026-06-23 01:03:06 +02:00
parent 01321bf50c
commit f6562df066
23 changed files with 707 additions and 1 deletions

24
argocd/apps/argocd.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: argocd
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: argocd
directory:
recurse: false
destination:
server: https://kubernetes.default.svc
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: cert-manager
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: cert-manager
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: cert-manager
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/fava.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: fava
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: fava
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: fava
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/gitea.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gitea
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: gitea
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: gitea
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/glance.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: glance
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: glance
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: glance
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: gym-tracker
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: gym-tracker
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: gym-tracker
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: homeassistant
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: homeassistant
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: home-assistant
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/jellyfin.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: jellyfin
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: jellyfin
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: jellyfin
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/litellm.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: litellm
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: litellm
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: litellm
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: minecraft-server
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: minecraft-server
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: minecraft
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: monitoring
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: monitoring
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: monitoring
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myorg-assistant
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: myorg-assistant
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: myorg-assistant
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/n8n.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: n8n
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: n8n
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: n8n
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

24
argocd/apps/nas.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: nas
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: nas
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: nas-proxy
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: openwebui
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: openwebui
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: openwebui
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

25
argocd/apps/phoenix.yaml Normal file
View File

@@ -0,0 +1,25 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: phoenix
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: phoenix
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: phoenix
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false
- Validate=false

24
argocd/apps/pihole.yaml Normal file
View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: pihole
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: pihole
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: pihole
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

17
argocd/apps/project.yaml Normal file
View File

@@ -0,0 +1,17 @@
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: k3s-cluster
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "-1"
spec:
description: Applications for the rogi.casa K3s cluster (managed in Git)
sourceRepos:
- https://git.rogi.casa/roger/k3s-cluster.git
destinations:
- server: https://kubernetes.default.svc
namespace: "*"
clusterResourceWhitelist:
- group: "*"
kind: "*"

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: qbittorrent
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: qbittorrent
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: qbittorrent
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

View File

@@ -0,0 +1,24 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: vaultwarden
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: https://git.rogi.casa/roger/k3s-cluster.git
targetRevision: main
path: vaultwarden
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: vaultwarden
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false

140
argocd/gen-apps.sh Executable file
View File

@@ -0,0 +1,140 @@
#!/usr/bin/env bash
# Generates ArgoCD Application manifests (one per app folder) + an AppProject.
#
# Layout produced:
# argocd/apps/project.yaml -> AppProject "k3s-cluster" (sync-wave -1)
# argocd/apps/<app>.yaml -> Application for that app folder
# argocd-bootstrap.yaml (repo root) -> app-of-apps: syncs everything in argocd/apps/
#
# Bootstrap (one-time, after ArgoCD + cert-manager are installed):
# kubectl apply -f argocd-bootstrap.yaml
#
# Re-run this script after adding/removing an app folder to regenerate the manifests.
set -euo pipefail
cd "$(dirname "$0")/.." # repo root
REPO="${REPO:-https://git.rogi.casa/roger/k3s-cluster.git}"
REV="${REV:-main}"
APPS_DIR="argocd/apps"
mkdir -p "$APPS_DIR"
# app-name | namespace | path | recurse | validate
APPS=(
"argocd|argocd|argocd|false|true"
"cert-manager|cert-manager|cert-manager|true|true"
"fava|fava|fava|true|true"
"gitea|gitea|gitea|true|true"
"glance|glance|glance|true|true"
"gym-tracker|gym-tracker|gym-tracker|true|true"
"homeassistant|home-assistant|homeassistant|true|true"
"jellyfin|jellyfin|jellyfin|true|true"
"litellm|litellm|litellm|true|true"
"minecraft-server|minecraft|minecraft-server|true|true"
"monitoring|monitoring|monitoring|true|true"
"myorg-assistant|myorg-assistant|myorg-assistant|true|true"
"n8n|n8n|n8n|true|true"
"nas|nas-proxy|nas|true|true"
"openwebui|openwebui|openwebui|true|true"
"phoenix|phoenix|phoenix|true|false"
"pihole|pihole|pihole|true|true"
"qbittorrent|qbittorrent|qbittorrent|true|true"
"vaultwarden|vaultwarden|vaultwarden|true|true"
)
# ---------------------------------------------------------------------------
# AppProject
# ---------------------------------------------------------------------------
cat > "$APPS_DIR/project.yaml" <<EOF
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: k3s-cluster
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "-1"
spec:
description: Applications for the rogi.casa K3s cluster (managed in Git)
sourceRepos:
- ${REPO}
destinations:
- server: https://kubernetes.default.svc
namespace: "*"
clusterResourceWhitelist:
- group: "*"
kind: "*"
EOF
# ---------------------------------------------------------------------------
# One Application per app folder
# ---------------------------------------------------------------------------
gen_app() {
local name="$1" ns="$2" path="$3" recurse="$4" validate="$5"
local recurse_yaml validate_opts=""
[ "$recurse" = "true" ] && recurse_yaml=" recurse: true" || recurse_yaml=" recurse: false"
[ "$validate" = "false" ] && validate_opts=$'\n - Validate=false'
cat > "$APPS_DIR/${name}.yaml" <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: ${name}
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
spec:
project: k3s-cluster
source:
repoURL: ${REPO}
targetRevision: ${REV}
path: ${path}
directory:
${recurse_yaml}
destination:
server: https://kubernetes.default.svc
namespace: ${ns}
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false${validate_opts}
EOF
}
for line in "${APPS[@]}"; do
IFS='|' read -r name ns path recurse validate <<< "$line"
gen_app "$name" "$ns" "$path" "$recurse" "$validate"
done
# ---------------------------------------------------------------------------
# Root "app-of-apps" bootstrap Application (uses the built-in default project)
# ---------------------------------------------------------------------------
cat > argocd-bootstrap.yaml <<EOF
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: k3s-cluster-root
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "-1"
spec:
project: default
source:
repoURL: ${REPO}
targetRevision: ${REV}
path: argocd/apps
directory:
recurse: true
destination:
server: https://kubernetes.default.svc
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=false
EOF
echo "Generated $(find "$APPS_DIR" -name '*.yaml' | wc -l) files in $APPS_DIR/ and argocd-bootstrap.yaml"