Lab: Kubernetes (kind)¶
Prediction checkpoint
You will delete a serving pod while requests continue. Predict which component notices first, how long the endpoint remains routable, and whether the client sees an error. Then use events and endpoint state to explain the observed gap.
Pairs with: Kubernetes
A real 3-node cluster (1 control-plane + 2 workers) with a real ingress controller. Break a Service selector and watch a stale keepalive connection survive it briefly before failing; break a readiness probe mid-rollout and watch Kubernetes correctly refuse to finish replacing working pods with broken ones — diagnosed with real kubectl describe, not a guess.
Needs kind and kubectl in addition to Docker: brew install kind kubectl.
kind-config.yaml¶
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 8080
protocol: TCP
- containerPort: 443
hostPort: 8443
protocol: TCP
- role: worker
- role: worker
manifests/app.yaml¶
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
labels:
app: hello
spec:
replicas: 3
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello
image: hashicorp/http-echo:1.0
args:
- "-text=hello from $(POD_NAME)"
- "-listen=:5678"
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
ports:
- containerPort: 5678
readinessProbe:
httpGet:
path: /
port: 5678
initialDelaySeconds: 1
periodSeconds: 2
livenessProbe:
httpGet:
path: /
port: 5678
initialDelaySeconds: 2
periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
name: hello
spec:
selector:
app: hello
ports:
- port: 80
targetPort: 5678
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello
port:
number: 80
Exercises¶
The full walkthrough (deploy, break the Service selector, break a readiness probe, diagnose each with kubectl) lives in the lab's README: