initial push
This commit is contained in:
38
README.md
Normal file
38
README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# k3s-manifests
|
||||||
|
|
||||||
|
Desired-state repo for the k3s cluster. **ArgoCD watches this repo and makes the
|
||||||
|
cluster match it.** You deploy by committing here; you roll back with `git revert`.
|
||||||
|
Do not `kubectl apply` these by hand — let ArgoCD own them.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
apps/ # app-of-apps: one ArgoCD Application per service/env
|
||||||
|
gitops-demo.yaml # -> points at gitops-demo/dev
|
||||||
|
gitops-demo/ # a service
|
||||||
|
dev/ # its dev environment (plain k8s YAML)
|
||||||
|
deployment.yaml
|
||||||
|
service.yaml
|
||||||
|
ingress.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Environment is a folder (`dev`, later `prod`). The manifests are **plain YAML on
|
||||||
|
purpose** for now — Phase 4 replaces the per-env duplication with a generic Helm
|
||||||
|
chart. One new concept per phase.
|
||||||
|
|
||||||
|
## One-time setup when you first push this
|
||||||
|
|
||||||
|
The child Application in `apps/gitops-demo.yaml` has a placeholder repo URL.
|
||||||
|
Replace it with this repo's real HTTPS URL before (or right after) the first push:
|
||||||
|
|
||||||
|
```
|
||||||
|
# from the repo root, replace the placeholder in every apps/*.yaml:
|
||||||
|
sed -i 's#REPLACE_WITH_MANIFEST_REPO_URL#https://gitea.lgkentang.com/you/k3s-manifests.git#' apps/*.yaml
|
||||||
|
git add -A && git commit -m "point apps at real repo url" && git push
|
||||||
|
```
|
||||||
|
|
||||||
|
## Onboarding a new service later
|
||||||
|
|
||||||
|
1. Add `myservice/dev/` manifests (deployment, service, ingress).
|
||||||
|
2. Add `apps/myservice.yaml` (copy `gitops-demo.yaml`, change name + path).
|
||||||
|
3. Commit + push. ArgoCD's root app picks it up — no cluster access needed.
|
||||||
27
apps/gitops-demo.yaml
Normal file
27
apps/gitops-demo.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# A child Application in the app-of-apps tree. ArgoCD's root app finds this file
|
||||||
|
# and creates this Application, which in turn syncs gitops-demo/dev into the
|
||||||
|
# cluster. To add another service, copy this file and change name + path.
|
||||||
|
#
|
||||||
|
# NOTE: replace REPLACE_WITH_MANIFEST_REPO_URL with this repo's real HTTPS URL
|
||||||
|
# (see README) — child Applications can't be templated by our shell scripts
|
||||||
|
# because ArgoCD reads them straight from git.
|
||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: gitops-demo-dev
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
repoURL: https://gitea.lgkentang.com/you/k3s-manifests.git
|
||||||
|
targetRevision: HEAD
|
||||||
|
path: gitops-demo/dev
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: dev # per-environment namespace convention
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
23
gitops-demo/dev/deployment.yaml
Normal file
23
gitops-demo/dev/deployment.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Plain Deployment — note there is NO `namespace:` here. ArgoCD places it in the
|
||||||
|
# namespace named by the Application's destination (dev). Leaving it out keeps
|
||||||
|
# these manifests reusable for prod later (a prod Application would drop the
|
||||||
|
# same files into the prd namespace).
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: gitops-demo
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: gitops-demo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: gitops-demo
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: whoami
|
||||||
|
image: traefik/whoami:latest
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
27
gitops-demo/dev/ingress.yaml
Normal file
27
gitops-demo/dev/ingress.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Same Ingress shape as Phases 1-2, now delivered via GitOps. When ArgoCD syncs
|
||||||
|
# this, the full platform reacts: cert-manager issues the cert, external-dns
|
||||||
|
# creates the A record, Traefik routes it. A brand-new host proves the whole
|
||||||
|
# chain end-to-end from a single git commit.
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: gitops-demo
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||||
|
spec:
|
||||||
|
ingressClassName: traefik
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- gitops-demo.dev.lgkentang.com
|
||||||
|
secretName: gitops-demo-tls
|
||||||
|
rules:
|
||||||
|
- host: gitops-demo.dev.lgkentang.com
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: gitops-demo
|
||||||
|
port:
|
||||||
|
number: 80
|
||||||
10
gitops-demo/dev/service.yaml
Normal file
10
gitops-demo/dev/service.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: gitops-demo
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: gitops-demo
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
targetPort: 80
|
||||||
Reference in New Issue
Block a user