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

ObjectPurpose
PodSmallest deployable unit; one or more containers sharing network/storage
DeploymentManages replicated Pods, rolling updates, rollbacks
ServiceStable network endpoint (ClusterIP, NodePort, LoadBalancer)
ConfigMap / SecretExternalise configuration and sensitive values
NamespaceVirtual cluster for resource isolation
IngressHTTP/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


References

  • AWS EKS certification notes