Simple definition#
“Running Kubernetes” covers day 1 (creating clusters and deploying apps) and day 2 (upgrading, scaling, securing, backing up and operating them for years). Most of the cost and risk of Kubernetes is in day 2.
A minimal application#
apiVersion: apps/v1
kind: Deployment
metadata: { name: orders, namespace: shop, labels: { app: orders } }
spec:
replicas: 3
selector: { matchLabels: { app: orders } }
template:
metadata: { labels: { app: orders } }
spec:
containers:
- name: orders
image: ghcr.io/acme/orders@sha256:3f1c... # deploy by digest
ports: [{ containerPort: 8080 }]
resources:
requests: { cpu: 250m, memory: 512Mi }
limits: { memory: 512Mi }
readinessProbe: { httpGet: { path: /actuator/health/readiness, port: 8080 } }
livenessProbe: { httpGet: { path: /actuator/health/liveness, port: 8080 } }
---
apiVersion: v1
kind: Service
metadata: { name: orders, namespace: shop }
spec:
selector: { app: orders }
ports: [{ port: 80, targetPort: 8080 }]
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata: { name: orders, namespace: shop }
spec:
parentRefs: [{ name: public, namespace: gateway }]
hostnames: ["shop.example.com"]
rules:
- matches: [{ path: { type: PathPrefix, value: /orders } }]
backendRefs: [{ name: orders, port: 80 }]
kubectl essentials#
| Task | Command |
|---|---|
| Apply desired state | kubectl apply -f k8s/ (or server-side: --server-side) |
| See what changes | kubectl diff -f k8s/ |
| Inspect | kubectl get pods -n shop -o wide, kubectl describe pod <p> |
| Logs | kubectl logs deploy/orders -f --since=10m |
| Debug | kubectl debug -it <pod> --image=busybox --target=orders (ephemeral container) |
| Rollout | kubectl rollout status deploy/orders, kubectl rollout undo deploy/orders |
| Events | kubectl events -n shop --types=Warning |
| Permissions | kubectl auth can-i create deployments -n shop --as=jane |
In production, humans should rarely apply by hand — use GitOps.
Managing configuration: Kustomize vs Helm#
flowchart TB
B["base/<br/>deployment, service, route"] --> D["overlays/dev<br/>1 replica, dev image"]
B --> S["overlays/staging<br/>2 replicas"]
B --> P["overlays/prod<br/>3 replicas, HPA, PDB"]
| Kustomize | Helm | |
|---|---|---|
| Approach | Patch plain YAML (overlays) | Templates + values |
| Packaging/distribution | No | Charts in OCI registries, versioned |
| Best for | Your own apps, environment differences | Reusable, distributable packages; third-party software |
| Built into kubectl | Yes (kubectl apply -k) |
No |
Many teams combine them: Helm for third-party charts, Kustomize for internal apps — both rendered by Argo CD or Flux. See Helm.
Operators#
Operators run complex software on Kubernetes by encoding operational knowledge in a controller:
flowchart LR
CR["Custom resource<br/>PostgresCluster: 3 instances, v16, backups daily"] --> OP["Operator controller"]
OP --> K["StatefulSets, Services,<br/>Secrets, backups, failover"]
K -->|"status"| CR
Use mature operators for databases (CloudNativePG, Crunchy), Kafka (Strimzi), certificates (cert-manager), monitoring (Prometheus Operator). Assess maturity (capability levels: install → upgrade → lifecycle → insights → autopilot) before trusting critical data to one.
Managed or self-managed?#
| Option | Examples | Fit |
|---|---|---|
| Managed Kubernetes | Amazon EKS, Azure AKS, Google GKE (incl. Autopilot) | Default for cloud workloads |
| Enterprise distributions | Red Hat OpenShift, SUSE Rancher, VMware VKS | Hybrid/on-premises, integrated platform, vendor support |
| Lightweight | k3s, k0s, Talos | Edge, labs, small footprints |
| DIY (kubeadm) | — | Rarely justified; maximum effort |
How many clusters?#
| Pattern | Pros | Cons |
|---|---|---|
| Few large shared clusters | Efficient, fewer upgrades | Larger blast radius; noisy neighbours; complex tenancy |
| Cluster per environment (dev/test/prod) | Clear separation | Still shared between teams |
| Cluster per team or app | Strong isolation, autonomy | Many clusters to upgrade and secure |
| Cluster per region/zone group | Resilience, data residency | Needs fleet management |
Most enterprises land on per-environment and per-region clusters shared by teams, with dedicated clusters for regulated or special workloads — managed as a fleet.
Fleet management and lifecycle#
- Cluster API — Kubernetes-style declarative management of clusters themselves (create, upgrade, scale) across clouds.
- GitOps across the fleet — Argo CD ApplicationSets or Flux with cluster labels to roll out add-ons consistently.
- Upgrades — one minor version at a time; test add-ons; use surge node pools or blue/green node pools; respect PodDisruptionBudgets.
- Backup and restore — Velero (objects + volume snapshots); etcd snapshots for self-managed control planes; rebuild from Git for stateless config.
- Capacity — node pools by workload type (general, memory, GPU, spot); autoscaling (Karpenter / Cluster Autoscaler).
Common mistakes#
Quick check#
Kustomize or Helm? Kustomize for patching your own YAML per environment; Helm for packaging and distributing reusable, versioned charts — often both, rendered by GitOps.
What is an operator? A controller plus CRDs that automates the lifecycle of complex software, such as a database’s provisioning, upgrades, backups and failover.
Why prefer managed Kubernetes? The provider operates the control plane, etcd and upgrades, reducing operational risk and effort.
How do you back up a cluster? Keep configuration in Git, use Velero for objects and volume snapshots, back up etcd for self-managed control planes, and regularly test restores.
What is Cluster API? A Kubernetes project that manages the lifecycle of clusters declaratively, using Kubernetes resources and controllers.
Summary#
- Deploy declaratively; kubectl is for inspection and debugging, Git for change.
- Kustomize for overlays, Helm for packages; operators for complex software.
- Prefer managed Kubernetes; choose cluster topology by isolation vs efficiency.
- Treat clusters as a fleet: reproducible, upgraded regularly, backed up and tested.
References#
- Kubernetes documentation, kubectl reference and Kustomize.
- Operator pattern and OperatorHub capability levels.
- Cluster API, Velero.