Pods, deployments, services, config maps, namespaces, and kubectl commands.
kubectl get pods -A -o widekubectl get pods -n production -o wide --sort-by=.status.startTimekubectl describe pod <name>kubectl describe pod api-7d4b9c -n productionkubectl logs -f --tail=100kubectl logs -f deployment/api -c app --tail=200kubectl exec -it pod -- bashkubectl exec -it pod/api-xyz -n prod -- /bin/shkubectl apply -f file.yamlkubectl apply -f ./k8s/ --dry-run=server // validate firstkubectl rollout undo deploykubectl rollout undo deployment/api --to-revision=3Podspec.containers[].resources.requests/limits — always set these!Deploymentkubectl scale deployment/api --replicas=5StatefulSetStatefulSet: postgres-0, postgres-1 ... (predictable DNS names)DaemonSetDaemonSet: fluentd, node-exporter, datadog-agentJob / CronJobschedule: "0 2 * * *" // run at 2AM dailyHorizontalPodAutoscalerkubectl autoscale deploy api --cpu-percent=70 --min=2 --max=20ClusterIP (default)my-svc.namespace.svc.cluster.local:80 // internal DNSNodePortnodePort: 31000 // accessible at NodeIP:31000LoadBalancertype: LoadBalancer // cloud provider creates external IPIngress + IngressClassrules: - host: api.example.com http.paths.backend.service.name: api-svcNetworkPolicypodSelector: matchLabels: {app: db} // restrict who can reach database podskubectl port-forwardkubectl port-forward svc/postgres 5432:5432 -n prodConfigMapkubectl create configmap app-config --from-file=config.envSecret (base64)kubectl create secret generic db-creds --from-literal=password=secretServiceAccount + RBACRole → RoleBinding (namespaced); ClusterRole → ClusterRoleBinding (global)PodSecurityContextsecurityContext: runAsNonRoot: true readOnlyRootFilesystem: trueResource Requests & Limitsresources: requests: {cpu: 100m, memory: 128Mi} limits: {cpu: 500m, memory: 512Mi}LimitRange / ResourceQuotaResourceQuota: hard: pods: "50" requests.cpu: "10" limits.memory: 20GiPersistentVolume (PV)spec.capacity.storage: 10Gi accessModes: [ReadWriteOnce]PersistentVolumeClaim (PVC)volumeClaimTemplates in StatefulSet gives each pod its own PVCStorageClassstorageClassName: gp3 // AWS EBS SSD in EKSemptyDir / hostPathemptyDir: {} // scratch space or cache between containers in a podlivenessProbelivenessProbe: httpGet: {path: /health, port: 8080} initialDelaySeconds: 30readinessProbereadinessProbe: httpGet: {path: /ready, port: 8080} periodSeconds: 5startupProbestartupProbe: failureThreshold: 30 periodSeconds: 10 // up to 5min startupnodeSelector / Affinityaffinity.nodeAffinity.requiredDuringScheduling: matchExpressionsTaints & Tolerationstolerations: [{key: "gpu", operator: "Exists", effect: "NoSchedule"}]PodDisruptionBudget (PDB)minAvailable: 2 // K8s won't drain a node if it would break this