GitOps scaffold: Argo CD bootstrap, app-of-apps, example workload
This commit is contained in:
parent
3b609b3077
commit
7cc6824e01
6 changed files with 112 additions and 3 deletions
20
README.md
20
README.md
|
|
@ -1,3 +1,17 @@
|
|||
# gitops-apps
|
||||
|
||||
Argo CD Application manifests for cluster redeploy
|
||||
# GitOps scaffold for Rancher-managed Kubernetes
|
||||
#
|
||||
# Flow: Developers/CI -> Forgejo -> Argo CD -> Rancher-managed clusters.
|
||||
# Kubernetes itself is NOT the backup. This repo (in Forgejo, backed up
|
||||
# by /root/forgejo/backup.sh) plus container images are the source of truth.
|
||||
#
|
||||
# Layout:
|
||||
# bootstrap/ one-time Argo CD install + root App-of-Apps
|
||||
# apps/ one Argo CD Application per workload
|
||||
# clusters/ per-cluster config (registered Rancher clusters)
|
||||
#
|
||||
# Usage on a NEW cluster:
|
||||
# 1. kubectl apply -f bootstrap/argocd-namespace.yaml
|
||||
# 2. kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
||||
# 3. kubectl apply -f bootstrap/repo-forgejo.yaml # registers THIS Forgejo repo
|
||||
# 4. kubectl apply -f bootstrap/root-app.yaml # app-of-apps -> redeploys everything
|
||||
# 5. (Rancher) cluster auto-registers; workloads converge from Git.
|
||||
|
|
|
|||
22
apps/example-app.yaml
Normal file
22
apps/example-app.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Example workload Application. Copy per app; point `path` (or chart) at
|
||||
# your app manifests (also stored in Forgejo). Replace repoURL/server.
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: example-app
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: http://localhost:3000/forgejoadmin/gitops-apps.git
|
||||
targetRevision: main
|
||||
path: clusters/default/example-app
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: example-app
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
4
bootstrap/argocd-namespace.yaml
Normal file
4
bootstrap/argocd-namespace.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: argocd
|
||||
15
bootstrap/repo-forgejo.yaml
Normal file
15
bootstrap/repo-forgejo.yaml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Registers the Forgejo repo with Argo CD.
|
||||
# For SSH access, create a secret with the deploy key instead:
|
||||
# kubectl -n argocd create secret generic forgejo-repo-creds \
|
||||
# --from-file=sshPrivateKey=/path/to/deploy_key
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: repo-forgejo-gitops
|
||||
namespace: argocd
|
||||
labels:
|
||||
argocd.argoproj.io/secret-type: repository
|
||||
stringData:
|
||||
type: git
|
||||
url: http://localhost:3000/forgejoadmin/gitops-apps.git
|
||||
# username/password or sshPrivateKey go here when the repo is private
|
||||
22
bootstrap/root-app.yaml
Normal file
22
bootstrap/root-app.yaml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# App-of-Apps: applying this one Application redeploys every workload
|
||||
# defined under apps/ onto the target cluster.
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: root-app
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: http://localhost:3000/forgejoadmin/gitops-apps.git
|
||||
targetRevision: main
|
||||
path: apps
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: argocd
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
32
clusters/default/example-app/deployment.yaml
Normal file
32
clusters/default/example-app/deployment.yaml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: example-app
|
||||
namespace: example-app
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: example-app
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: example-app
|
||||
spec:
|
||||
containers:
|
||||
- name: app
|
||||
image: nginx:1.27-alpine
|
||||
ports:
|
||||
- containerPort: 80
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: example-app
|
||||
namespace: example-app
|
||||
spec:
|
||||
selector:
|
||||
app: example-app
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
Loading…
Add table
Add a link
Reference in a new issue