Kubernetes Internals Basics
This page is a hands-on tour of the core loop that runs Kubernetes: you declare desired state, and controllers work to make reality match it.
Busca en todas las páginas de la documentación
This page is a hands-on tour of the core loop that runs Kubernetes: you declare desired state, and controllers work to make reality match it.
Each example shows one internal mechanism you can observe with kubectl on any cluster.
kubectl matching your cluster minor version.# Quick local cluster for these examples
kind create cluster --name internals
kubectl version --shortYou describe what you want, not the steps to get there.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels: { app: web }
template:
metadata:
labels: { app: web }
spec:
containers:
- name: web
image: nginx:1.27spec is your desired state; you never write "start three containers".Apply the Deployment and watch objects appear that you never wrote.
kubectl apply -f web.yaml
kubectl get deploy,rs,pods -l app=webEvery object carries both what you want and what is true now.
kubectl get deploy web -o jsonpath='{.spec.replicas} desired / {.status.availableReplicas} available{"\n"}'spec holds desired state; status holds observed state.status toward spec continuously.Delete a Pod and watch Kubernetes replace it.
kubectl delete pod -l app=web --field-selector 'status.phase=Running' --wait=false
kubectl get pods -l app=web --watchChange the desired number and let the system converge.
kubectl scale deploy/web --replicas=5
kubectl get rs -l app=webspec.replicas; you did not start any Pods yourself.The whole cluster is queryable objects, not hidden state.
kubectl get pod -l app=web -o yaml | head -n 20
kubectl api-resources | headmetadata, spec, and status are the universal envelope.get it, watch it, and version it.Events are the audit trail of the loop.
kubectl get events --sort-by=.lastTimestamp | tailTwo writers cannot silently clobber each other.
kubectl get deploy web -o jsonpath='{.metadata.resourceVersion}{"\n"}'resourceVersion that changes on each write.Children know their parent, so deletes cascade.
kubectl get rs -l app=web -o jsonpath='{.items[0].metadata.ownerReferences[0].kind}{"\n"}'
kubectl delete deploy web
kubectl get rs,pods -l app=webownerReference pointing at the Deployment.Clients stream changes rather than asking repeatedly.
kubectl get pods -l app=web --watch --output-watch-events--watch opens a long-lived stream of ADDED, MODIFIED, and DELETED events.The API describes itself, so you never have to guess field names.
kubectl explain deployment.spec.strategy
kubectl explain pod.spec.containers.resourceskubectl explain reads the live schema the API server publishes.Intent lives in etcd, so the cluster rebuilds reality after failures.
kubectl get deploy web -o yaml | grep -A2 'strategy:'spec is durable state stored through the API server in etcd.Stack versions: This page was written for Kubernetes 1.36.2, Docker Engine 29.6.1 (BuildKit default), containerd (CRI runtime on nodes), Helm 3, Compose v2, Argo CD (latest - verify at build), and Gateway API (GA - verify controller support at build).
Revisado por Chris St. John·Última actualización: 16 jul 2026