Kubernetes
Definition
Kubernetes (K8s) is an open-source platform for automating the deployment, scaling, and operations of containerised workloads. It abstracts the underlying infrastructure and schedules containers across a cluster of nodes based on declared intent.
Core Ideas
Fundamental Objects
| Object | Purpose |
|---|---|
| Pod | Smallest deployable unit; one or more containers sharing network/storage |
| Deployment | Manages replicated Pods, rolling updates, rollbacks |
| Service | Stable network endpoint (ClusterIP, NodePort, LoadBalancer) |
| ConfigMap / Secret | Externalise configuration and sensitive values |
| Namespace | Virtual cluster for resource isolation |
| Ingress | HTTP/HTTPS routing to Services from outside the cluster |
Workload Types
- Deployment — stateless apps (web servers, APIs)
- StatefulSet — stateful apps with stable identity (databases, Kafka)
- DaemonSet — one pod per node (logging agents, monitoring)
- Job / CronJob — batch or scheduled tasks
Scheduling & Resource Management
- Node selectors, affinity/anti-affinity rules
- Resource requests (guaranteed) vs limits (cap)
- Horizontal Pod Autoscaler (HPA) — scale based on CPU/custom metrics
- Cluster Autoscaler — add/remove nodes based on pending pods
Networking
- CNI plugins: Calico, Flannel, Cilium
- Services: ClusterIP (internal), NodePort (node-level), LoadBalancer (cloud LB)
- Ingress controllers: NGINX, Traefik, AWS ALB Ingress
- Service mesh: Istio, Linkerd (mTLS, traffic management, observability)
Storage
- PersistentVolume (PV) + PersistentVolumeClaim (PVC)
- StorageClasses for dynamic provisioning
- CSI drivers for cloud storage (EBS, EFS, GCP PD)
Managed Kubernetes
- EKS (AWS Elastic Kubernetes Service) — primary managed offering in source notes
- GKE (Google), AKS (Azure)
- EKS Fargate — serverless node pools (no EC2 management)
Helm
- Package manager for Kubernetes
- Charts = templated Kubernetes manifests
- Values files for environment-specific configuration
- Helm repositories and OCI chart registries
CronJobs and Scheduled Workloads
For recurring jobs (e.g. hourly data sync), concurrencyPolicy: Forbid prevents overlapping runs: if a run outlasts its interval, Kubernetes skips the next scheduled job rather than double-running or racing. Worst case is a missed tick, not corrupted or duplicated data. (Note: manually creating an ad-hoc job with kubectl create job --from=cronjob bypasses Forbid and can cause conflicts — that’s a testing artifact, not something the schedule does to itself.) Pair this with a diff-and-skip design so each run only writes records that actually changed, keeping steady-state runs fast.
Relationships
- Microservices — Kubernetes is the primary runtime for microservice architectures
- Cloud & AWS Infrastructure — EKS is the managed K8s offering in AWS
- AI & Machine Learning — ML model serving on Kubernetes (Kubeflow, Triton)
- Self-Hosted Infrastructure — splitting one cluster across public and private subnets with node labels and
nodeSelector
References
- AWS EKS certification notes