# Kubernetes Kubernetes (K8s) is an [[Open Source]] container orchestration platform for automating deployment, scaling, and management of containerized applications. Originally developed at Google based on their internal Borg system, it was donated to the [[Cloud Native Computing Foundation (CNCF)]] in 2014. Created by [[Joe Beda]], [[Brendan Burns]], and [[Craig McLuckie]], Kubernetes has become the industry standard for running containers in production. Kubernetes abstracts infrastructure into a declarative API—you describe the desired state (pods, services, deployments), and Kubernetes continuously works to maintain it. It handles service discovery, load balancing, storage orchestration, automated rollouts/rollbacks, self-healing, and secret management. The name comes from Greek for "helmsman" or "pilot," and K8s is shorthand (K + 8 letters + s). ## Core Concepts | Concept | Description | |---------|-------------| | **Pod** | Smallest deployable unit; one or more containers | | **Deployment** | Manages ReplicaSets, handles rollouts | | **Service** | Stable network endpoint for pods | | **Namespace** | Virtual cluster for resource isolation | | **ConfigMap** | Configuration data as key-value pairs | | **Secret** | Sensitive data (passwords, tokens) | | **Ingress** | External HTTP/HTTPS routing | | **PersistentVolume** | Storage abstraction | ## Architecture ``` ┌─────────────────────────────────────────────────────────┐ │ Control Plane │ ├─────────────┬─────────────┬──────────────┬──────────────┤ │ API Server │ Scheduler │ Controller │ etcd │ │ │ │ Manager │ (key-value) │ └──────┬──────┴──────┬──────┴──────┬───────┴──────────────┘ │ │ │ └─────────────┼─────────────┘ │ ┌────────────────┼────────────────┐ ▼ ▼ ▼ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ Node 1 │ │ Node 2 │ │ Node 3 │ ├────────────┤ ├────────────┤ ├────────────┤ │ kubelet │ │ kubelet │ │ kubelet │ │ kube-proxy │ │ kube-proxy │ │ kube-proxy │ │ Container │ │ Container │ │ Container │ │ Runtime │ │ Runtime │ │ Runtime │ │ ┌────────┐ │ │ ┌────────┐ │ │ ┌────────┐ │ │ │ Pods │ │ │ │ Pods │ │ │ │ Pods │ │ │ └────────┘ │ │ └────────┘ │ │ └────────┘ │ └────────────┘ └────────────┘ └────────────┘ ``` ## Common Commands (kubectl) ```bash # Get resources kubectl get pods kubectl get deployments kubectl get services # Describe resource kubectl describe pod my-pod # Create from YAML kubectl apply -f deployment.yaml # Scale deployment kubectl scale deployment my-app --replicas=5 # View logs kubectl logs -f pod-name # Execute in pod kubectl exec -it pod-name -- bash # Port forward kubectl port-forward pod-name 8080:80 # Delete resources kubectl delete pod my-pod ``` ## Deployment Example ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.25 ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx ports: - port: 80 targetPort: 80 type: LoadBalancer ``` ## Kubernetes Distributions | Distribution | Description | |--------------|-------------| | **Managed** | EKS (AWS), GKE (Google), AKS (Azure) | | **Self-hosted** | kubeadm, kops, Rancher | | **Local** | minikube, kind, k3d, Docker Desktop | | **Lightweight** | k3s (Rancher), MicroK8s | | **Enterprise** | OpenShift (Red Hat), Tanzu (VMware) | ## Key Features - **Self-healing**: Restarts failed containers, replaces pods - **Horizontal scaling**: Scale based on CPU/memory/custom metrics - **Service discovery**: DNS-based discovery and load balancing - **Rolling updates**: Zero-downtime deployments - **Secret management**: Encrypted sensitive data - **Storage orchestration**: Mount local, cloud, or network storage - **Batch execution**: Manage batch and CI workloads ## History - **2014**: Google open-sources Kubernetes - **2015**: v1.0 released; CNCF founded with K8s as seed - **2017**: AWS, Azure launch managed Kubernetes - **2018**: Kubernetes graduates from CNCF incubation - **Present**: De facto standard for container orchestration ## References - https://kubernetes.io - https://kubernetes.io/docs/home/ - https://en.wikipedia.org/wiki/Kubernetes - https://github.com/kubernetes/kubernetes ## Related - [[Docker]] - [[Cloud Native Computing Foundation (CNCF)]] - [[Joe Beda]] - [[Brendan Burns]] - [[Craig McLuckie]] - [[Helm]] - [[DevOps]] - [[Containerization]] - [[kubectl]]