(01)Install Flux CD
1curl -s https://fluxcd.io/install.sh | sudo bash2flux check --pre3flux installGitOps toolkit — sync Kubernetes from Git repos
If you're on Kubernetes 1.27 or older
If you're on Kubernetes 1.28
What is this?
Flux CD keeps your Kubernetes cluster in sync with config files stored in Git.
Where to create or edit the main configuration — paths below match the setup steps.
clusters/<env>/Location: Git repo — Flux bootstrap path
Kustomization and HelmRelease manifests
Step 01
1curl -s https://fluxcd.io/install.sh | sudo bash2flux check --pre3flux installStep 02
1flux create source git myapp --url=https://github.com/user/repo --branch=main2flux create kustomization myapp --source=myapp --path=./k8s --prune=trueStep 03
1flux get all2 YAML templates for Flux CD. Copy and deploy after setup.
2 ready-to-copy templates. Expand one, copy the YAML, then run the deploy commands.
deployment.yml
Deployment with resource requests/limits and local image
1apiVersion: apps/v12kind: Deployment3metadata:4 labels:5 app: api-deploy6 name: api-deploy7spec:8 replicas: 19 selector:10 matchLabels:11 app: api-deploy12 template:13 metadata:14 labels:15 app: api-deploy16 spec:17 containers:18 - image: api:local19 name: api20 imagePullPolicy: IfNotPresent21 ports:22 - containerPort: 300023 resources:24 limits:25 memory: "512Mi"26 cpu: "500m"27 requests:28 memory: "256Mi"29 cpu: "250m"services.yml
NodePort Service exposing the API on port 32000
1apiVersion: v12kind: Service3metadata:4 labels:5 app: api-deploy6 name: api-deploy-service7spec:8 type: NodePort9 selector:10 app: api-deploy11 ports:12 - port: 300013 protocol: TCP14 targetPort: 300015 nodePort: 32000Step 01
1# Build local image2docker build -t api:local .3 4# For Minikube / Kind — load image into cluster5minikube image load api:local6# OR: kind load docker-image api:local1kubectl apply -f deployment.yml2kubectl apply -f services.yml3kubectl get pods,svc4curl http://localhost:32000 # or minikube service api-deploy-service