Kubernetes is built around a small set of composable resource types. Understanding how they fit together is the difference between βrunning random YAML filesβ and actually designing systems. This lesson is a tour, organized by what each resource is for.
Cluster, Node, Namespace
π’
Cluster
The whole Kubernetes installation. One control plane, many worker nodes.
π»
Node
A machine (VM or physical). Runs kubelet, kube-proxy, container runtime. Can host many pods.
π·οΈ
Namespace
Virtual cluster within a cluster. Isolation boundary for resources, RBAC, network policies.
Most resources are namespaced β they live inside a namespace. A few are cluster-scoped (Nodes, ClusterRoles, PersistentVolumes, StorageClasses).
Workload Resources
The βwhat is runningβ layer.
π¦
Pod
One or more co-located containers with shared network and storage. Smallest unit. Usually managed by higher-level resources, not created directly.
π―
Deployment
For stateless services. Manages a ReplicaSet. Rolling updates, rollback, scaling. Default workload type for most services.
π
ReplicaSet
Maintains N replicas of a Pod. Usually created by Deployment, not directly.
πΎ
StatefulSet
For stateful workloads (databases, brokers). Stable identity, ordered deployment, persistent volume per pod.
π€
DaemonSet
One pod per node (or matching node selector). For log collectors, monitoring agents, CSI drivers, network plugins.
β°
Job / CronJob
Run-to-completion workloads. Job for one-off; CronJob for scheduled (cron syntax).
Choosing the right workload type
Deployment
Stateless, swappable
Web servers, API services, workers without local state. Can scale freely; pods are interchangeable.
StatefulSet
Stateful, identity-bound
Databases, brokers, anything where pod identity or ordering matters. Pod gets a stable hostname, stable storage. Ordered scaling.
Four ways a Job runs
CronJob only creates a Job on the schedule. Concurrency is a field on the Job, not a different resource kind.
Pattern
Controller behavior
Sequential
One pod at a time until the completion count is met. Use it when the steps are ordered, or when you cannot afford concurrent pods.
Parallel
At most parallelism pods at once. Three means up to three pods share the work.
Work queue
Pods pull from a shared queue until it is empty. The Job does not know the task count ahead of time.
Indexed
Each pod gets JOB_COMPLETION_INDEX, starting at 0. One pod handles one shard of a migration or one slice of a training set.
HPA changes the replica count on the Deployment or StatefulSet. VPA changes requests through that same controller. Neither one edits pod objects directly.
Service and Networking
Pods are ephemeral; their IPs change. Services provide stable endpoints.
π
Service
Virtual IP and DNS name targeting a set of Pods (selected by label). Types: ClusterIP, NodePort, LoadBalancer, ExternalName.
π·οΈ
Endpoints / EndpointSlice
The actual list of Pod IPs backing a Service. Updated by the endpoints controller. EndpointSlice is the modern, scalable form.
π
Ingress
HTTP/HTTPS L7 routing β path-based, host-based, TLS termination. Backed by an Ingress controller (nginx, Traefik, AWS ALB, etc.).
πͺ
Gateway API
Modern replacement for Ingress. More expressive, role-oriented (Gateway, HTTPRoute, GRPCRoute). Will eventually replace Ingress in most clusters.
π‘οΈ
NetworkPolicy
Firewall rules between pods. Restricts pod-to-pod traffic. Without them, all pods can talk to all pods.
πΈοΈ
Service mesh resources
Istio VirtualService, DestinationRule. Linkerd ServerAuthorization. CRDs that layer over the standard resources.
How the Service types stack
ClusterIP allocates the virtual IP. EndpointSlice objects hold the ready pod IPs; the Service object does not.
NodePort opens a port on every node and forwards it to that ClusterIP.
LoadBalancer asks the cloud for a balancer whose target is the NodePort.
Ingress is a rule, not a forwarder. A controller watches it and programs host, path, and TLS on a load balancer. Gateway and route objects split that rule so two teams do not edit one file.
A headless Service sets no cluster IP. DNS returns pod IPs, so StatefulSet members can address each other by a stable name.
What a volume bind survives
A PVC binds to one PV matching size, access mode, and StorageClass. If nothing matches, the class provisions a PV. The bind outlives the pod: a replacement on another node that mounts the same claim sees the same volume. Deleting the pod does not release it.
VolumeSnapshotClass defines how snapshots are taken. A VolumeSnapshot is a point-in-time copy of a claim, and a restore is a new claim filled from that snapshot.
Configuration and Secrets
π
ConfigMap
Non-sensitive key-value config. Mounted as files or env vars in pods. Feature flags, public URLs, log levels.
π
Secret
Sensitive data. Base64-encoded; encrypted at rest if etcd encryption is configured. DB passwords, API keys, TLS certs.
For production secrets, integrate with a real secret manager (AWS Secrets Manager, Vault, GCP Secret Manager) via the External Secrets Operator.
Storage
π
Volume
Storage attached to a Pod. Lifetime tied to the pod. Many types β emptyDir, hostPath, configMap, etc.
ποΈ
PersistentVolume (PV)
Cluster-level storage resource. Backed by EBS, NFS, etc. Lifecycle independent of any pod.
π«
PersistentVolumeClaim (PVC)
A pod's request for storage. Binds to an available PV (or triggers dynamic provisioning).
βοΈ
StorageClass
Template for dynamic PV provisioning. "gp3-encrypted-iops3000" β a class your StatefulSets ask for.
Identity and Access
π€
ServiceAccount
Identity for processes running in pods. By default each pod gets the namespace's default ServiceAccount. Use distinct ones for least-privilege.
π
Role / ClusterRole
Permissions definitions. Role is namespace-scoped; ClusterRole is cluster-wide. Verbs (get/list/create/update/delete) on resources.
π
RoleBinding / ClusterRoleBinding
Attach a Role to a User, Group, or ServiceAccount. The "X can do Y in namespace Z" mapping.
Declares a new resource type. K8s starts validating and storing instances of the new type the same way it does built-in types.
π€
Operator
A controller that manages CRDs. Encodes domain knowledge β how to operate a Postgres cluster, a Kafka cluster, a backup schedule.
π
OperatorHub
Catalog of community operators. Don't write your own for common systems β there's usually a battle-tested one.
A Realistic Composition
What a typical SaaS service looks like in K8s:
Namespace: app-prod Deployment: api-server βββ 3 Pods Γ (api-server container + sidecar log-collector) βββ envFrom: ConfigMap "api-config" + Secret "api-secrets" βββ ServiceAccount: api-server-sa βββ RoleBinding to Role "read-configs" Service: api-server (ClusterIP) βββ targets pods with label app=api-server Ingress: api-public βββ routes /v1/* to Service api-server HorizontalPodAutoscaler: api-server-hpa βββ scales api-server Deployment 3-20 replicas based on CPU ResourceQuota: app-prod-quota βββ limits namespace to 50 CPUs, 100Gi memory NetworkPolicy: api-server-policy βββ allows ingress only from ingress controller; egress only to DB StatefulSet: postgres βββ 3 Pods, each with 100Gi PVC from gp3-encrypted StorageClass βββ Headless Service for stable DNS ExternalSecret: db-creds βββ pulls from AWS Secrets Manager into Secret "postgres-creds"
This is what a βrealβ production service looks like. Lots of resources composing β but each one has a single, focused responsibility.