How do you implement Kubernetes for production container orchestration?
Kubernetes orchestrates containerized workloads with automated deployment, scaling, and management. Core concepts: Pods (smallest deployable unit, one or more containers), Deployments (manage pod replicas with rolling updates), Services (stable network endpoints for pod groups), and Ingress (external HTTP routing to services). Production setup: use managed Kubernetes (EKS, GKE, AKS) for reduced operational burden, implement namespaces for environment and team isolation, configure resource requests and limits for every container, and implement Pod Disruption Budgets for availability during maintenance. Networking: implement a service mesh (Istio) for mTLS between services, observability, and traffic management. Use Network Policies to restrict inter-pod communication following the principle of least privilege. Storage: use Persistent Volume Claims for stateful workloads, implement storage classes for different performance tiers, and use StatefulSets for databases and other stateful applications. Scaling: Horizontal Pod Autoscaler (HPA) scales replicas based on CPU, memory, or custom metrics; Vertical Pod Autoscaler (VPA) adjusts resource requests; and Cluster Autoscaler adds/removes nodes based on pending pods. Security: implement Pod Security Standards (restricted profile for production), use OPA Gatekeeper for policy enforcement, implement RBAC for cluster access control, scan container images for vulnerabilities (Trivy, Snyk), and use sealed secrets or external secrets operator for secret management. Monitoring: deploy Prometheus and Grafana for metrics, implement liveness and readiness probes for health checking, and use Kubernetes events and audit logs for operational visibility. GitOps: use ArgoCD or Flux for declarative, Git-driven deployments with automatic drift detection and reconciliation.