Kubernetes Skill
When to activate
- Writing Kubernetes manifests (Deployments, Services, ConfigMaps, Secrets, Ingress)
- Configuring Helm charts or values files for an application
- Debugging a failing Pod, CrashLoopBackOff, or OOMKilled container
- Setting up horizontal pod autoscaling (HPA) or vertical pod autoscaling (VPA)
- Defining resource requests and limits for containers
- Writing or reviewing RBAC policies (Roles, ClusterRoles, RoleBindings)
- Setting up liveness, readiness, and startup probes
- Configuring persistent volumes and persistent volume claims
- Writing network policies to control pod-to-pod traffic
- Setting up namespaces and multi-tenant isolation
When NOT to use
- Docker Compose setups that aren't being migrated to Kubernetes
- Serverless (Cloud Run, Lambda, Fargate) — different deployment model
- Simple single-container apps that don't need orchestration
- Local development environments where Docker alone suffices
- Nomad, Mesos, or other non-Kubernetes orchestrators
Instructions
Manifest structure
Always set these fields in every Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-name
namespace: production # Always explicit — never rely on default namespace
labels:
app: app-name
version: "1.0.0"
spec:
replicas: 3
selector:
matchLabels:
app: app-name
template:
metadata:
labels:
app: app-name
version: "1.0.0"
spec:
containers:
- name: app-name
image: registry/app-name:tag # Never use :latest in production
resources:
requests:
cpu: "100m"
memory: "128Mi"
limits:
cpu: "500m"
memory: "512Mi"
Resource requests and limits
- Always set both
requests and limits — never omit
requests = guaranteed resources (used for scheduling)
limits = maximum allowed (OOMKilled if memory exceeded)
- CPU limits are optional in clusters with CPU throttling disabled — but memory limits are mandatory
- Start conservative: requests at ~25% of expected, limits at 2x expected, then tune with actual metrics
Health probes
All production containers must have probes:
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
livenessProbe failure → container restart
readinessProbe failure → removed from Service load balancer (no traffic, no restart)
- Never point both at the same endpoint — readiness should check dependencies, liveness should not
Secrets management
- Never put secrets in ConfigMaps — use Secrets
- Never commit Secret manifests with real values — use sealed-secrets, external-secrets-operator, or Vault
- Reference secrets as env vars, not volumes, unless the app specifically requires file-based secrets:
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: app-secrets
key: database-url
Namespace conventions
default namespace: dev/testing only
- Production workloads always in named namespaces
- Use
ResourceQuota and LimitRange on every production namespace
- RBAC: developers get edit in dev namespaces, view in production
Common CrashLoopBackOff causes and fixes
- Missing env var → check
kubectl describe pod Events section
- Failed healthcheck → logs show the real error, probe just detects it
- OOMKilled → increase memory limit or fix memory leak
- Image pull error → check imagePullPolicy and registry credentials
- Init container failure →
kubectl logs pod-name -c init-container-name
Example
User: Deploy a FastAPI app with PostgreSQL connection, 3 replicas, resource limits, and health checks.
Expected output structure:
- Namespace manifest
- Secret for
DATABASE_URL
- Deployment with 3 replicas, resource requests/limits, liveness + readiness probes pointing to
/healthz and /ready
- Service (ClusterIP) exposing port 80 → container port 8080
- HorizontalPodAutoscaler targeting 70% CPU utilization, min 3 / max 10 replicas
1---2name: "kubernetes"3description: "Kubernetes manifests, resource limits, health probes, secrets, RBAC, HPA, CrashLoopBackOff diagnosis"4metadata:5 source: https://skillmd.com/skills/uitbreidenos/kubernetes6---78# Kubernetes Skill910## When to activate11- Writing Kubernetes manifests (Deployments, Services, ConfigMaps, Secrets, Ingress)12- Configuring Helm charts or values files for an application13- Debugging a failing Pod, CrashLoopBackOff, or OOMKilled container14- Setting up horizontal pod autoscaling (HPA) or vertical pod autoscaling (VPA)15- Defining resource requests and limits for containers16- Writing or reviewing RBAC policies (Roles, ClusterRoles, RoleBindings)17- Setting up liveness, readiness, and startup probes18- Configuring persistent volumes and persistent volume claims19- Writing network policies to control pod-to-pod traffic20- Setting up namespaces and multi-tenant isolation2122## When NOT to use23- Docker Compose setups that aren't being migrated to Kubernetes24- Serverless (Cloud Run, Lambda, Fargate) — different deployment model25- Simple single-container apps that don't need orchestration26- Local development environments where Docker alone suffices27- Nomad, Mesos, or other non-Kubernetes orchestrators2829## Instructions3031### Manifest structure32Always set these fields in every Deployment:33```yaml34apiVersion: apps/v135kind: Deployment36metadata:37 name: app-name38 namespace: production # Always explicit — never rely on default namespace39 labels:40 app: app-name41 version: "1.0.0"42spec:43 replicas: 344 selector:45 matchLabels:46 app: app-name47 template:48 metadata:49 labels:50 app: app-name51 version: "1.0.0"52 spec:53 containers:54 - name: app-name55 image: registry/app-name:tag # Never use :latest in production56 resources:57 requests:58 cpu: "100m"59 memory: "128Mi"60 limits:61 cpu: "500m"62 memory: "512Mi"63```6465### Resource requests and limits66- Always set both `requests` and `limits` — never omit67- `requests` = guaranteed resources (used for scheduling)68- `limits` = maximum allowed (OOMKilled if memory exceeded)69- CPU limits are optional in clusters with CPU throttling disabled — but memory limits are mandatory70- Start conservative: requests at ~25% of expected, limits at 2x expected, then tune with actual metrics7172### Health probes73All production containers must have probes:74```yaml75livenessProbe:76 httpGet:77 path: /healthz78 port: 808079 initialDelaySeconds: 1580 periodSeconds: 2081 failureThreshold: 38283readinessProbe:84 httpGet:85 path: /ready86 port: 808087 initialDelaySeconds: 588 periodSeconds: 1089 failureThreshold: 390```91- `livenessProbe` failure → container restart92- `readinessProbe` failure → removed from Service load balancer (no traffic, no restart)93- Never point both at the same endpoint — readiness should check dependencies, liveness should not9495### Secrets management96- Never put secrets in ConfigMaps — use Secrets97- Never commit Secret manifests with real values — use sealed-secrets, external-secrets-operator, or Vault98- Reference secrets as env vars, not volumes, unless the app specifically requires file-based secrets:99```yaml100env:101 - name: DATABASE_URL102 valueFrom:103 secretKeyRef:104 name: app-secrets105 key: database-url106```107108### Namespace conventions109- `default` namespace: dev/testing only110- Production workloads always in named namespaces111- Use `ResourceQuota` and `LimitRange` on every production namespace112- RBAC: developers get edit in dev namespaces, view in production113114### Common CrashLoopBackOff causes and fixes1151. Missing env var → check `kubectl describe pod` Events section1162. Failed healthcheck → logs show the real error, probe just detects it1173. OOMKilled → increase memory limit or fix memory leak1184. Image pull error → check imagePullPolicy and registry credentials1195. Init container failure → `kubectl logs pod-name -c init-container-name`120121## Example122123**User:** Deploy a FastAPI app with PostgreSQL connection, 3 replicas, resource limits, and health checks.124125**Expected output structure:**126- Namespace manifest127- Secret for `DATABASE_URL`128- Deployment with 3 replicas, resource requests/limits, liveness + readiness probes pointing to `/healthz` and `/ready`129- Service (ClusterIP) exposing port 80 → container port 8080130- HorizontalPodAutoscaler targeting 70% CPU utilization, min 3 / max 10 replicas131132---