{
    "slug": "container_orchestration",
    "term": "Container Orchestration",
    "category": "cloud",
    "difficulty": "advanced",
    "short": "Automating the deployment, scaling, networking, and health management of containers across a cluster of machines — Kubernetes is the dominant solution.",
    "long": "Kubernetes (K8s) manages containerised workloads: Pods (one or more containers), Deployments (desired replica count), Services (stable network endpoint), Ingress (HTTP routing), ConfigMaps/Secrets (configuration), and PersistentVolumes (storage). The control plane schedules and monitors; worker nodes run containers. Key operations: rolling updates, health checks, automatic restarts, horizontal pod autoscaling. For PHP: PHP-FPM runs in containers behind an nginx sidecar, scaled by HPA based on CPU or request rate.",
    "aliases": [
        "Kubernetes",
        "K8s",
        "Docker Swarm",
        "EKS",
        "GKE"
    ],
    "tags": [
        "cloud",
        "devops",
        "containers",
        "kubernetes"
    ],
    "misconception": "Kubernetes is required for production — it adds significant operational complexity; a managed PaaS (Render, Fly.io, Railway) or serverless approach is often better for teams without dedicated DevOps.",
    "why_it_matters": "Kubernetes standardises deployment, scaling, and self-healing across any cloud — a workload running on local K8s runs identically on EKS, GKE, or AKS.",
    "common_mistakes": [
        "Running a database in Kubernetes without understanding persistent storage — container restarts lose data without PVCs.",
        "Not setting resource requests and limits — containers without limits steal CPU/memory from neighbours.",
        "Not implementing readiness and liveness probes — Kubernetes cannot route traffic away from broken pods without them.",
        "Storing secrets in ConfigMaps — use Kubernetes Secrets or an external secrets manager."
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "containerisation",
        "cloud_auto_scaling",
        "health_check",
        "immutable_infrastructure"
    ],
    "prerequisites": [
        "kubernetes_basics",
        "containerisation",
        "continuous_deployment"
    ],
    "refs": [
        "https://kubernetes.io/docs/concepts/"
    ],
    "bad_code": "# Deployment without resource limits or health probes:\napiVersion: apps/v1\nkind: Deployment\nspec:\n  template:\n    spec:\n      containers:\n      - name: php-fpm\n        image: myapp:latest\n        # No resources: limits — can consume all node CPU/memory\n        # No readinessProbe — traffic sent to broken pods\n        # No livenessProbe — dead pods never restarted",
    "good_code": "spec:\n  containers:\n  - name: php-fpm\n    image: myapp:1.2.3  # Pinned version, not 'latest'\n    resources:\n      requests: { cpu: 250m, memory: 256Mi }\n      limits:   { cpu: 500m, memory: 512Mi }\n    readinessProbe:\n      httpGet: { path: /health, port: 80 }\n      initialDelaySeconds: 5\n    livenessProbe:\n      httpGet: { path: /ping, port: 80 }\n      periodSeconds: 10",
    "quick_fix": "Use managed Kubernetes (EKS, GKE, AKS) rather than self-hosted — the control plane management overhead is significant; focus on deploying your PHP app, not operating Kubernetes",
    "severity": "medium",
    "effort": "high",
    "created": "2026-03-15",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/container_orchestration",
        "html_url": "https://codeclaritylab.com/glossary/container_orchestration",
        "json_url": "https://codeclaritylab.com/glossary/container_orchestration.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Container Orchestration](https://codeclaritylab.com/glossary/container_orchestration) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/container_orchestration"
            }
        }
    }
}