Introduction
Deploy a production Kubernetes cluster using kubeadm, configure persistent storage, ingress, monitoring, and GitOps with ArgoCD. This comprehensive guide covers everything from design through implementation, testing, and deployment.
Deploy a production Kubernetes cluster using kubeadm, configure persistent storage, ingress, monitoring, and GitOps with ArgoCD.
Deploy a production Kubernetes cluster using kubeadm, configure persistent storage, ingress, monitoring, and GitOps with ArgoCD. This comprehensive guide covers everything from design through implementation, testing, and deployment.
Control Plane (master): API Server (central REST API for all K8s operations), etcd (distributed key-value store for all cluster state), Scheduler (assigns pods to nodes), Controller Manager (enforces desired state). Worker Nodes: kubelet (ensures containers run as specified), kube-proxy (implements network rules for Services), Container Runtime (containerd or CRI-O). Minimum for production: 3 control plane nodes (HA) + 3+ worker nodes. For learning: 1 master + 2 workers.
10 components required for this project.
| # | Component | Purpose | Qty |
|---|---|---|---|
| 1 | Ubuntu 22.04 VMs (3–5 nodes) | 1 master + 2–4 worker nodes | x3–5 |
| 2 | kubeadm | Kubernetes cluster bootstrap tool | x1 |
| 3 | Flannel or Calico CNI | Pod networking (Container Network Interface) | x1 |
| 4 | MetalLB | LoadBalancer for bare-metal Kubernetes | x1 |
| 5 | NGINX Ingress Controller | HTTP/HTTPS routing to services | x1 |
| 6 | cert-manager | Automatic TLS certificate provisioning | x1 |
| 7 | Helm 3 | Kubernetes application packaging | x1 |
| 8 | ArgoCD | GitOps continuous deployment | x1 |
| 9 | Prometheus + Grafana Stack | Cluster monitoring and alerting | x1 |
| 10 | Longhorn (storage) | Distributed block storage for PersistentVolumes | x1 |
Follow these 6 steps carefully.
Control Plane (master): API Server (central REST API for all K8s operations), etcd (distributed key-value store for all cluster state), Scheduler (assigns pods to nodes), Controller Manager (enforces desired state). Worker Nodes: kubelet (ensures containers run as specified), kube-proxy (implements network rules for Services), Container Runtime (containerd or CRI-O). Minimum for production: 3 control plane nodes (HA) + 3+ worker nodes. For learning: 1 master + 2 workers.
On all nodes: disable swap (Kubernetes requirement), install containerd runtime, install kubeadm/kubelet/kubectl. On master: kubeadm init --pod-network-cidr=10.244.0.0/16 (for Flannel). Copy kubeconfig: mkdir ~/.kube && cp /etc/kubernetes/admin.conf ~/.kube/config. Install CNI: kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml. On workers: kubeadm join master_ip:6443 --token TOKEN --discovery-token-ca-cert-hash HASH (from master init output).
Longhorn provides distributed block storage: each PersistentVolume is replicated across 3 worker nodes. Install via Helm: helm install longhorn longhorn/longhorn --namespace longhorn-system. Create StorageClass (set as default): class.longhorn.io. Create PVC (PersistentVolumeClaim) of 10Gi. Longhorn automatically provisions the PV, replicates data. Access mode: ReadWriteOnce (one pod) or ReadWriteMany (multiple pods simultaneously). Monitor via Longhorn UI.
MetalLB provides LoadBalancer IPs in bare-metal environments (cloud K8s handles this automatically). Configure L2 mode with IP range from your LAN. Install NGINX Ingress Controller: helm install ingress-nginx ingress-nginx/ingress-nginx. Install cert-manager for automatic TLS: helm install cert-manager cert-manager/cert-manager --set installCRDs=true. Create ClusterIssuer using Let's Encrypt. Create Ingress resource: routes catb.in → catb-service:80, with TLS annotation for automatic certificate.
GitOps: Kubernetes manifests stored in Git. ArgoCD watches Git repo, syncs cluster state to match Git. Install ArgoCD: kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml. Create Application resource: sourcePath=k8s/, destinationNamespace=production. On every Git push (via CI/CD): ArgoCD detects change, auto-syncs new manifests to cluster. Audit trail: all changes tracked in Git history with author, timestamp, and diff.
Install kube-prometheus-stack: helm install monitoring prometheus-community/kube-prometheus-stack. Includes: Prometheus (metrics), Grafana (dashboards), AlertManager (notifications), node-exporter (hardware metrics), kube-state-metrics (K8s object metrics). Access Grafana: kubectl port-forward svc/monitoring-grafana 3000:80. Pre-built dashboards: cluster capacity, pod restart rates, network traffic, storage usage, API server request rate. Configure PagerDuty/Slack alerts for critical events.
Core code for deployment.yaml:
# Example CATB.in application deployment apiVersion: apps/v1 kind: Deployment metadata: name: catb-web namespace: production spec: replicas: 3 selector: matchLabels: {app: catb-web} template: metadata: labels: {app: catb-web} spec: containers: - name: catb-web image: registry.catb.in/catb-web:v1.2.3 ports: [{containerPort: 3000}] resources: requests: {cpu: "100m", memory: "128Mi"} limits: {cpu: "500m", memory: "512Mi"} readinessProbe: httpGet: {path: /health, port: 3000} initialDelaySeconds: 10 periodSeconds: 5 livenessProbe: httpGet: {path: /health, port: 3000} initialDelaySeconds: 30 periodSeconds: 10 --- apiVersion: v1 kind: Service metadata: name: catb-service namespace: production spec: selector: {app: catb-web} ports: [{port: 80, targetPort: 3000}] --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: catb-ingress namespace: production annotations: cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/ssl-redirect: "true" spec: tls: - hosts: [catb.in] secretName: catb-tls rules: - host: catb.in http: paths: - path: / pathType: Prefix backend: service: {name: catb-service, port: {number: 80}}
Test Docker and Kubernetes Cluster Setup by verifying each subsystem individually before full integration.
Verify power voltages, check ground connections, use serial monitor for debug.
An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.