COMP 3150Operating Systems

01 Introduction

Lesson 13.4 presented Docker: the platform that made the containers the accessible (the images, the Dockerfile, the registries, the CLI, the ecosystem). The Docker's design's scope: the single's host's containers (the docker run's command, the Compose's multi-container's applications on the one host). The Docker's design's limits: the single's host's failures (the host's crash stops the containers), the manual's scaling (the operator runs the docker run's commands for the many's containers), the manual's placement (the operator decides which host runs which container), and the manual's networking (the operator configures the containers' connectivity). The orchestration is the answer to the limits: the platforms that manage the containers at scale — across the many's hosts, with the automated's scheduling, the automated's scaling, the automated's healing, and the automated's networking.

The container orchestration is the automated's management of the containers' lifecycle, the placement, the networking, the storage, and the configuration across the clusters of the many's hosts. The orchestration's concerns:

  • The scheduling. The orchestrator decides which host runs which container: the scheduler considers the containers' resource's requests (the CPU, the memory), the hosts' available's resources, the constraints (the affinity, the anti-affinity, the taints and the tolerations, the node's selectors), and the policies (the spread, the bin-packing, the topology's awareness).
  • The scaling. The orchestrator adjusts the containers' count (the horizontal's scaling: the replicas' count) and the containers' resources (the vertical's scaling: the CPU's and the memory's requests and limits) based on the demand: the metrics (the CPU's usage, the custom's metrics), the schedules (the time-based's scaling), and the events (the queues' lengths, the traffic's rates).
  • The self-healing. The orchestrator detects the containers' failures (the crashed's processes, the failed's health's checks), and it restarts or replaces the failed's containers: the desired's state (the replicas' count) is the orchestrator's specification, and the orchestrator's controllers (the reconciliation's loops) make the actual's state match the desired's state.
  • The service's discovery. The orchestrator provides the containers' the network's identities (the services' names, the DNS's names, the virtual's IPs), so the containers can find and communicate with the other's containers (the services' names' resolution, the load's balancing, the endpoints' management) without the manual's configuration.
  • The rolling's updates. The orchestrator updates the applications without the downtime: the rolling's updates (the containers are the replaced the incrementally: the new's version's containers are the started, the old's version's containers are the stopped), the blue-green's deployments (the two's environments: the new's version is the deployed, the traffic is the switched), the canary's releases (the small's percentage of the traffic to the new's version, the gradual's increase), and the rollbacks (the failed's updates are the reverted).
  • The configuration's management. The orchestrator manages the applications' configuration (the ConfigMaps, the environment's variables, the command's arguments) and the secrets (the Secrets, the external's secret's stores), so the containers' configuration is the declared, the versioned, and the injected at the runtime.
  • The storage's management. The orchestrator manages the containers' persistent's storage (the volumes, the PersistentVolumes, the PersistentVolumeClaims, the StorageClasses), so the containers' data is the persistent's and the portable's across the hosts.
  • The observability. The orchestrator provides the containers' and the applications' observability (the logs, the metrics, the traces, the events), so the operators can monitor the applications' health and diagnose the failures.

The Kubernetes is the orchestration's standard: the open-source's platform (the Google's, the 2014's release) that is the descendant of the Google's internal's Borg (the 2003's) and Omega (the 2010's) systems. The Kubernetes's design: the declarative's model (the operators declare the desired's state, and the Kubernetes's controllers make the actual's state match the desired's state), the extensible's architecture (the API's server, the controllers, the schedulers, the kubelets, the CRDs, the operators), the portable's abstractions (the pods, the services, the deployments, the ConfigMaps, the Secrets), and the ecosystem (the Helm, the Istio, the Prometheus, the ArgoCD, the many's tools). The Kubernetes's adoption: the cloud's providers' managed's services (the Amazon's EKS, the Google's GKE, the Microsoft's AKS, the Alibaba's ACK, the DigitalOcean's DOKS), the enterprises' on-premises's clusters (the Red Hat's OpenShift, the Rancher's RKE, the VMware's Tanzu), and the developers' local's clusters (the Docker Desktop's Kubernetes, the minikube, the kind, the k3s). The observation: the Kubernetes is the orchestration's de facto standard, and the observation is the reason the lesson's focus is the Kubernetes's architecture and its objects.

This lesson presents the container orchestration. It defines the orchestration's concept and its concerns. It presents the Kubernetes's architecture (the control's plane, the worker's nodes, the API's server, the etcd, the scheduler, the controller's manager, the kubelet, the kube-proxy, the CRI, the CNI, the CSI). It presents the Kubernetes's objects (the pods, the Deployments, the ReplicaSets, the Services, the Ingresses, the ConfigMaps, the Secrets, the StatefulSets, the DaemonSets, the Jobs, the CronJobs, the namespaces, the RBAC, the network's policies). It presents the alternatives (the Docker Swarm, the Nomad, the Mesos, the Amazon's ECS, the Azure's AKS, the Google's GKE) and the security's considerations. It presents the operations's concerns (the observability, the cost's management, the upgrades) and the ecosystem (the Helm, the Istio, the Prometheus, the ArgoCD). It closes with the orchestration's design's trade-offs and the lesson's synthesis.

Prerequisites

This lesson builds on Lessons 13.1 through 13.4 and the earlier lessons. The virtual machines (Lesson 13.1), the hypervisors (Lesson 13.2), the containers (Lesson 13.3), and the Docker (Lesson 13.4) are assumed. The containers' mechanisms (the namespaces, the cgroups, the union file systems, the capabilities, the seccomp, the LSM, the user's namespace), the OCI standards (the Runtime's Specification, the Image's Specification, the Distribution's Specification), the Docker's objects (the images, the containers, the networks, the volumes), and the Docker's security's considerations are the context for the orchestration's discussion. The Linux's networking (the bridges, the routes, the iptables, the DNS), the process's management, and the security's principles (Lesson 12.1) are assumed. Familiarity with the Linux command line from Lesson 2.2 is essential, since the interactive activity uses the kubectl, the minikube, the kind, the k3s, the helm, the k9s, the stern, the kubectx, the kubens, and the kubeadm commands.

02 Learning objectives

By the end of this lesson you will be able to

  • Define the container orchestration and explain its concerns (the scheduling, the scaling, the self-healing, the service's discovery, the rolling's updates, the configuration's management, the storage's management, the observability).
  • Describe the Kubernetes's architecture (the control's plane, the worker's nodes, the API's server, the etcd, the scheduler, the controller's manager, the kubelet, the kube-proxy, the CRI, the CNI, the CSI) and each component's role.
  • Describe the Kubernetes's objects (the pods, the Deployments, the ReplicaSets, the Services, the Ingresses, the ConfigMaps, the Secrets, the StatefulSets, the DaemonSets, the Jobs, the CronJobs, the namespaces, the RBAC, the network's policies) and each object's purpose.
  • Describe the Kubernetes's declarative's model (the desired's state, the reconciliation's loops, the manifests, the kubectl's commands) and the Kubernetes's scheduling's and the networking's mechanisms.
  • Describe the orchestration's alternatives (the Docker Swarm, the Nomad, the Mesos, the Amazon's ECS, the Azure's AKS, the Google's GKE) and each alternative's characteristics.
  • Describe the orchestration's security's considerations and the operations's concerns, and evaluate an orchestration's configuration against the lesson's criteria.

This lesson contributes to U13.5 and U13.6, and to course learning outcomes CLO1, CLO7, and CLO8.

03 Required reading

  • Operating System Concepts — Chapter 18, Virtual Machines, the sections on the containers and the operating-system-level virtualization. The standard treatment of the containers' concept and the orchestration's context.
  • OSTEP — the Virtualization chapters, particularly the discussion of the containers and the namespaces. OSTEP's treatment of the containers' mechanisms is the foundation for the orchestration's discussion, and it is the basis for the worked example in this lesson.
  • Burns, B., Grant, B., Oppenheimer, D., Brewer, E., & Wilkes, J. — Borg, Omega, and Kubernetes. ACM Queue, 2016. The paper that describes the Google's orchestration's systems and the Kubernetes's design, and it is the source for the Kubernetes's design's rationale.
  • Bernstein, D. — Containers and Cloud: From LXC to Docker to Kubernetes. IEEE Cloud Computing, 2014. The survey of the containers' evolution and the Kubernetes's role.
  • Hightower, K., Burns, B., & Beda, J. — Kubernetes: Up and Running, 3rd ed. O'Reilly, 2022. The comprehensive's practical's reference for the Kubernetes's architecture, the objects, and the operations.
  • Burns, B., Beda, J., & Hightower, K. — Kubernetes: Up and Running (the earlier's editions). The Kubernetes's concepts and the practical's guidance.
  • Lukša, M. — Kubernetes in Action, 2nd ed. Manning, 2020. The comprehensive's reference for the Kubernetes's architecture and the objects.
  • Kelsey Hightower's Kubernetes the Hard Way. The step-by-step's guide that builds the Kubernetes's cluster from the components, and it is the source for the Kubernetes's architecture's understanding.
  • The Kubernetes's documentation (kubernetes.io/docs): the concepts (the architecture, the objects, the controllers), the tasks, the tutorials, the reference (the API, the kubectl), and the best practices. The authoritative reference for the Kubernetes's usage.
  • The Cloud Native Computing Foundation (CNCF)'s landscape. The map of the orchestration's ecosystem (the platforms, the runtimes, the networking, the storage, the observability, the security, the CI/CD), and it is the source for the ecosystem's discussion.
  • Rice, L. — Container Security. O'Reilly, 2020. The comprehensive's treatment of the container's security's mechanisms, the escapes' attacks, and the Kubernetes's security's considerations.
  • NIST SP 800-190. — Application Container Security Guide. National Institute of Standards and Technology. The security's reference for the containers and the orchestration.
  • The Linux man pages: man 1 kubectl (or the kubectl's reference), man 1 minikube, man 1 kind, man 1 k3s, man 1 k3d, man 1 kubeadm, man 1 helm, man 1 k9s, man 1 stern, man 1 kubectx, man 1 kubens, man 1 crictl, man 1 ctr, man 1 nerdctl, man 1 podman, man 1 docker.

Reading strategy

Read the Burns et al. paper first for the Kubernetes's design's rationale: the Borg, the Omega, and the Kubernetes's evolution, the Kubernetes's design's decisions (the declarative's model, the pods, the labels, the controllers, the API's server), and the Kubernetes's design's trade-offs. Then read the Hightower et al. book or the Lukša book for the practical's treatment: the architecture, the objects, the operations, the security. The Kubernetes's documentation is the authoritative reference, and it is worth consulting for the specific's objects' and the commands' details. The CNCF's landscape is the ecosystem's map, and it is worth exploring for the tools' and the platforms' overview. The Rice's book and the NIST SP 800-190 are the security's references, and they are worth reading for the Kubernetes's security's considerations and the containers' best practices. Finally, the Linux man pages are the practical's tools. Pay particular attention to the Kubernetes's declarative's model: the operators declare the desired's state (the manifests: the YAML's files), and the Kubernetes's controllers (the reconciliation's loops) make the actual's state match the desired's state. The observation is the Kubernetes's design's central's idea: the operators do not issue the imperative's commands (kubectl run's the container), they declare the desired's state (kubectl apply -f's the manifest), and the Kubernetes's controllers do the rest. The observation is the reason the Kubernetes's model is the GitOps's foundation (the manifests are the versioned in the Git's repositories, and the tools like the ArgoCD and the Flux reconcile the clusters' state with the repositories' state).

04 Core content

4.1 What container orchestration is

The container orchestration is the automated's management of the containers' lifecycle, the placement, the networking, the storage, and the configuration across the clusters of the many's hosts. The orchestration's purpose: the containers' management at scale (the many's hosts, the many's containers, the many's applications), with the automated's operations (the scheduling, the scaling, the healing, the networking, the updates) and the declarative's model (the operators declare the desired's state, and the orchestrator makes the actual's state match the desired's state).

The orchestration's concerns (the introduction's list):

The scheduling
The orchestrator's scheduler decides which host runs which container: the scheduler considers the containers' resource's requests (the CPU, the memory), the hosts' available's resources (the capacity, the allocations), the constraints (the node's selectors, the affinity, the anti-affinity, the taints and the tolerations), and the policies (the spread, the bin-packing, the topology's awareness), and it places the containers on the hosts that satisfy the requirements.
The scaling
The orchestrator adjusts the containers' count (the horizontal's scaling: the replicas' count) and the containers' resources (the vertical's scaling: the CPU's and the memory's requests and limits) based on the demand: the metrics (the CPU's usage, the memory's usage, the custom's metrics: the queue's lengths, the requests' rates), the schedules (the time-based's scaling), and the events (the alerts, the traffic's rates). The Kubernetes's mechanisms: the HorizontalPodAutoscaler (the HPA: the replicas' adjustment), the VerticalPodAutoscaler (the VPA: the resources' adjustment), and the ClusterAutoscaler (the nodes' adjustment: the cloud's providers' integration).
The self-healing
The orchestrator detects the containers' failures (the crashed's processes, the failed's health's checks, the nodes' failures), and it restarts or replaces the failed's containers. The Kubernetes's mechanisms: the controllers (the reconciliation's loops: the Deployments, the ReplicaSets, the StatefulSets, the DaemonSets) compare the desired's state (the replicas' count) with the actual's state, and they create, delete, or replace the containers as the state requires. The observation: the self-healing is the declarative's model's consequence (the desired's state is the specification, and the controllers make the actual's state match).
The service's discovery
The orchestrator provides the containers' the network's identities: the services' names, the DNS's names, the virtual's IPs, the load's balancing, and the endpoints' management. The Kubernetes's mechanisms: the Services (the stable's virtual's IPs and the DNS's names: the myapp.default.svc.cluster.local's names), the kube-proxy (the load's balancing: the iptables's or the IPVS's rules, or the eBPF's with the Cilium), and the CoreDNS (the DNS's server: the services' and the pods' names' resolution).
The rolling's updates
The orchestrator updates the applications without the downtime: the rolling's updates (the containers are the replaced the incrementally), the blue-green's deployments (the two's environments, the traffic's switch), the canary's releases (the small's percentage of the traffic, the gradual's increase), and the rollbacks (the failed's updates' reverts). The Kubernetes's mechanisms: the Deployments (the strategy's field: the RollingUpdate's or the Recreate's; the maxSurge's and the maxUnavailable's parameters), the ReplicaSets (the versions' management), and the kubectl rollout's commands (the status, the history, the undo, the restart).
The configuration's management
The orchestrator manages the applications' configuration and the secrets: the ConfigMaps (the non-sensitive's configuration: the configuration's files, the environment's variables, the command's arguments), the Secrets (the sensitive's data: the passwords, the tokens, the certificates), and the external's secret's stores (the HashiCorp's Vault, the cloud's providers' secret's managers: the AWS's Secrets Manager, the Azure's Key Vault, the Google's Secret Manager; the Kubernetes's integrations: the Secrets Store CSI Driver, the External Secrets Operator).
The storage's management
The orchestrator manages the containers' persistent's storage: the volumes (the pods' volumes: the emptyDir's, the hostPath's, the configMap's, the secret's, the persistentVolumeClaim's), the PersistentVolumes (the cluster's storage's resources), the PersistentVolumeClaims (the pods' storage's requests), the StorageClasses (the dynamic's provisioning's templates: the cloud's providers' storage's classes, the CSI's drivers), and the CSI (the Container Storage Interface: the storage's plugins' standard).
The observability
The orchestrator provides the containers' and the applications' observability: the logs (the containers' stdout's and stderr's streams: the kubectl logs's command, the centralized's logging: the Fluentd's, the Fluent Bit's, the Loki's), the metrics (the resource's usage: the Metrics Server, the Prometheus's, the Grafana's), the traces (the distributed's tracing: the Jaeger's, the Tempo's, the OpenTelemetry's), and the events (the Kubernetes's events: the kubectl get events's command, the kubectl describe's output).

4.2 The Kubernetes's architecture

The Kubernetes's architecture is the cluster's design: the control's plane (the cluster's management's components) and the worker's nodes (the containers' hosts). The components:

The control's plane's components
The cluster's management's components:
  • The API's server (kube-apiserver). The cluster's central's component: the REST's API's server that the kubectl's commands, the controllers, the kubelets, and the other's components use. The API's server's roles: the authentication (the tokens, the certificates, the OIDC), the authorization (the RBAC, the ABAC, the webhooks), the admission (the validating's and the mutating's webhooks, the policies), the validation, and the persistence (the etcd's storage). The observation: the API's server is the cluster's single's source of the truth, and the observation is the reason the cluster's every's component communicates with the API's server.
  • The etcd. The cluster's key-value's store: the distributed's, the consistent's (the Raft's consensus's protocol) store that holds the cluster's state (the objects: the pods, the deployments, the services, the configs, the secrets). The etcd's roles: the state's persistence, the watch's mechanism (the API's server's and the controllers' watches), and the cluster's consistency. The observation: the etcd is the cluster's critical's component (its loss is the cluster's loss), and the observation is the reason the etcd's backup and its security are the cluster's operations's central's concerns.
  • The scheduler (kube-scheduler). The component that assigns the pods to the nodes: the scheduler watches the API's server for the unscheduled's pods, and it selects the nodes (the filtering: the predicates: the resources, the affinity, the taints, the volumes; the scoring: the priorities: the spread, the bin-packing, the topology's awareness; the binding: the selected node's assignment). The observation: the scheduler is the cluster's placement's component, and the observation is the reason the scheduler's policies and the pods' resource's requests and the nodes' labels are the cluster's scheduling's concerns.
  • The controller's manager (kube-controller-manager). The component that runs the cluster's controllers: the controllers (the reconciliation's loops) watch the API's server's objects, and they make the actual's state match the desired's state. The controllers: the Deployment's controller (the ReplicaSets' management), the ReplicaSet's controller (the pods' management), the StatefulSet's controller, the DaemonSet's controller, the Job's controller, the CronJob's controller, the Node's controller (the nodes' health's monitoring), the Service's controller, the Endpoints's controller, and the others. The observation: the controllers are the Kubernetes's declarative's model's heart, and the observation is the reason the Kubernetes's design is the the controllers' collection rather than the imperative's commands.
  • The cloud's controller's manager (cloud-controller-manager). The component that integrates the cluster with the cloud's providers' APIs: the cloud's controllers (the node's controller: the cloud's instances' lifecycle; the route's controller: the cloud's network's routes; the service's controller: the cloud's load's balancers; the volume's controller: the cloud's storage's provisioning). The observation: the cloud's controller's manager is the Kubernetes's cloud's integration's component.
The worker's nodes's components
The containers' hosts's components:
  • The kubelet (kubelet). The node's agent: the component that runs on the every's worker's node, and it manages the node's pods (the pods' lifecycle: the pods' creation, the pods' start, the pods' stop, the pods' deletion), the containers' health (the liveness's, the readiness's, the startup's probes), the volumes' mounting, the CRI's interface (the container's runtime's communication), and the node's status's reporting (the API's server's node's status's updates). The observation: the kubelet is the node's Kubernetes's agent, and the observation is the reason the kubelet's design and the CRI's interface are the Kubernetes's node's management's central's concerns.
  • The kube-proxy (kube-proxy). The node's network's proxy: the component that implements the Kubernetes's services' load's balancing on the node (the iptables's rules, the IPVS's, or the eBPF's with the Cilium), and it forwards the traffic to the services' endpoints. The observation: the kube-proxy is the Kubernetes's services' networking's component, and the observation is the reason the kube-proxy's modes (the iptables's, the IPVS's, the eBPF's) are the cluster's networking's concerns.
  • The container's runtime (the CRI's implementation). The node's container's runtime: the component that creates and runs the containers (the containerd, the CRI-O, the Docker with the dockershim's compatibility's layer, the deprecated in the Kubernetes 1.24's), and it communicates with the kubelet through the CRI (the Container Runtime Interface). The observation: the CRI's interface is the Kubernetes's and the runtimes' standard, and the observation is the reason the Kubernetes's clusters can use the different's runtimes.
  • The CNI's plugins. The node's network's plugins: the CNI (the Container Network Interface: the standard for the containers' network's configuration), and the plugins: the Calico's (the BGP's, the eBPF's), the Cilium's (the eBPF's: the security, the observability), the Flannel's (the VXLAN's), the Weave's, the Antrea's, the Kube-router's. The observation: the CNI's plugins implement the Kubernetes's network's model (the every's pod has its own's IP address, and the pods can communicate with the other's pods across the nodes without the NAT's), and the observation is the reason the CNI's plugins are the cluster's networking's central's concern.
  • The CSI's drivers. The node's storage's plugins: the CSI (the Container Storage Interface: the standard for the containers' storage's provisioning and mounting), and the drivers: the cloud's providers' (the AWS's EBS's, the Azure's Disk's, the Google's PD's), the on-premises's (the Ceph's, the NetApp's, the Pure's), the NFS's, the local's. The observation: the CSI's drivers are the Kubernetes's storage's management's mechanism, and the observation is the reason the storage's classes and the CSI's drivers are the cluster's storage's concerns.
The Kubernetes's architecture and its objects The diagram has two parts. The top part shows the Kubernetes's architecture: the control plane (the API server, the etcd, the scheduler, the controller manager, the cloud controller manager) and the worker nodes (the kubelet, the kube-proxy, the container runtime, the CNI, the CSI, the pods). The bottom part shows the Kubernetes's objects: the pod (the smallest deployable unit), the Deployment (the replicas and the rolling updates), the ReplicaSet (the pod's count), the Service (the stable virtual IP and the load balancing), the Ingress (the external HTTP and HTTPS), the ConfigMap and the Secret (the configuration), the StatefulSet (the stateful applications), the DaemonSet (the every node's pod), the Job and the CronJob (the batch workloads), the namespace (the logical partition), and the RBAC (the access control). THE KUBERNETES'S ARCHITECTURE The control's plane The API's server kube-apiserver the REST's API the cluster's truth etcd the key-value's store the Raft's consensus the cluster's state The scheduler kube-scheduler the pods' placement the filtering, the scoring The controller's manager kube-controller-manager the controllers' loops the reconciliation The cloud's controller's manager cloud-controller-manager the cloud's providers' integrations The worker's nodes The node 1 kubelet (the node's agent) kube-proxy (the load's balancing) the CRI (containerd, CRI-O) the CNI, the CSI (the plugins) The node 2 kubelet (the node's agent) kube-proxy (the load's balancing) the CRI (containerd, CRI-O) the CNI, the CSI (the plugins) THE KUBERNETES'S OBJECTS The pod the smallest's deployable's unit • the 1..n containers • the shared's network's namespace • the shared's volumes • the shared's lifecycle The Deployment the replicas and the updates • the replicas' count • the rolling's updates • the ReplicaSets' management • the rollbacks The Service the stable's network's identity • the virtual's IP • the DNS's name • the load's balancing • the endpoints The Ingress the external's HTTP and HTTPS • the host's routing • the path's routing • the TLS's termination • the Ingress's controllers The ConfigMap and the Secret the configuration • the ConfigMap (the non-sensitive's) • the Secret (the sensitive's) • the environment's variables • the files' mounts The StatefulSet the stateful's applications • the stable's identities • the stable's storage • the ordered's deployment • the databases, the caches The DaemonSet the every node's pod • the logs' collectors • the monitoring's agents • the network's plugins • the storage's drivers The Job and CronJob the batch's workloads • the Job (the run to completion) • the CronJob (the scheduled's) • the parallelism, the completions • the backoff's limit
Figure 13.5 — The Kubernetes's architecture and its objects. The top diagram shows the Kubernetes's architecture: the control plane (the API server, the etcd, the scheduler, the controller manager, the cloud controller manager) and the worker nodes (the kubelet, the kube-proxy, the container runtime, the CNI, the CSI). The bottom diagram shows the Kubernetes's objects: the pod (the smallest deployable unit), the Deployment (the replicas and the rolling updates), the Service (the stable network identity and the load balancing), the Ingress (the external HTTP and HTTPS), the ConfigMap and the Secret (the configuration), the StatefulSet (the stateful applications), the DaemonSet (the every node's pod), and the Job and the CronJob (the batch workloads). The objects are the Kubernetes's declarative model's vocabulary: the operators declare the desired state, and the controllers make the actual state match.

4.3 The Kubernetes's objects

The Kubernetes's objects are the cluster's state's records: the declarative's model's vocabulary. The operators declare the objects in the manifests (the YAML's or the JSON's files), and the Kubernetes's controllers make the actual's state match the declared's state. The objects:

The pod
The pod is the Kubernetes's smallest's deployable's unit: the group of the one's or the more's containers that share the network's namespace (the same's IP address and the same's port's space), the storage's volumes, and the lifecycle (the containers are the scheduled, the started, and the stopped together). The pod's design: the containers' co-location (the sidecar's pattern: the helper's containers that augment the main's container: the logging's, the proxy's, the configuration's), the shared's resources, and the pod's specification (the containers, the volumes, the resource's requests and limits, the probes, the security's context, the node's selector, the affinity, the tolerations). The observation: the pod is the Kubernetes's atomic's unit (the operators do not manage the containers directly; they manage the pods), and the observation is the reason the pod's design (the co-location, the shared's resources, the lifecycle) is the Kubernetes's abstractions' foundation.
The Deployment
The Deployment is the stateless's applications' controller: the object that manages the ReplicaSets (the versions) and the pods (the replicas). The Deployment's fields: the replicas (the desired's pod's count), the selector (the pods' labels' selector), the template (the pod's specification), the strategy (the RollingUpdate's or the Recreate's; the maxSurge's and the maxUnavailable's parameters), the revision's history (the revisionHistoryLimit's field), and the progress's deadline. The Deployment's design: the rolling's updates (the new's ReplicaSet is the created, the pods are the replaced the incrementally), the rollbacks (the previous's ReplicaSet is the scaled up, the current's ReplicaSet is the scaled down), and the pause and the resume (the kubectl rollout pause's and the kubectl rollout resume's commands). The observation: the Deployment is the Kubernetes's stateless's applications' standard's object, and the observation is the reason the modern's applications use the Deployments for the web's servers, the API's backends, and the stateless's services.
The ReplicaSet
The ReplicaSet is the pods' count's controller: the object that ensures the specified's number of the pods is the running (the replicas' count: the replicas's field), the pods are the selected (the selector's field), and the pods are the created from the template (the template's field). The ReplicaSet's design: the reconciliation's loop (the actual's pods' count's comparison with the desired's count, and the pods' creation or deletion), and the observation: the ReplicaSet is the Deployment's implementation's detail (the operators rarely manage the ReplicaSets directly), and the observation is the reason the modern's practices use the Deployments (the ReplicaSets' management) rather than the ReplicaSets (the pods' management).
The Service
The Service is the stable's network's identity: the object that provides the stable's virtual's IP address and the DNS's name for the group of the pods (the selector's field: the pods' labels), and it load-balances the traffic across the pods (the endpoints). The Service's types: the ClusterIP's (the cluster's internal's virtual's IP: the default), the NodePort's (the every node's port: the external's access through the nodes' IPs), the LoadBalancer's (the cloud's providers' load's balancers: the external's access through the load's balancer's IP), and the ExternalName's (the DNS's CNAME's alias). The Service's design: the endpoints' management (the Endpoints's object: the pods' IPs and the ports), the kube-proxy's load's balancing (the iptables's, the IPVS's, or the eBPF's), and the DNS's resolution (the CoreDNS: the myapp.default.svc.cluster.local's names). The observation: the Service is the Kubernetes's services' discovery's and the load's balancing's object, and the observation is the reason the applications' communication uses the services' names (the stable's identities) rather than the pods' IPs (the ephemeral's addresses).
The Ingress
The Ingress is the external's HTTP and HTTPS's routing: the object that routes the external's traffic to the services (the host's routing: the example.com's, the api.example.com's; the path's routing: the /'s, the /api's; the TLS's termination: the certificates). The Ingress's design: the Ingress's controllers (the Nginx's, the Traefik's, the HAProxy's, the Envoy's, the Istio's) implement the routing, and the observation: the Ingress is the Kubernetes's external's access's object, and the observation is the reason the modern's applications use the Ingress (the HTTP and the HTTPS's routing) with the Ingress's controllers (the external's load's balancers' and the reverse's proxies' implementations).
The ConfigMap and the Secret
The ConfigMap is the non-sensitive's configuration: the object that holds the configuration's data (the key-value's pairs: the configuration's files, the environment's variables, the command's arguments), and it is the mounted into the pods (the volumes' or the environment's variables' injection). The Secret is the sensitive's data: the object that holds the sensitive's data (the passwords, the tokens, the certificates, the keys), and it is the mounted into the pods (the volumes' or the environment's variables' injection) and the stored in the etcd (the base64-encoded: the encryption at rest is the configuration's option). The design's observation: the ConfigMaps and the Secrets are the Kubernetes's configuration's management's objects, and the observation is the reason the applications' configuration is the declared (the manifests), the versioned (the Git's repositories), and the injected (the pods' mounts) rather than the baked into the images.
The StatefulSet
The StatefulSet is the stateful's applications' controller: the object that manages the stateful's applications (the databases, the caches, the message's queues), with the stable's identities (the pods' names: the myapp-0's, the myapp-1's, the myapp-2's; the network's identities: the headless's services' DNS's names), the stable's storage (the PersistentVolumeClaims's templates: the every pod's volume), and the ordered's deployment (the pods are the created and the deleted in the order). The observation: the StatefulSet is the Kubernetes's stateful's applications' object, and the observation is the reason the databases and the other's stateful's workloads use the StatefulSets (the stable's identities and storage) rather than the Deployments (the interchangeable's pods).
The DaemonSet
The DaemonSet is the every node's pod's controller: the object that ensures the every node (or the selected's nodes: the node's selectors, the affinity, the taints and the tolerations) runs the specified's pod. The DaemonSet's use's cases: the logs' collectors (the Fluentd's, the Fluent Bit's), the monitoring's agents (the Prometheus's node's exporter, the Datadog's agent), the network's plugins (the Calico's, the Cilium's node's components), the storage's drivers (the CSI's node's plugins), and the security's agents (the Falco's). The observation: the DaemonSet is the Kubernetes's per-node's workloads' object, and the observation is the reason the cluster's infrastructure's components (the logs, the monitoring, the networking, the storage) use the DaemonSets.
The Job and the CronJob
The Job is the batch's workloads' controller: the object that runs the pods to the completion (the completions's field: the successful's pods' count; the parallelism's field: the concurrent's pods' count; the backoffLimit's field: the retries' count; the activeDeadlineSeconds's field: the timeout). The CronJob is the scheduled's jobs' controller: the object that runs the Jobs on the schedule (the schedule's field: the cron's expression; the concurrencyPolicy's field: the Allow's, the Forbid's, the Replace's policies; the startingDeadlineSeconds's field; the successfulJobsHistoryLimit's and the failedJobsHistoryLimit's fields). The observation: the Jobs and the CronJobs are the Kubernetes's batch's workloads' objects, and the observation is the reason the data's processing (the ETL's pipelines, the ML's training's jobs), the backups, and the maintenance's tasks use the Jobs and the CronJobs.
The namespace
The namespace is the cluster's logical's partition: the object that provides the scope for the names (the the objects' names are the unique within the namespace, not the cluster), the resource's quotas (the ResourceQuota's objects: the CPU's, the memory's, the objects' counts), the limit's ranges (the LimitRange's objects: the default's and the maximum's resource's limits), the network's policies (the NetworkPolicy's objects: the pods' traffic's rules), and the RBAC's scope (the roles' and the role's bindings' scope). The namespaces' use's cases: the environments' separation (the development, the staging, the production), the teams' separation, the tenants' separation. The observation: the namespace is the Kubernetes's multi-tenancy's and the organization's mechanism, and the observation is the reason the namespaces are the cluster's logical's partitions.
The RBAC (the Role-Based Access Control)
The RBAC is the Kubernetes's authorization's mechanism: the objects (the Role's and the ClusterRole's: the permissions' rules: the API's groups, the resources, the verbs; the RoleBinding's and the ClusterRoleBinding's: the subjects' and the roles' bindings: the users, the groups, the service's accounts), and the authorization's model (the additive's: the every's matching's rule's permission is the granted, the no's deny's rules, the the cluster's admin's role is the cluster's superuser). The observation: the RBAC is the Kubernetes's access's control's mechanism, and the observation is the reason the RBAC's design (the least privilege's principle: the the applications' service's accounts are the the specific's permissions, the the users' roles are the the specific's namespaces' scopes) is the cluster's security's central's concern.
The network's policy
The NetworkPolicy is the pods' traffic's rules: the object that specifies the allowed's ingress and egress's traffic (the pod's selectors, the namespace's selectors, the IP's blocks, the ports, the protocols), and the observation: the NetworkPolicy is the Kubernetes's network's segmentation's mechanism, and the observation is the reason the NetworkPolicy's design (the the namespaces' and the pods' isolation's rules) is the cluster's security's central's concern. The observation: the NetworkPolicy's enforcement requires the CNI's plugins' support (the the Calico's, the Cilium's, the Weave's: the the enforcement's plugins; the the Flannel's: the no's enforcement's support).

4.4 The Kubernetes's declarative's model

The Kubernetes's declarative's model is the design's central's idea: the operators declare the desired's state (the manifests: the YAML's or the JSON's files), and the Kubernetes's controllers (the reconciliation's loops) make the actual's state match the desired's state. The model's components:

  • The manifests. The declarative's specifications: the YAML's files (the apiVersion's, the kind's, the metadata's, the spec's sections), and the observation: the manifests are the applications' definitions (the infrastructure's as the code), and the observation is the reason the manifests are the versioned in the Git's repositories.
  • The kubectl's commands. The Kubernetes's CLI: the imperative's commands (the kubectl run's, the kubectl create's, the kubectl delete's, the kubectl scale's, the kubectl expose's: the ad-hoc's operations) and the declarative's commands (the kubectl apply -f's, the kubectl diff's, the kubectl delete -f's, the kubectl kustomize's: the manifests' operations). The kubectl's commands: the resource's inspection (the get's, the describe's, the logs's, the exec's, the port-forward's, the cp's), the cluster's inspection (the cluster-info's, the get nodes's, the top's), the rollout's management (the rollout's subcommands: the status's, the history's, the undo's, the restart's), the debugging (the debug's, the events's), and the configuration (the config's subcommands: the set-context's, the set-namespace's).
  • The reconciliation's loops. The controllers' mechanism: the every's controller watches the API's server's objects (the watch's mechanism: the etcd's events), and it compares the actual's state (the cluster's resources) with the desired's state (the objects' specifications), and it performs the actions (the objects' creation, the objects' deletion, the objects' updates) to make the actual's state match the desired's state. The observation: the reconciliation's loops are the Kubernetes's declarative's model's heart, and the observation is the reason the Kubernetes's design is the the controllers' collection rather than the imperative's commands.
  • The GitOps's model. The GitOps's design: the manifests are the versioned in the Git's repositories (the desired's state's single's source of the truth), and the GitOps's tools (the ArgoCD's, the Flux's) watch the repositories and reconcile the clusters' state with the repositories' state (the pull's model: the tools pull the manifests from the Git, the CI/CD's pipelines push the manifests to the Git, the tools reconcile the clusters, the observation: the GitOps's model is the declarative's model's extension, and the observation is the reason the GitOps's tools are the modern's Kubernetes's operations's standard).

The declarative's model's example (the Deployment's manifest):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: production
  labels:
    app: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: web
          image: ghcr.io/myorg/web:v1.0.0
          ports:
            - containerPort: 8080
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 512Mi
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            httpGet:
              path: /ready
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 10
          securityContext:
            runAsNonRoot: true
            runAsUser: 1000
            readOnlyRootFilesystem: true
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
          volumeMounts:
            - name: config
              mountPath: /etc/app
              readOnly: true
            - name: secrets
              mountPath: /etc/secrets
              readOnly: true
      volumes:
        - name: config
          configMap:
            name: web-config
        - name: secrets
          secret:
            secretName: web-secrets
      securityContext:
        fsGroup: 1000
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchLabels:
                    app: web
                topologyKey: kubernetes.io/hostname

The manifest's observation: the spec's section declares the desired's state (the three's replicas, the container's image, the resources' requests and limits, the probes, the security's context, the volumes, the affinity), and the Kubernetes's controllers (the Deployment's, the ReplicaSet's, the scheduler's, the kubelet's) make the actual's state match. The observation: the manifest is the application's definition (the versioned, the reviewable, the reproducible), and the observation is the reason the declarative's model is the Kubernetes's design's central's idea.

4.5 The Kubernetes's scheduling and networking

The Kubernetes's scheduling: the scheduler assigns the pods to the nodes, and its mechanisms:

  • The resource's requests and limits. The pods' containers declare the resource's requests (the guaranteed's resources: the scheduler uses the requests to select the nodes) and the limits (the maximum's resources: the kubelet enforces the limits), and the observation: the requests and the limits are the scheduling's and the enforcement's mechanisms (the cgroups' configuration).
  • The node's selection's rules. The nodeSelector's field (the simple's label's selector), the nodeName's field (the specific's node), the affinity (the nodeAffinity's: the nodes' labels' selectors; the podAffinity's: the pods' co-location; the podAntiAffinity's: the pods' separation), and the taints and the tolerations (the nodes' taints: the NoSchedule's, the PreferNoSchedule's, the NoExecute's; the pods' tolerations: the the taints' matching's tolerations).
  • The scheduler's policies. The filtering (the predicates: the resources' availability, the affinity, the taints, the volumes, the ports), the scoring (the priorities: the spread, the bin-packing, the topology's awareness, the image's locality), and the binding (the selected's node's assignment), and the observation: the scheduler's design is the Kubernetes's placement's mechanism, and the observation is the reason the scheduler's policies (the the cluster's defaults and the the pods' specifications) are the cluster's scheduling's concerns.
  • The scheduler's profiles. The scheduler's profiles (the KubeSchedulerConfiguration's object: the profiles: the default-scheduler's, the high-throughput's; the plugins: the NodeResourcesFit's, the PodTopologySpread's, the InterPodAffinity's, the ImageLocality's; the pluginConfig's), and the observation: the scheduler's profiles are the cluster's scheduling's customization's mechanism.

The Kubernetes's networking: the cluster's network's model, and its mechanisms:

  • The network's model. The Kubernetes's network's requirements (the CNI's specification): the every pod has its own's IP address (the cluster's unique's IP), the the pods can communicate with the the other's pods on the the same's node and the the different's nodes without the NAT's, the the nodes can communicate with the the pods, the the pods can communicate with the the external's world (the the NAT's for the the egress's traffic), and the observation: the the network's model's requirements are the CNI's plugins' specifications.
  • The CNI's plugins. The CNI's plugins: the Calico's (the the BGP's and the the eBPF's datapath's, the the network's policies' enforcement's), the Cilium's (the the eBPF's: the the networking's, the the security's, the the observability's, the the service's mesh's, the the network's policies'), the Flannel's (the the VXLAN's overlay's: the the simple's, the the no's network's policies' enforcement's), the Weave's, the Antrea's (the the Open vSwitch's), the Kube-router's, and the observation: the CNI's plugins are the cluster's networking's and the network's policies' implementations.
  • The services' networking. The services' networking: the ClusterIP's (the the virtual's IP: the the kube-proxy's iptables's rules or the the IPVS's virtual's servers, or the the eBPF's with the the Cilium), the NodePort's (the the every node's port: the the external's access through the the nodes' IPs), the LoadBalancer's (the the cloud's providers' load's balancers: the the external's IP: the the cloud's controller's manager's provisioning's), and the observation: the services' networking is the Kubernetes's services' discovery's and the load's balancing's mechanism.
  • The DNS's resolution. The CoreDNS's (the cluster's DNS's server: the services' names: the the myapp.default.svc.cluster.local's format: the the <service>.<namespace>.svc.cluster.local's; the the pods' names: the the headless's services'; the the stateful's pods' names; the the search's domains: the the pod's /etc/resolv.conf's file), and the observation: the DNS's resolution is the Kubernetes's services' discovery's mechanism.

4.6 The orchestration's alternatives

The orchestration's alternatives:

The Docker Swarm
The Docker Swarm is the Docker's native's orchestration (the Docker's, the 2014's): the cluster's swarm (the managers and the workers), the services (the multi-container's applications: the replicated's tasks), the overlay's networks (the multi-host's networks), the secrets and the configs, and the stacks (the Compose's files' deployment). The Swarm's advantages: the simplicity (the Docker's CLI and the Compose's files: the the Docker's familiar's interfaces), the the integration (the Docker's ecosystem: the the images, the the Compose, the the secrets), and the the learning's curve (the the the Docker's knowledge's reuse). The Swarm's disadvantages: the the features (the the fewer's than the the Kubernetes's: the the no's auto-scaling's, the the no's the the advanced's scheduling's), the the ecosystem (the the smaller's than the the Kubernetes's), and the the adoption (the the Kubernetes's dominance: the the Swarm's decline), and the observation: the Swarm's design is the the Docker's simplicity's choice, and the observation is the the reason the the small's deployments and the the Docker's developers use the the Swarm.
The HashiCorp's Nomad
The Nomad is the HashiCorp's orchestration (the HashiCorp's, the 2015's): the cluster's servers (the management's components), the clients (the workloads' hosts), the jobs (the workloads' definitions: the the containers, the the virtual machines, the the raw's binaries, the the Java's applications), and the allocations (the jobs' instances). The Nomad's advantages: the simplicity (the the single's binary, the the simple's configuration), the the flexibility (the the multiple's workloads: the the containers, the the VMs, the the binaries), the the integration (the the HashiCorp's stack: the the Consul, the the Vault, the the Terraform), and the the scale (the the millions of the containers: the the HashiCorp's claims). The Nomad's disadvantages: the the ecosystem (the the smaller's than the the Kubernetes's), and the the adoption (the the Kubernetes's dominance), and the observation: the the Nomad's design is the the HashiCorp's ecosystem's integration's choice.
The Apache Mesos
The Mesos is the Apache's cluster's manager (the UC Berkeley's, the 2011's): the the master's nodes (the the management's components), the the agent's nodes (the the workloads' hosts), the the frameworks (the the workload's managers: the the Marathon's for the the containers, the the Chronos's for the the scheduled's tasks, the the Spark's for the the data's processing), and the the offers (the the resources' proposals). The Mesos's advantages: the the scale (the the thousands of the nodes), the the flexibility (the the multiple's frameworks), and the the maturity (the the years of the production's use: the the Twitter's, the the Airbnb's). The Mesos's disadvantages: the the complexity (the the frameworks' management), and the the adoption (the the Kubernetes's dominance: the the Mesos's decline), and the observation: the the Mesos's design is the the data's center's OS's vision (the the frameworks as the the workloads' managers).
The cloud's providers' orchestration's services
The cloud's providers' orchestration's services: the Amazon's ECS (the Elastic Container Service: the the AWS's native's orchestration: the the task's definitions, the the services, the the clusters, the the Fargate's serverless's compute), the Amazon's EKS (the Elastic Kubernetes Service: the the managed's Kubernetes's clusters), the Google's GKE (the Google Kubernetes Engine: the the managed's Kubernetes's clusters, the the Autopilot's mode), the Microsoft's AKS (the Azure Kubernetes Service), the Alibaba's ACK, the DigitalOcean's DOKS, and the observation: the the cloud's providers' services are the the managed's orchestration (the the control's plane's management's outsourcing: the the upgrades, the the scaling, the the monitoring), and the observation is the the reason the the modern's organizations use the the managed's services rather than the the self-managed's clusters.

4.7 The orchestration's security

The orchestration's security: the clusters' security's considerations (the Lesson 12.1's principles and the Lesson 13.3's and the Lesson 13.4's discussions applied to the Kubernetes):

  • The cluster's security's layers. The layers: the cloud's infrastructure's security (the the VPC's, the the security's groups, the the IAM's), the the cluster's security (the the API's server's authentication and the the authorization, the the RBAC, the the admission's controllers, the the etcd's encryption), the the node's security (the the OS's hardening, the the kubelet's security, the the container's runtime's security), the the pod's security (the the security's context, the the pod's security's admission, the the seccomp's, the the AppArmor's, the the SELinux's, the the capabilities), and the the application's security (the the container's security's configurations: the the non-root's user, the the read-only's file system, the the dropped's capabilities), and the observation: the the security's layers are the the defence's in the depth's application (the the Lesson 12.1's principle).
  • The API's server's security. The API's server's security's mechanisms: the authentication (the the client's certificates, the the bearer's tokens, the the OIDC's, the the webhook's, the the service's accounts' tokens), the authorization (the the RBAC's, the the ABAC's, the the webhook's, the the node's authorizer), the admission's controllers (the the validating's and the the mutating's: the the PodSecurity's, the the ResourceQuota's, the the LimitRanger's, the the NetworkPolicy's, the the custom's webhooks), and the audit's logging (the the API's server's audit's policy: the the requests' recording), and the observation: the the API's server's security is the the cluster's security's the central's component.
  • The pod's security. The pod's security's mechanisms: the the security's context (the the runAsUser's, the the runAsNonRoot's, the the readOnlyRootFilesystem's, the the allowPrivilegeEscalation's, the the capabilities' the drop's, the the seccompProfile's, the the appArmorProfile's, the the seLinuxOptions's, the the fsGroup's, the the sysctls's), the the Pod Security's Standards (the the privileged's, the the baseline's, the the restricted's: the the three's policy's levels: the the namespaces' labels: the the pod-security.kubernetes.io/enforce's), the the Pod Security's Admission (the the admission's controller: the the PSS's enforcement: the the three's modes: the the enforce's, the the audit's, the the warn's), and the observation: the the pod's security is the the cluster's security's the application's layer.
  • The network's security. The network's security's mechanisms: the the network's policies (the the pods' ingress and the the egress's rules: the the namespace's selectors, the the pod's selectors, the the IP's blocks, the the ports), the the service's mesh's security (the the mTLS's: the the mutual's TLS's, the the authorization's policies, the the traffic's encryption), and the observation: the the network's security is the the cluster's security's the networking's layer, and the observation is the the reason the the network's policies and the the service's mesh are the the cluster's security's central's concerns.
  • The supply chain's security. The supply chain's security's mechanisms: the the images' scanning (the the Trivy's, the the Grype's, the the Clair's), the the images' signing (the the Cosign's, the the Notary's: the the Sigstore's), the the images' attestation (the the SLSA's, the the in-toto's), the the SBOM's (the the Software's Bill's of the Materials: the the Syft's, the the Trivy's, the the SPDX's), the the admission's controllers (the the Kyverno's, the the OPA's Gatekeeper's, the the Sigstore's policy's controller: the the images' verification's the admission's policies), and the observation: the the supply chain's security is the the cluster's security's the emerging's concern.
  • The runtime's security. The runtime's security's tools: the the Falco's (the the runtime's security: the the system's calls' monitoring, the the rules, the the alerts), the the Tetragon's (the the eBPF's security's observability: the the Kubernetes's awareness), the the Sysdig's, the the Aqua's, the the StackRox's, and the observation: the the runtime's security's tools are the the cluster's security's the operations's mechanisms (the the detection, the the response).

4.8 The orchestration's operations

The orchestration's operations (the Day 2's concerns): the clusters' management after the initial's deployment:

  • The observability. The logs (the the kubectl logs's command, the the centralized's logging: the the Fluentd's, the the Fluent Bit's, the the Loki's, the the Elasticsearch's), the metrics (the the Metrics Server: the the kubectl top's command, the the Prometheus's, the the Grafana's, the the VictoriaMetrics's), the traces (the the Jaeger's, the the Tempo's, the the OpenTelemetry's), and the events (the the kubectl get events's, the the kubectl describe's), and the observation: the the observability is the the cluster's operations's the central's concern.
  • The cost's management. The cost's management's tools: the the Kubecost's, the the OpenCost's, the the cloud's providers' cost's management's tools (the the AWS's Cost Explorer, the the Azure's Cost Management, the the GCP's Cost Management), the the resource's requests and the the limits' optimization (the the rightsizing's: the the VPA's), and the observation: the the cost's management is the the cluster's operations's the emerging's concern (the the cloud's bills' the significant's component).
  • The upgrades. The upgrades' mechanisms: the the cluster's version's upgrades (the the control's plane's, the the nodes': the the rolling's, the the blue-green's), the the API's versions' deprecations (the the migration's guides), the the add-ons' upgrades (the the CNI's, the the CSI's, the the Ingress's, the the operators'), and the observation: the the upgrades are the the cluster's operations's the periodic's concern.
  • The backups. The backups' mechanisms: the the etcd's backups (the the critical's: the the cluster's state), the the persistent's volumes' backups (the the Velero's: the the cluster's resources' and the the volumes' backups), the the manifests' backups (the the Git's repositories: the the GitOps's model), and the observation: the the backups are the the cluster's operations's the essential's concern.
  • The disaster's recovery. The disaster's recovery's mechanisms: the the multi-cluster's designs (the the active-active's, the the active-passive's), the the cross-region's replication (the the storage's, the the etcd's), the the failover's procedures, and the observation: the the disaster's recovery is the the cluster's operations's the resilience's concern.

4.9 The orchestration's ecosystem

The orchestration's ecosystem (the Cloud Native Computing Foundation's landscape): the tools that extend the Kubernetes:

  • The Helm (the package's management). The Helm is the Kubernetes's package's manager (the the charts: the the packages: the the templates, the the default's values, the the dependencies; the the releases: the the installed's instances; the the repositories: the the chart's repositories), and the observation: the the Helm's design is the the Kubernetes's applications' packaging's and the the deployment's mechanism (the the templating's, the the versioning's, the the rollbacks'), and the observation is the the reason the the Helm is the the Kubernetes's ecosystem's the standard's package's manager.
  • The Kustomize (the configuration's management). The Kustomize is the Kubernetes's configuration's customization's tool (the the base's manifests and the the overlays: the the environment's specific's customizations: the the patches, the the name's prefixes, the the labels, the the image's tags), and the observation: the the Kustomize's design is the the Kubernetes's manifests' the templating's alternative (the the plain's YAML's the overlays), and the observation is the the reason the the kubectl kustomize's and the the kubectl apply -k's commands are the the Kubernetes's the configuration's management's standard.
  • The Istio (the service's mesh). The Istio is the Kubernetes's service's mesh (the the traffic's management, the the security's: the the mTLS's, the the authorization's policies, the the observability's: the the metrics, the the traces, the the logs), and the observation: the the Istio's design is the the Kubernetes's the networking's the advanced's features (the the traffic's routing, the the resilience's: the the retries, the the timeouts, the the circuit's breakers), and the observation is the the reason the the service's mesh (the the Istio's, the the Linkerd's, the the Consul's Connect's) is the the Kubernetes's the microservices' networking's the standard.
  • The Prometheus (the monitoring). The Prometheus is the Kubernetes's monitoring (the the metrics' collection: the the pull's model, the the exporters, the the service's monitors, the the pod's monitors; the the PromQL's query's language; the the Alertmanager's the alerts), and the observation: the the Prometheus's design is the the Kubernetes's the observability's the standard (the the CNCF's the graduated's project), and the observation is the the reason the the Grafana's (the the dashboards) and the the Prometheus's (the the metrics) are the the Kubernetes's the monitoring's the standard.
  • The ArgoCD and the Flux (the GitOps). The ArgoCD and the Flux are the Kubernetes's the GitOps's tools (the the Git's repositories as the the desired's state's the single's source of the truth, the the reconciliation's: the the tools' the pull's model, the the clusters' the state's the repositories' the state's the match), and the observation: the the GitOps's design is the the Kubernetes's the declarative's model's the extension, and the observation is the the reason the the GitOps's tools are the the Kubernetes's the operations's the modern's standard.
  • The Operators (the application's management). The Operators are the Kubernetes's the applications' the operational's knowledge's the encapsulation (the the custom's resources: the the CRDs; the the controllers: the the reconciliation's loops), and the observation: the the Operators' design is the the Kubernetes's the extensibility's the mechanism, and the observation is the the reason the the Operators (the the Prometheus's Operator, the the PostgreSQL's Operator, the the Kafka's Operator, the the Cert-Manager's) are the the Kubernetes's the complex's applications' the deployment's and the the operations's the standard.

4.10 The orchestration's design's trade-offs

The orchestration's design's trade-offs:

The orchestration's design's trade-offs
The dimension The benefit The cost
The declarative's model The reproducibility, the versioning, the GitOps's, the self-healing's The learning's curve (the manifests, the controllers, the reconciliation's), the the debugging's difficulty (the the indirect's causality)
The scheduling's abstraction The portability (the the same's manifests on the the different's clusters), the the operations's automation The the control's loss (the the scheduling's decisions are the the scheduler's), the the resource's overcommitment's risks (the the requests' and the the limits' configuration)
The pod's abstraction The co-location (the the sidecar's pattern), the the shared's resources, the the atomic's deployment's The the multi-container's pods' complexity (the the sidecars' lifecycle's, the the logs' aggregation's, the the resource's sharing's)
The service's abstraction The stable's identities, the the load's balancing's, the the service's discovery's The the networking's complexity (the the CNI's plugins, the the kube-proxy's modes, the the DNS's), the the debugging's difficulty (the the virtual's IPs, the the iptables's rules)
The cluster's abstraction The scale (the the many's nodes and the the many's pods), the the multi-tenancy's (the the namespaces, the the RBAC) The the cluster's management's complexity (the the control's plane's, the the etcd's, the the nodes'), the the cost's (the the control's plane's resources, the the managed's services' fees)
The ecosystem's diversity The the tools' choice (the the many's implementations), the the standards' (the the CNI's, the the CSI's, the the CRI's, the the SMI's) The the integration's complexity (the the many's tools', the the version's compatibility's), the the decision's fatigue (the the many's choices')

4.11 Common misconceptions

"The Kubernetes is the containers."

The Kubernetes is the orchestration's platform (the cluster's management, the scheduling, the scaling, the healing, the networking, the configuration), and the containers are the workloads (the runtime's units). The Kubernetes manages the containers (the pods), and the containers run the applications. The observation: the Kubernetes is not the container's runtime (the containerd, the CRI-O, the Docker are the runtimes), and the observation is the reason the Kubernetes's clusters use the different's runtimes through the CRI.

"The Kubernetes is the Docker's extension."

The Kubernetes (the Google's, the 2014's) and the Docker (the dotCloud's, the 2013's) are the different's projects. The Kubernetes's design is the descendant of the Google's Borg and Omega, and the Kubernetes supports the different's container's runtimes (the containerd, the CRI-O, the Docker with the dockershim's layer, the deprecated in the Kubernetes 1.24's). The observation: the Kubernetes and the Docker are the complementary (the Docker is the developers' tool, and the Kubernetes is the operators' platform), and the observation is the reason the modern's practices use the Docker for the development and the Kubernetes for the production.

"The pod is the container."

The pod is the Kubernetes's smallest's deployable's unit (the group of the one's or the more's containers that share the network's namespace, the storage's volumes, and the lifecycle), and the container is the runtime's unit (the process's isolation's environment). The observation: the pod can contain the multiple's containers (the sidecar's pattern), and the observation is the reason the Kubernetes's abstractions are the pods, not the containers (the operators manage the pods, and the pods manage the containers).

"The Kubernetes's manifests are the imperative's commands."

The Kubernetes's manifests are the declarative's specifications (the desired's state), and the Kubernetes's controllers (the reconciliation's loops) make the actual's state match the desired's state. The observation: the operators do not issue the imperative's commands (the kubectl run's the container), they declare the desired's state (the kubectl apply -f's the manifest), and the Kubernetes's controllers do the rest. The observation is the reason the Kubernetes's model is the GitOps's foundation.

"The Kubernetes's services are the load's balancers."

The Kubernetes's Services are the stable's network's identities (the virtual's IPs, the DNS's names, the load's balancing across the endpoints), and the load's balancers are the external's components (the cloud's providers' load's balancers: the the AWS's ELB's, the the Azure's Load Balancer's, the the Google's Cloud Load Balancing's). The observation: the Kubernetes's Services are the cluster's internal's networking's abstraction (the the services' discovery's, the the load's balancing's within the cluster), and the observation is the reason the external's access uses the Ingresses (the HTTP and the HTTPS's routing) or the LoadBalancer's Services (the external's load's balancers).

"The Kubernetes's namespaces are the Linux's namespaces."

The Kubernetes's namespaces are the cluster's logical's partitions (the the names' scopes, the the resource's quotas, the the RBAC's scopes, the the network's policies' scopes), and the Linux's namespaces are the kernel's isolation's mechanisms (the the mount's, the the PID's, the the network's, the the user's, the the IPC's, the the UTS's, the the cgroup's, the the time's: the Lesson 13.3's discussion). The observation: the Kubernetes's namespaces are the API's objects (the the logical's partitions), and the Linux's namespaces are the kernel's mechanisms (the the containers' isolation's): the two are the different's concepts with the confusingly's same's name.

"The Kubernetes's clusters are the secure by default."

The Kubernetes's clusters' security depends on the configuration: the defaults are the reasonable but not the secure (the the RBAC's the permissive's default's roles: the the system:basic-user's, the the system:discovery's; the the pods' the default's service's account's tokens' the auto-mounting's; the the no's network's policies' the default's: the the every pod can communicate with the the every pod; the the no's the pod's security's admission's the default's), and the observation: the Kubernetes's clusters' security is the configuration's discipline (the the RBAC's the least's privilege's, the the network's policies', the the pod's security's standards', the the secrets' management's, the the admission's controllers'), and the observation is the reason the the cluster's security's assessment's tools (the the kube-bench's, the the kubesec's, the the Polaris's, the the Kubescape's) are the the Kubernetes's the security's the operations's mechanisms.

"The Kubernetes's the only's orchestration."

The Kubernetes is the orchestration's de facto standard (the the adoption's, the the ecosystem's, the the cloud's providers' managed's services), but the alternatives exist: the the Docker Swarm's (the the simplicity's), the the HashiCorp's Nomad's (the the flexibility's, the the HashiCorp's stack's integration's), the the Apache Mesos's (the the data's center's OS's vision's, the the decline's), the the Amazon's ECS's (the the AWS's native's), and the observation: the the alternatives are the the different's trade-offs (the the simplicity's vs. the the features', the the ecosystem's vs. the the integration's), and the observation is the the reason the the orchestration's choice depends on the the requirements and the the constraints.

05 Worked example

The following example deploys a multi-tier application to a Kubernetes's cluster, demonstrates the declarative's model's reconciliation, and inspects the cluster's state.

Deploying a multi-tier application

The following manifests deploy a web's application (the Nginx's frontend, the Node.js's API, the PostgreSQL's database) to the Kubernetes's cluster:

# The namespace's manifest
cat > 00-namespace.yaml << 'EOF'
apiVersion: v1
kind: Namespace
metadata:
  name: myapp
  labels:
    pod-security.kubernetes.io/enforce: restricted
    pod-security.kubernetes.io/audit: restricted
EOF

# The ConfigMap's manifest
cat > 01-configmap.yaml << 'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
  name: web-config
  namespace: myapp
data:
  nginx.conf: |
    server {
      listen 8080;
      location / {
        proxy_pass http://api:3000;
      }
    }
EOF

# The Secret's manifest
cat > 02-secret.yaml << 'EOF'
apiVersion: v1
kind: Secret
metadata:
  name: db-secrets
  namespace: myapp
type: Opaque
stringData:
  username: myapp
  password: s3cr3t-p4ssw0rd
EOF

# The PostgreSQL's StatefulSet's manifest
cat > 03-postgres.yaml << 'EOF'
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: db
  namespace: myapp
spec:
  serviceName: db
  replicas: 1
  selector:
    matchLabels:
      app: db
  template:
    metadata:
      labels:
        app: db
    spec:
      securityContext:
        fsGroup: 999
        runAsNonRoot: true
        runAsUser: 999
      containers:
        - name: postgres
          image: postgres:16-alpine
          ports:
            - containerPort: 5432
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: db-secrets
                  key: username
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secrets
                  key: password
          volumeMounts:
            - name: data
              mountPath: /var/lib/postgresql/data
          resources:
            requests:
              cpu: 100m
              memory: 256Mi
            limits:
              cpu: 500m
              memory: 1Gi
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
  name: db
  namespace: myapp
spec:
  selector:
    app: db
  ports:
    - port: 5432
      targetPort: 5432
  clusterIP: None
EOF

# The API's Deployment's manifest
cat > 04-api.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
  namespace: myapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      securityContext:
        runAsNonRoot: true
        runAsUser: 1000
        fsGroup: 1000
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: api
          image: node:20-alpine
          command: ["node", "-e", "require('http').createServer((req,res)=>{res.end('Hello from the API!')}).listen(3000)"]
          ports:
            - containerPort: 3000
          env:
            - name: DB_HOST
              value: db
            - name: DB_USER
              valueFrom:
                secretKeyRef:
                  name: db-secrets
                  key: username
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: db-secrets
                  key: password
          resources:
            requests:
              cpu: 100m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 256Mi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: ["ALL"]
          livenessProbe:
            httpGet: { path: /, port: 3000 }
            initialDelaySeconds: 5
          readinessProbe:
            httpGet: { path: /, port: 3000 }
            initialDelaySeconds: 3
---
apiVersion: v1
kind: Service
metadata:
  name: api
  namespace: myapp
spec:
  selector:
    app: api
  ports:
    - port: 3000
      targetPort: 3000
EOF

# The web's Deployment's manifest
cat > 05-web.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: myapp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      securityContext:
        runAsNonRoot: true
        runAsUser: 101
        fsGroup: 101
      containers:
        - name: nginx
          image: nginx:alpine
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: config
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: nginx.conf
              readOnly: true
            - name: cache
              mountPath: /var/cache/nginx
            - name: run
              mountPath: /var/run
          resources:
            requests:
              cpu: 50m
              memory: 64Mi
            limits:
              cpu: 200m
              memory: 128Mi
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities:
              drop: ["ALL"]
              add: ["NET_BIND_SERVICE"]
      volumes:
        - name: config
          configMap:
            name: web-config
        - name: cache
          emptyDir: {}
        - name: run
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: web
  namespace: myapp
spec:
  type: ClusterIP
  selector:
    app: web
  ports:
    - port: 80
      targetPort: 8080
EOF

# The Ingress's manifest
cat > 06-ingress.yaml << 'EOF'
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: web
  namespace: myapp
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
    - host: myapp.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 80
EOF

# The HPA's manifest
cat > 07-hpa.yaml << 'EOF'
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: api
  namespace: myapp
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: api
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70
EOF

# The NetworkPolicy's manifest
cat > 08-networkpolicy.yaml << 'EOF'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny
  namespace: myapp
spec:
  podSelector: {}
  policyTypes:
    - Ingress
    - Egress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-web-to-api
  namespace: myapp
spec:
  podSelector:
    matchLabels:
      app: api
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app: web
      ports:
        - port: 3000
          protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-api-to-db
  namespace: myapp
spec:
  podSelector:
    matchLabels:
      app: db
  policyTypes:
    - Ingress
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app: api
      ports:
        - port: 5432
          protocol: TCP
EOF

# Apply all the manifests
kubectl apply -f 00-namespace.yaml
kubectl apply -f 01-configmap.yaml -f 02-secret.yaml
kubectl apply -f 03-postgres.yaml
kubectl apply -f 04-api.yaml -f 05-web.yaml
kubectl apply -f 06-ingress.yaml -f 07-hpa.yaml -f 08-networkpolicy.yaml

# Watch the deployment's rollout
kubectl rollout status deployment/api -n myapp
kubectl rollout status deployment/web -n myapp
kubectl rollout status statefulset/db -n myapp

The deployment's components: the namespace (the myapp's: the logical's partition with the restricted's pod's security's standard), the ConfigMap (the web-config's: the Nginx's configuration), the Secret (the db-secrets's: the database's credentials), the StatefulSet (the db's: the PostgreSQL's database with the persistent's volume's claim's template), the Deployment (the api's and the web's: the stateless's applications), the Services (the db's headless's, the api's, the web's), the Ingress (the web's: the external's HTTP's routing), the HPA (the api's: the autoscaling's), and the NetworkPolicies (the default-deny's and the specific's allows). The observation: the manifests are the application's complete's definition (the declarative's model), and the observation is the reason the Kubernetes's deployments are the reproducible's and the versionable's.

The declarative's model's demonstration

The following commands demonstrate the declarative's model's reconciliation:

# The pods' state
kubectl get pods -n myapp
kubectl get deployments -n myapp
kubectl get services -n myapp
kubectl get statefulsets -n myapp
kubectl get pvc -n myapp
kubectl get hpa -n myapp
kubectl get networkpolicies -n myapp

# The deployment's details
kubectl describe deployment api -n myapp

# The pods' placement
kubectl get pods -n myapp -o wide

# The self-healing's demonstration: delete a pod
POD=$(kubectl get pods -n myapp -l app=api -o jsonpath='{.items[0].metadata.name}')
kubectl delete pod $POD -n myapp

# The ReplicaSet's controller's reaction (the new pod's creation)
sleep 2
kubectl get pods -n myapp -l app=api

# The scaling's demonstration: scale the deployment
kubectl scale deployment/api -n myapp --replicas=5
kubectl get pods -n myapp -l app=api

# The rolling's update's demonstration: update the image
kubectl set image deployment/api -n myapp api=node:20-alpine
kubectl rollout status deployment/api -n myapp
kubectl rollout history deployment/api -n myapp

# The rollback's demonstration
kubectl rollout undo deployment/api -n myapp
kubectl rollout status deployment/api -n myapp

# The HPA's state
kubectl get hpa api -n myapp
kubectl describe hpa api -n myapp

# The service's endpoints
kubectl get endpoints -n myapp

# The events
kubectl get events -n myapp --sort-by='.lastTimestamp' | tail -20

The demonstrations' observations: the self-healing (the pod's deletion triggers the ReplicaSet's controller's creation of the new pod), the scaling (the kubectl scale's command adjusts the replicas' count, and the ReplicaSet's controller creates the new pods), the rolling's update (the image's change triggers the Deployment's controller's creation of the new ReplicaSet and the gradual's replacement of the pods), the rollback (the kubectl rollout undo's command reverts to the previous's ReplicaSet), and the HPA (the HorizontalPodAutoscaler adjusts the replicas' count based on the CPU's utilization). The observation: the Kubernetes's declarative's model's reconciliation is the cluster's central's mechanism, and the observation is the reason the operators declare the desired's state and let the controllers do the rest.

The cluster's inspection

The following commands inspect the cluster's architecture and its components:

# The cluster's info
kubectl cluster-info
kubectl version
kubectl config current-context
kubectl config get-contexts

# The nodes
kubectl get nodes
kubectl describe nodes | head -60

# The control's plane's components
kubectl get pods -n kube-system
kubectl get pods -n kube-system -l component=kube-apiserver

# The API's resources
kubectl api-resources | head -40
kubectl api-versions | head -20

# The cluster's capacity
kubectl top nodes
kubectl top pods -n myapp

# The namespaces
kubectl get namespaces

# The RBAC's objects
kubectl get roles,rolebindings -A | head -20
kubectl get clusterroles,clusterrolebindings | head -10
kubectl auth can-i --list -n myapp

# The service's accounts
kubectl get serviceaccounts -n myapp

# The CRDs (if any operators are installed)
kubectl get crds | head -20

# The events
kubectl get events -A --sort-by='.lastTimestamp' | tail -20

The cluster's inspection's findings: the control's plane's components (the kube-system's namespace: the API's server, the etcd, the scheduler, the controller's manager, the CoreDNS, the kube-proxy's daemonset), the nodes (the worker's nodes: the kubelet's, the kube-proxy's, the CNI's), the RBAC's objects (the roles' and the role's bindings' the many's defaults: the system:basic-user's, the system:discovery's, the admin's, the edit's, the view's), and the observation: the cluster's architecture's inspection is the operations's first step, and the observation is the reason the kubectl's commands (the get's, the describe's, the logs's, the exec's, the events's) are the operators' standard's tools.

The application's debugging

The following commands demonstrate the application's debugging in the Kubernetes:

# The pod's state and the events
kubectl get pods -n myapp
kubectl describe pod -l app=api -n myapp | head -40

# The pod's logs
kubectl logs -l app=api -n myapp --tail=20

# The pod's exec (the command inside the container)
POD=$(kubectl get pods -n myapp -l app=api -o jsonpath='{.items[0].metadata.name}')
kubectl exec -it $POD -n myapp -- sh

# The pod's port's forwarding
kubectl port-forward -n myapp deployment/api 3000:3000 &
sleep 2
curl http://localhost:3000/
kill %1

# The pod's debug (the ephemeral container)
kubectl debug -it $POD -n myapp --image=busybox --target=api

# The service's connectivity's test
kubectl run test --rm -it --image=busybox -n myapp --restart=Never -- sh -c "
    wget -q -O - http://api:3000/ && echo 'The API is reachable'
    nslookup api.myapp.svc.cluster.local
    nslookup web.myapp.svc.cluster.local
"

# The DNS's resolution's test
kubectl run dns-test --rm -it --image=busybox -n myapp --restart=Never -- \
    nslookup db.myapp.svc.cluster.local

The debugging's findings: the pod's state and the events (the describe's output: the pod's conditions, the events, the containers' states), the pod's logs (the logs's output: the application's stdout and stderr), the pod's exec (the exec's command: the shell inside the container), the pod's port's forwarding (the port-forward's command: the local's access to the pod's port), the pod's debug (the ephemeral container: the debugging's container with the debug's command), the service's connectivity's test (the wget's and the nslookup's commands), and the DNS's resolution's test (the CoreDNS's resolution: the services' names). The observation: the Kubernetes's debugging's tools (the kubectl's commands: the get's, the describe's, the logs's, the exec's, the debug's, the port-forward's, the events's) are the operators' standard's mechanisms.

The cluster's operations's inspection

The following commands inspect the cluster's operations's concerns:

# The cluster's resource's usage
kubectl top nodes
kubectl top pods -A --sort-by=cpu | head -10
kubectl top pods -A --sort-by=memory | head -10

# The resource's requests and the limits
kubectl describe nodes | grep -A5 'Allocated resources'

# The capacity's and the allocatable's resources
kubectl get nodes -o json | \
    python3 -c "
import sys, json
data = json.load(sys.stdin)
for node in data['items']:
    print(f\"The node: {node['metadata']['name']}\")
    print(f\"  The capacity: {node['status']['capacity']}\")
    print(f\"  The allocatable: {node['status']['allocatable']}\")
"

# The persistent's volumes
kubectl get pv,pvc -A
kubectl get storageclasses

# The HPA's state
kubectl get hpa -A
kubectl describe hpa -n myapp

# The deployments' and the statefulsets' status
kubectl get deployments -A
kubectl get statefulsets -A
kubectl get daemonsets -A

# The services' and the ingresses' state
kubectl get services -A
kubectl get ingresses -A

# The secrets' state
kubectl get secrets -A

# The cluster's version and the upgrades
kubectl version --short
kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.nodeInfo.kubeletVersion}{"\n"}{end}'

The operations's inspection's findings: the cluster's resource's usage (the top's commands: the nodes' and the pods' CPU and memory's usage), the resource's requests and the limits (the describe nodes's output: the allocated's resources vs. the allocatable), the persistent's volumes (the PVs, the PVCs, the storageclasses), the HPA's state (the current's replicas, the target's metrics), the deployments' and the statefulsets' status (the desired's vs. the actual's replicas), the services' and the ingresses' state, the secrets' state, and the cluster's version (the nodes' kubelet's versions). The observation: the cluster's operations' inspection is the operators' ongoing's activity, and the observation is the reason the kubectl's commands, the Prometheus's, the Grafana's, the Loki's, and the Kubecost's tools are the operators' standard's mechanisms.

06 Interactive activity

Activity · explore the container orchestration on a live system

The goal of this activity is to use the Kubernetes's CLI to deploy an application, to demonstrate the declarative's model's reconciliation, to inspect the cluster's state, and to debug the application. Work through the steps in your course VM. Note: the activity requires a Kubernetes's cluster (the minikube's, the kind's, the k3s's, the k3d's, or the Docker Desktop's Kubernetes), and the kubectl's CLI.

  1. Set up a local's Kubernetes's cluster. Install and start a local's cluster (the minikube's, the kind's, the k3s's, or the k3d's).
    # Check the tools
    which kubectl minikube kind k3s k3d 2>/dev/null
    
    # Install minikube (if necessary)
    curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    sudo install minikube-linux-amd64 /usr/local/bin/minikube
    
    # Install kubectl (if necessary)
    curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
    
    # Start minikube
    minikube start --cpus=2 --memory=4096 --driver=docker 2>/dev/null
    
    # Verify the cluster
    kubectl cluster-info
    kubectl get nodes
    kubectl version --short
    kubectl config current-context
    
    # The cluster's add-ons
    minikube addons list 2>/dev/null | head -20
    Did the cluster start? How many nodes are there? What are the kubectl's and the cluster's versions? Write down what you find.
  2. Explore the cluster's architecture. Inspect the cluster's components and their state.
    # The control's plane's components
    kubectl get pods -n kube-system
    kubectl describe pods -n kube-system -l component=kube-apiserver | head -30
    
    # The nodes
    kubectl get nodes -o wide
    kubectl describe nodes | head -60
    
    # The API's resources
    kubectl api-resources | head -40
    kubectl api-versions | head -20
    
    # The cluster's capacity
    kubectl top nodes 2>/dev/null
    kubectl get --raw='/healthz' 2>/dev/null
    kubectl get --raw='/readyz?verbose' 2>/dev/null | head -10
    
    # The cluster's namespaces
    kubectl get namespaces
    kubectl get all -A | head -30
    What are the control's plane's components? What are the nodes' roles? What are the API's resources? Write down what you find.
  3. Deploy a simple's application. Create and deploy a simple's application with the declarative's manifests.
    # Create the application's directory
    mkdir -p /tmp/k8s-demo
    cd /tmp/k8s-demo
    
    # The namespace's manifest
    cat > 00-namespace.yaml << 'EOF'
    apiVersion: v1
    kind: Namespace
    metadata:
      name: demo
    EOF
    
    # The Deployment's manifest
    cat > 01-deployment.yaml << 'EOF'
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: web
      namespace: demo
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: web
      template:
        metadata:
          labels:
            app: web
        spec:
          containers:
            - name: web
              image: nginx:alpine
              ports:
                - containerPort: 80
              resources:
                requests:
                  cpu: 50m
                  memory: 64Mi
                limits:
                  cpu: 200m
                  memory: 128Mi
    EOF
    
    # The Service's manifest
    cat > 02-service.yaml << 'EOF'
    apiVersion: v1
    kind: Service
    metadata:
      name: web
      namespace: demo
    spec:
      type: ClusterIP
      selector:
        app: web
      ports:
        - port: 80
          targetPort: 80
    EOF
    
    # Apply the manifests
    kubectl apply -f 00-namespace.yaml
    kubectl apply -f 01-deployment.yaml -f 02-service.yaml
    
    # The deployment's state
    kubectl get pods -n demo
    kubectl get deployments -n demo
    kubectl get services -n demo
    kubectl rollout status deployment/web -n demo
    
    # The pods' details
    kubectl describe deployment web -n demo
    kubectl get pods -n demo -o wide
    Did the deployment succeed? How many pods are running? What is the service's ClusterIP's address? Write down what you find.
  4. Demonstrate the declarative's model. Demonstrate the self-healing, the scaling, and the rolling's updates.
    # The self-healing's demonstration
    POD=$(kubectl get pods -n demo -l app=web -o jsonpath='{.items[0].metadata.name}')
    echo "Deleting pod: $POD"
    kubectl delete pod $POD -n demo
    sleep 3
    kubectl get pods -n demo -l app=web
    
    # The scaling's demonstration
    kubectl scale deployment/web -n demo --replicas=4
    kubectl get pods -n demo -l app=web
    sleep 5
    kubectl get deployments -n demo
    
    # The rolling's update's demonstration
    kubectl set image deployment/web -n demo web=nginx:1.25-alpine
    kubectl rollout status deployment/web -n demo
    kubectl rollout history deployment/web -n demo
    
    # The rollback's demonstration
    kubectl rollout undo deployment/web -n demo
    kubectl rollout status deployment/web -n demo
    
    # The declarative's reconciliation's observation
    kubectl get replicasets -n demo
    kubectl describe deployment web -n demo | grep -A10 'OldReplicaSets\|NewReplicaSet'
    What happens when a pod is deleted? What happens when the deployment is scaled? What happens during the rolling's update? Write down your observations.
  5. Explore the networking. Inspect the cluster's networking and the services' discovery.
    # The service's endpoints
    kubectl get endpoints web -n demo
    kubectl describe service web -n demo
    
    # The DNS's resolution's test
    kubectl run dns-test --rm -it --image=busybox:latest -n demo \
        --restart=Never -- sh -c "
            echo 'The DNS:'
            nslookup web.demo.svc.cluster.local
            echo 'The service:'
            wget -q -O - http://web.demo.svc.cluster.local/
        "
    
    # The network's inspection (with the pod's exec)
    POD=$(kubectl get pods -n demo -l app=web -o jsonpath='{.items[0].metadata.name}')
    kubectl exec $POD -n demo -- ip addr 2>/dev/null
    kubectl exec $POD -n demo -- ip route 2>/dev/null
    
    # The port's forwarding
    kubectl port-forward -n demo service/web 8080:80 &
    sleep 2
    curl http://localhost:8080/ 2>/dev/null | head -3
    kill %1 2>/dev/null
    
    # The services' cluster IPs
    kubectl get services -n demo -o wide
    What are the service's endpoints? Does the DNS's resolution work? Does the connectivity's test work? Write down what you find.
  6. Debug an application. Demonstrate the Kubernetes's debugging's tools.
    # The pod's events
    kubectl describe pod -l app=web -n demo | tail -20
    
    # The pod's logs
    kubectl logs -l app=web -n demo --tail=20
    
    # The pod's exec
    POD=$(kubectl get pods -n demo -l app=web -o jsonpath='{.items[0].metadata.name}')
    kubectl exec -it $POD -n demo -- sh
    
    # Inside the container:
    # ls /
    # cat /etc/os-release
    # ps aux
    # exit
    
    # The pod's debug (an ephemeral container)
    kubectl debug -it $POD -n demo --image=busybox:latest --target=web
    
    # The cluster's events
    kubectl get events -n demo --sort-by='.lastTimestamp'
    
    # The Kubernetes's API's inspection
    kubectl explain deployment.spec.strategy
    kubectl explain pod.spec.containers.resources
    What are the pod's events? What does the pod's log show? Did the exec and the debug work? Write down what you find.
  7. Explore the Kubernetes's objects. Explore the Kubernetes's objects and their relationships.
    # The objects' hierarchy
    kubectl get deployments,replicasets,pods -n demo
    kubectl get services,endpoints -n demo
    
    # The object's YAML's inspection
    kubectl get deployment web -n demo -o yaml | head -50
    kubectl get pod -l app=web -n demo -o yaml | head -50
    
    # The object's status's inspection
    kubectl get deployment web -n demo -o jsonpath='{.status}'
    kubectl get pod -l app=web -n demo -o jsonpath='{.items[0].status.conditions}'
    
    # The objects' labels
    kubectl get pods -n demo --show-labels
    kubectl get deployment web -n demo -o jsonpath='{.metadata.labels}'
    
    # The owner's references
    kubectl get pods -n demo -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.ownerReferences[0].kind}/{.metadata.ownerReferences[0].name}{"\n"}{end}'
    
    # The RBAC's objects
    kubectl auth can-i --list -n demo
    kubectl get rolebindings,roles -n demo
    What are the objects' hierarchy and the owner's references? How do the objects relate to one another? Write down what you find.
  8. Read the man pages. Read the man pages that document the Kubernetes's interfaces.
    man 1 kubectl
    man 1 kubectl-apply
    man 1 kubectl-get
    man 1 kubectl-describe
    man 1 kubectl-logs
    man 1 kubectl-exec
    man 1 kubectl-rollout
    man 1 kubectl-scale
    man 1 kubectl-port-forward
    man 1 minikube
    man 1 kind
    man 1 k3s
    man 1 helm
    man 1 k9s
    man 1 stern
    man 1 kubectx
    man 1 kubens
    For each, write a sentence describing its main contribution to your understanding of the Kubernetes. The man 1 kubectl page documents the Kubernetes's CLI; the man 1 kubectl-apply page documents the declarative's commands; the man 1 helm page documents the Helm's package's manager.

Reflect: the container orchestration is the layer that turns the individual containers into the production's workloads, and the Kubernetes is the orchestration's standard. The Kubernetes's declarative's model (the desired's state, the reconciliation's loops) is the design's central's idea, and the observation is the reason the Kubernetes's model is the GitOps's foundation. Which of the orchestration's concerns (the scheduling, the scaling, the self-healing, the service's discovery, the rolling's updates, the configuration's management, the storage's management, the observability) is the most important for the modern's workloads, and why? What would you change about the Kubernetes's design if you could? How would you explain the declarative's model to someone who has never thought about it? What is the right balance between the Kubernetes's complexity and the operators' simplicity?

07 Knowledge check

Check your understanding

Question 1

Define the container orchestration and explain its concerns (the scheduling, the scaling, the self-healing, the service's discovery, the rolling's updates, the configuration's management, the storage's management, the observability). Why is the orchestration the layer that turns the containers into the production's workloads?

Show answer
The container orchestration is the automated's management of the containers' lifecycle, the placement, the networking, the storage, and the configuration across the clusters of the many's hosts. The orchestration's purpose: the containers' management at scale (the many's hosts, the many's containers, the many's applications), with the automated's operations and the declarative's model. The orchestration's concerns: the scheduling (the orchestrator decides which host runs which container: the resources' requests, the hosts' available's resources, the constraints (the affinity, the anti-affinity, the taints and the tolerations), the policies (the spread, the bin-packing, the topology's awareness)); the scaling (the orchestrator adjusts the containers' count (the horizontal's scaling: the replicas' count) and the containers' resources (the vertical's scaling: the CPU's and the memory's requests and limits) based on the demand: the metrics (the CPU's usage, the custom's metrics), the schedules, the events); the self-healing (the orchestrator detects the containers' failures and restarts or replaces the failed's containers: the desired's state is the specification, and the controllers' reconciliation's loops make the actual's state match the desired's state); the service's discovery (the orchestrator provides the containers' the network's identities: the services' names, the DNS's names, the virtual's IPs, the load's balancing, the endpoints' management); the rolling's updates (the orchestrator updates the applications without the downtime: the rolling's updates, the blue-green's deployments, the canary's releases, the rollbacks); the configuration's management (the orchestrator manages the applications' configuration: the ConfigMaps, the Secrets, the external's secret's stores); the storage's management (the orchestrator manages the containers' persistent's storage: the volumes, the PersistentVolumes, the PersistentVolumeClaims, the StorageClasses, the CSI's drivers); and the observability (the orchestrator provides the containers' and the applications' observability: the logs, the metrics, the traces, the events). The orchestration is the layer that turns the containers into the production's workloads because the containers alone are the single's host's units (the Docker's design's scope: the docker run's command, the Compose's multi-container's applications on the one host), and the production's workloads require the many's hosts' management (the clusters), the automated's operations (the scheduling, the scaling, the healing, the networking, the updates), and the declarative's model (the operators declare the desired's state, and the orchestrator makes the actual's state match the desired's state). The observation: the orchestration is the containers' production's layer, and the observation is the reason the modern's organizations use the orchestration's platforms (the Kubernetes's, the Docker Swarm's, the Nomad's) for the containers' production's deployments.

Question 2

Describe the Kubernetes's architecture (the control's plane, the worker's nodes, the API's server, the etcd, the scheduler, the controller's manager, the cloud's controller's manager, the kubelet, the kube-proxy, the CRI, the CNI, the CSI). What is each component's role, and how do the components interact?

Show answer
The Kubernetes's architecture is the cluster's design: the control's plane (the cluster's management's components) and the worker's nodes (the containers' hosts). The control's plane's components: the API's server (kube-apiserver: the cluster's central's component: the REST's API's server that the kubectl's commands, the controllers, the kubelets, and the other's components use; the roles: the authentication, the authorization (the RBAC, the ABAC, the webhooks), the admission (the validating's and the mutating's webhooks, the policies), the validation, and the persistence (the etcd's storage)); the etcd (the cluster's key-value's store: the distributed's, the consistent's (the Raft's consensus's protocol) store that holds the cluster's state: the objects, the watch's mechanism, the cluster's consistency); the scheduler (kube-scheduler: the component that assigns the pods to the nodes: the filtering (the predicates: the resources' availability, the affinity, the taints, the volumes), the scoring (the priorities: the spread, the bin-packing, the topology's awareness), the binding (the selected's node's assignment)); the controller's manager (kube-controller-manager: the component that runs the cluster's controllers: the Deployment's, the ReplicaSet's, the StatefulSet's, the DaemonSet's, the Job's, the CronJob's, the Node's, the Service's, the Endpoints's controllers, and the others: the reconciliation's loops); and the cloud's controller's manager (cloud-controller-manager: the component that integrates the cluster with the cloud's providers' APIs: the node's, the route's, the service's, the volume's controllers). The worker's nodes's components: the kubelet (kubelet: the node's agent: the component that runs on the every's worker's node, and it manages the node's pods (the pods' lifecycle, the containers' health: the liveness's, the readiness's, the startup's probes), the volumes' mounting, the CRI's interface, the node's status's reporting); the kube-proxy (kube-proxy: the node's network's proxy: the component that implements the Kubernetes's services' load's balancing on the node (the iptables's, the IPVS's, the eBPF's), and it forwards the traffic to the services' endpoints); the container's runtime (the CRI's implementation: the containerd, the CRI-O, the Docker with the dockershim's layer: the component that creates and runs the containers, and it communicates with the kubelet through the CRI: the Container Runtime Interface); the CNI's plugins (the Container Network Interface: the standard for the containers' network's configuration, and the plugins: the Calico's, the Cilium's, the Flannel's, the Weave's, the Antrea's, the Kube-router's); and the CSI's drivers (the Container Storage Interface: the standard for the containers' storage's provisioning and mounting, and the drivers: the cloud's providers' (the AWS's EBS's, the Azure's Disk's, the Google's PD's), the on-premises's (the Ceph's, the NetApp's, the Pure's), the NFS's, the local's). The components' interaction: the kubectl's commands send the requests to the API's server (the REST's API); the API's server persists the objects in the etcd; the controllers (the controller's manager's) watch the API's server for the objects and reconcile the actual's state with the desired's state; the scheduler watches the API's server for the unscheduled's pods and assigns them to the nodes; the kubelet (the node's agent) watches the API's server for the pods assigned to its node, and it creates the containers (through the CRI), mounts the volumes (through the CSI), and reports the node's status; the kube-proxy (the node's network's proxy) watches the API's server for the services and the endpoints, and it configures the node's networking (the iptables's, the IPVS's, the eBPF's). The observation: the Kubernetes's architecture is the declarative's model's implementation (the API's server is the cluster's single's source of the truth, the controllers are the reconciliation's loops, the scheduler is the placement's component, and the kubelet is the node's agent), and the observation is the reason the Kubernetes's design is the components' collection rather than the single's program.

Question 3

Describe the Kubernetes's objects (the pods, the Deployments, the ReplicaSets, the Services, the Ingresses, the ConfigMaps, the Secrets, the StatefulSets, the DaemonSets, the Jobs, the CronJobs, the namespaces, the RBAC, the network's policies). What is each object's purpose, and how do the objects relate to one another?

Show answer
The Kubernetes's objects: the pod (the smallest's deployable's unit: the group of the one's or the more's containers that share the network's namespace, the storage's volumes, and the lifecycle: the sidecar's pattern); the Deployment (the stateless's applications' controller: the ReplicaSets' and the pods' management: the replicas, the selector, the template, the strategy (the RollingUpdate's or the Recreate's), the revision's history: the rolling's updates and the rollbacks); the ReplicaSet (the pods' count's controller: the specified's number of the pods is the running: the Deployment's implementation's detail); the Service (the stable's network's identity: the virtual's IP and the DNS's name for the pods' group, the load's balancing across the endpoints: the types: the ClusterIP's, the NodePort's, the LoadBalancer's, the ExternalName's); the Ingress (the external's HTTP and HTTPS's routing: the host's and the path's routing, the TLS's termination, the Ingress's controllers: the Nginx's, the Traefik's, the HAProxy's, the Envoy's); the ConfigMap (the non-sensitive's configuration: the key-value's pairs: the configuration's files, the environment's variables, the command's arguments); the Secret (the sensitive's data: the passwords, the tokens, the certificates, the keys: the base64's storage in the etcd, the encryption at rest's option); the StatefulSet (the stateful's applications' controller: the stable's identities (the pods' names: the myapp-0's, the myapp-1's), the stable's storage (the PersistentVolumeClaims's templates), the ordered's deployment); the DaemonSet (the every node's pod's controller: the logs' collectors, the monitoring's agents, the network's plugins, the storage's drivers, the security's agents); the Job (the batch's workloads' controller: the pods to the completion: the completions's, the parallelism's, the backoffLimit's fields); the CronJob (the scheduled's jobs' controller: the schedule's field, the concurrencyPolicy's field); the namespace (the cluster's logical's partition: the names' scopes, the resource's quotas, the limit's ranges, the RBAC's scopes, the network's policies' scopes); the RBAC (the authorization's mechanism: the Role's and the ClusterRole's objects: the permissions' rules; the RoleBinding's and the ClusterRoleBinding's objects: the subjects' and the roles' bindings); and the network's policy (the pods' traffic's rules: the allowed's ingress and egress's traffic: the pod's selectors, the namespace's selectors, the IP's blocks, the ports). The objects' relationships: the namespace contains the objects (the names' scope, the RBAC's scope); the Deployment manages the ReplicaSets, which manage the pods; the StatefulSet manages the pods with the stable's identities and the PersistentVolumeClaims; the DaemonSet manages the pods on the every node; the Service selects the pods (the labels) and provides the stable's network's identity; the Ingress routes the external's traffic to the Services; the pods consume the ConfigMaps and the Secrets (the volumes' or the environment's variables' injection); the RBAC controls the access to the objects; and the network's policies control the traffic between the pods. The observation: the objects are the Kubernetes's declarative's model's vocabulary, and the observation is the reason the operators declare the objects (the manifests) and the controllers make the actual's state match.

Question 4

Describe the Kubernetes's declarative's model (the desired's state, the reconciliation's loops, the manifests, the kubectl's commands) and the Kubernetes's scheduling's and the networking's mechanisms. What is the declarative's model's significance, and how does the GitOps's model extend it?

Show answer
The Kubernetes's declarative's model is the design's central's idea: the operators declare the desired's state (the manifests: the YAML's or the JSON's files), and the Kubernetes's controllers (the reconciliation's loops) make the actual's state match the desired's state. The model's components: the manifests (the declarative's specifications: the apiVersion's, the kind's, the metadata's, the spec's sections; the observation: the manifests are the applications' definitions (the infrastructure's as the code), and the observation is the reason the manifests are the versioned in the Git's repositories); the kubectl's commands (the imperative's commands: the run's, the create's, the delete's, the scale's, the expose's: the ad-hoc's operations; the declarative's commands: the apply -f's, the diff's, the delete -f's, the kustomize's: the manifests' operations); and the reconciliation's loops (the controllers' mechanism: the every's controller watches the API's server's objects (the watch's mechanism: the etcd's events), and it compares the actual's state (the cluster's resources) with the desired's state (the objects' specifications), and it performs the actions (the objects' creation, the objects' deletion, the objects' updates) to make the actual's state match the desired's state). The Kubernetes's scheduling: the scheduler assigns the pods to the nodes, and its mechanisms: the resource's requests and limits (the pods' containers declare the resource's requests: the scheduler uses the requests to select the nodes; and the limits: the kubelet enforces the limits), the node's selection's rules (the nodeSelector's field, the nodeName's field, the affinity: the nodeAffinity's, the podAffinity's, the podAntiAffinity's; the taints and the tolerations), the scheduler's policies (the filtering: the predicates; the scoring: the priorities; the binding), and the scheduler's profiles. The Kubernetes's networking: the cluster's network's model (the CNI's specification: the every pod has its own's IP address, the the pods can communicate with the the other's pods across the nodes without the NAT's), the CNI's plugins (the Calico's, the Cilium's, the Flannel's, the Weave's, the Antrea's, the Kube-router's), the services' networking (the ClusterIP's, the NodePort's, the LoadBalancer's; the kube-proxy's modes: the iptables's, the IPVS's, the eBPF's), and the DNS's resolution (the CoreDNS: the <service>.<namespace>.svc.cluster.local's names). The declarative's model's significance: the model is the Kubernetes's design's central's idea (the operators do not issue the imperative's commands, they declare the desired's state, and the Kubernetes's controllers do the rest), and the observation is the reason the Kubernetes's model is the GitOps's foundation: the manifests are the versioned in the Git's repositories (the desired's state's single's source of the truth), and the GitOps's tools (the ArgoCD's, the Flux's) watch the repositories and reconcile the clusters' state with the repositories' state. The GitOps's model's extension: the CI/CD's pipelines build the images and update the manifests in the Git's repositories, and the GitOps's tools (the pull's model: the tools pull the manifests from the Git) reconcile the clusters (the observation: the GitOps's model is the declarative's model's extension, and the observation is the reason the GitOps's tools are the modern's Kubernetes's operations's standard).

Question 5

Describe the orchestration's alternatives (the Docker Swarm, the HashiCorp's Nomad, the Apache Mesos, the cloud's providers' services), the orchestration's security (the cluster's layers, the API's server's security, the pod's security, the network's security, the supply chain's security, the runtime's security), and the orchestration's ecosystem (the Helm, the Kustomize, the Istio, the Prometheus, the ArgoCD, the Operators). What are the trade-offs?

Show answer
The orchestration's alternatives: the Docker Swarm (the Docker's native's orchestration: the swarm, the services, the nodes, the overlay's networks, the secrets, the configs, the stacks; the advantages: the simplicity (the Docker's CLI and the Compose's files), the integration (the Docker's ecosystem), the learning's curve; the disadvantages: the fewer's features, the smaller's ecosystem, the Kubernetes's dominance); the HashiCorp's Nomad (the HashiCorp's orchestration: the servers, the clients, the jobs, the allocations; the advantages: the simplicity (the single's binary, the simple's configuration), the flexibility (the multiple's workloads: the containers, the VMs, the binaries), the integration (the HashiCorp's stack: the Consul, the Vault, the Terraform), the scale; the disadvantages: the smaller's ecosystem, the adoption); the Apache Mesos (the Apache's cluster's manager: the master's nodes, the agent's nodes, the frameworks, the offers; the advantages: the scale, the flexibility, the maturity; the disadvantages: the complexity, the decline); and the cloud's providers' services (the Amazon's ECS's and EKS's, the Google's GKE's, the Microsoft's AKS's, the Alibaba's ACK's, the DigitalOcean's DOKS's: the managed's orchestration: the control's plane's management's outsourcing: the upgrades, the scaling, the monitoring). The orchestration's security: the cluster's layers (the cloud's infrastructure's security, the cluster's security, the node's security, the pod's security, the application's security); the API's server's security (the authentication: the client's certificates, the bearer's tokens, the OIDC's, the webhook's, the service's accounts' tokens; the authorization: the RBAC's, the ABAC's, the webhook's, the node's authorizer; the admission's controllers: the validating's and the mutating's: the PodSecurity's, the ResourceQuota's, the LimitRanger's, the NetworkPolicy's, the custom's webhooks; the audit's logging); the pod's security (the security's context: the runAsUser's, the runAsNonRoot's, the readOnlyRootFilesystem's, the allowPrivilegeEscalation's, the capabilities's, the seccompProfile's, the appArmorProfile's, the seLinuxOptions's; the Pod Security's Standards: the privileged's, the baseline's, the restricted's levels; the Pod Security's Admission); the network's security (the network's policies, the service's mesh's security: the mTLS's, the authorization's policies, the traffic's encryption); the supply chain's security (the images' scanning, the images' signing, the images' attestation, the SBOM's, the admission's controllers); and the runtime's security (the Falco's, the Tetragon's, the Sysdig's, the Aqua's, the StackRox's). The orchestration's ecosystem: the Helm (the package's manager: the charts, the releases, the repositories: the templating's, the versioning's, the rollbacks'); the Kustomize (the configuration's management: the base's manifests and the overlays: the environment's specific's customizations); the Istio (the service's mesh: the traffic's management, the security's, the observability's); the Prometheus (the monitoring: the metrics' collection, the PromQL, the Alertmanager); the ArgoCD and the Flux (the GitOps's tools: the Git's repositories as the desired's state's source of the truth); and the Operators (the applications' operational's knowledge's encapsulation: the CRDs, the controllers). The trade-offs: the declarative's model (the reproducibility, the versioning, the GitOps's, the self-healing's vs. the learning's curve, the debugging's difficulty); the scheduling's abstraction (the portability, the operations's automation vs. the control's loss, the resource's overcommitment's risks); the pod's abstraction (the co-location, the shared's resources vs. the multi-container's pods' complexity); the service's abstraction (the stable's identities, the load's balancing's, the service's discovery's vs. the networking's complexity, the debugging's difficulty); the cluster's abstraction (the scale, the multi-tenancy's vs. the cluster's management's complexity, the cost's); and the ecosystem's diversity (the tools' choice, the standards' vs. the integration's complexity, the decision's fatigue).

08 Unit discussion

Discussion prompt

The container orchestration is the layer that turns the individual containers into the production's workloads, and its history is the history of the containers' scale's evolution. The classical's orchestration (the Google's Borg's in the 2000s and the Omega's in the 2010s) was the search's response to the Google's scale (the many's machines, the many's jobs), and the Kubernetes's release (the 2014's) was the Borg's design's open-source's version. The Kubernetes's design (the declarative's model, the pods, the labels, the controllers, the API's server) was the synthesis of the Borg's and the Omega's lessons, and the Kubernetes's adoption (the cloud's providers' managed's services, the enterprises' on-premises's clusters, the developers' local's clusters) made it the orchestration's de facto standard. Each stage was the response to the previous stage's limitations, and each was shaped by the technology and the workloads of its time.

The trend is toward the declarative's model and the GitOps's. The classical's operations was the imperative's (the operators issued the commands: the docker run's, the kubectl run's), and the modern's operations is the declarative's (the operators declare the desired's state, and the controllers reconcile the actual's state). The GitOps's model extends the declarative's model: the manifests are the versioned in the Git's repositories, and the GitOps's tools (the ArgoCD's, the Flux's) watch the repositories and reconcile the clusters' state. The observation: the trend is the infrastructure's as the code's extension (the applications' definitions are the versioned, the reviewable, the reproducible), and the observation is the reason the modern's Kubernetes's operations use the GitOps's tools and the CI/CD's pipelines.

The trend also raises a question about the complexity and the abstraction's balance. The Kubernetes's power (the declarative's model, the many's objects, the ecosystem's tools) comes with the complexity (the learning's curve, the many's components, the debugging's difficulty), and the observation is the reason the managed's services (the EKS's, the GKE's, the AKS's) and the abstraction's tools (the Helm's, the Kustomize's, the Crossplane's, the Radius's) are the modern's Kubernetes's ecosystem's central's concerns. The observation: the Kubernetes's complexity and the operators' simplicity are the two sides of the orchestration's design, and the observation is the reason the modern's platforms (the serverless's, the PaaS's, the managed's Kubernetes's) provide the abstraction's layers (the developers declare the applications, and the platforms manage the Kubernetes's complexity).

Which of the orchestration's concerns (the scheduling, the scaling, the self-healing, the service's discovery, the rolling's updates, the configuration's management, the storage's management, the observability) is the most important for the modern's workloads, and why? Should the orchestration's design prioritize the declarative's model (the Kubernetes's power) or the operators' simplicity (the managed's services, the abstraction's tools)? What is the right balance between the Kubernetes's features and the operators' learning's curve? How should the orchestration's design evolve for the serverless's platforms, the edge's computing, and the AI's workloads? Post your response to the Unit 13 discussion forum and reply to at least two classmates. Supports CLO1, CLO7, and CLO8.

09 Practice exercise

This ungraded exercise consolidates the lesson and prepares you for Lesson 13.6. Aim to spend 60–90 minutes on it.

  1. Compare the orchestration's platforms. Write a short essay (400–500 words) comparing the orchestration's platforms (the Kubernetes, the Docker Swarm, the HashiCorp's Nomad, the Apache Mesos, the cloud's providers' services). Your essay should address:
    • Each platform's architecture (the control's plane, the worker's nodes, the objects).
    • Each platform's features (the scheduling, the scaling, the self-healing, the networking, the storage, the security).
    • Each platform's ecosystem.
    • Each platform's advantages and disadvantages.
    • Each platform's appropriate environments.
    Conclude with a recommendation for a small's team and for a large's enterprise.
  2. Design a Kubernetes's application. A team is deploying a multi-tier application (the web's frontend, the API's backend, the database, the cache, the message's queue). Design the Kubernetes's manifests:
    • The namespace (the environment's separation, the pod's security's standard's label).
    • The ConfigMaps and the Secrets (the configuration and the credentials).
    • The Deployments (the stateless's services: the web, the API; the replicas, the resources, the probes, the security's context).
    • The StatefulSets (the stateful's services: the database, the cache, the message's queue; the stable's identities, the storage's templates).
    • The Services (the stable's identities, the load's balancing).
    • The Ingress (the external's HTTP's routing, the TLS's termination).
    • The HPAs (the autoscaling's).
    • The NetworkPolicies (the segmentation's rules).
    • The PodDisruptionBudgets (the availability's guarantees).
    Justify your design through the lesson's principles.
  3. Deploy an application to a Kubernetes's cluster. On your VM, deploy an application to a local's Kubernetes's cluster:
    # Start the cluster
    minikube start --cpus=2 --memory=4096 2>/dev/null
    
    # Deploy the application (from the practice's manifests)
    kubectl apply -f 00-namespace.yaml
    kubectl apply -f 01-configmap.yaml -f 02-secret.yaml
    kubectl apply -f 03-postgres.yaml
    kubectl apply -f 04-api.yaml -f 05-web.yaml
    kubectl apply -f 06-ingress.yaml -f 07-hpa.yaml -f 08-networkpolicy.yaml
    
    # The state's verification
    kubectl get all -n myapp
    kubectl get pvc -n myapp
    kubectl get hpa -n myapp
    
    # The demonstrations
    kubectl scale deployment/api -n myapp --replicas=5
    kubectl rollout status deployment/api -n myapp
    kubectl rollout undo deployment/api -n myapp
    
    # The cleanup
    kubectl delete namespace myapp
    minikube stop 2>/dev/null
    Did the deployment succeed? What are the services' and the pods' states? Write a report (500–750 words) describing the deployment and the observations.
  4. Analyze the Kubernetes's security. On your VM, inspect the cluster's security:
    # The RBAC's objects
    kubectl get clusterroles,clusterrolebindings | head -20
    kubectl auth can-i --list
    kubectl auth can-i create pods -n myapp
    kubectl auth can-i delete nodes
    
    # The pods' security's contexts
    kubectl get pods -A -o json | \
        python3 -c "
    import sys, json
    data = json.load(sys.stdin)
    for pod in data['items']:
        ns = pod['metadata']['namespace']
        name = pod['metadata']['name']
        sc = pod['spec'].get('securityContext', {})
        print(f'{ns}/{name}: runAsNonRoot={sc.get(\"runAsNonRoot\")}, runAsUser={sc.get(\"runAsUser\")}')
    " | head -20
    
    # The Pod Security's Admission's status
    kubectl get namespaces -o json | \
        python3 -c "
    import sys, json
    data = json.load(sys.stdin)
    for ns in data['items']:
        labels = ns['metadata'].get('labels', {})
        pss = {k: v for k, v in labels.items() if 'pod-security' in k}
        if pss:
            print(f'{ns[\"metadata\"][\"name\"]}: {pss}')
    "
    
    # The network's policies
    kubectl get networkpolicies -A
    
    # The secrets' state
    kubectl get secrets -A | head -20
    
    # The admission's controllers
    kubectl get validatingwebhookconfigurations 2>/dev/null
    kubectl get mutatingwebhookconfigurations 2>/dev/null
    
    # The security's scanning's tools (if available)
    which kube-bench kube-hunter kubesec polaris kubescape 2>/dev/null
    What are the cluster's RBAC's state and the pods' security's contexts? What are the network's policies? Write a report (500–750 words) analyzing the cluster's security.
  5. Design a GitOps's workflow. A team is adopting the GitOps's model for its Kubernetes's operations. Design the workflow:
    • The repositories' structure (the applications' repositories, the manifests' repositories, the environments' separation).
    • The CI's pipeline (the images' building, the scanning, the signing, the pushing, the manifests' updates).
    • The GitOps's tool (the ArgoCD's or the Flux's: the installation, the configuration, the applications' definitions).
    • The environments' promotion (the development, the staging, the production: the different's overlays or the different's branches).
    • The secrets' management (the sealed-secrets's, the external-secrets's, the Vault's).
    • The rollbacks' strategy (the Git's reverts, the ArgoCD's rollbacks).
    • The observability (the ArgoCD's dashboards, the Prometheus's alerts).
    Justify your design through the lesson's principles.
  6. Compare the Kubernetes's networking's CNI's plugins. Write a short paragraph (200–250 words) comparing the Kubernetes's networking's CNI's plugins (the Calico's, the Cilium's, the Flannel's, the Weave's, the Antrea's). Your paragraph should address:
    • Each plugin's datapath (the iptables's, the eBPF's, the VXLAN's, the Open vSwitch's).
    • Each plugin's features (the network's policies, the load's balancing, the observability, the encryption).
    • Each plugin's performance.
    • Each plugin's appropriate use's cases.
    • The plugins' ecosystem's integration (the Prometheus's, the Grafana's, the service's mesh's).
  7. Design the Kubernetes's observability's stack. A team needs the Kubernetes's observability for its cluster. Design the stack:
    • The metrics (the Prometheus's, the Grafana's, the node's exporters, the kube-state-metrics, the application's metrics).
    • The logs (the Loki's, the Fluent Bit's, the Grafana's, the centralized's logging).
    • The traces (the Tempo's, the Jaeger's, the OpenTelemetry's).
    • The alerts (the Alertmanager's, the Prometheus's rules, the severity's levels, the routing).
    • The dashboards (the Grafana's: the cluster's, the nodes', the pods', the applications').
    • The SLO's (the service's level's objectives, the error's budgets).
    Justify your design through the lesson's principles.
  8. Analyze a Kubernetes's incident. Choose a known Kubernetes's security's incident (the Tesla's cluster's cryptojacking, the CVE-2021-25741's subpath's, the CVE-2021-25742's ingress-nginx's, the CVE-2022-0185's Linux's kernel's, the ArgoCD's CVE-2022-31035, the Kubernetes's RBAC's misconfigurations) and analyze it:
    • The vulnerability's description.
    • The exploit's mechanism (which component: the kernel's, the runtime's, the Kubernetes's, the configuration's).
    • The affected's versions and the fixes.
    • The lessons for the Kubernetes's security's design.
    • The mitigations (the RBAC's, the network's policies, the pod's security, the monitoring).
    Write a short report (500–750 words).
  9. Reflect. In your own words, explain the container orchestration's concept and its concerns, and describe the Kubernetes's architecture, the objects, the declarative's model, the scheduling, the networking, the alternatives, the security, and the ecosystem. Then describe one situation in your own experience — a Kubernetes's cluster you have used, a deployment you have administered, or an orchestration's tool you have relied on — where the orchestration's design affected the outcome. What was the situation, and how would a different configuration have changed the outcome?

10 Summary

  • The container orchestration is the automated's management of the containers' lifecycle, the placement, the networking, the storage, and the configuration across the clusters of the many's hosts. Its concerns: the scheduling, the scaling, the self-healing, the service's discovery, the rolling's updates, the configuration's management, the storage's management, and the observability.
  • The Kubernetes's architecture: the control's plane (the API's server, the etcd, the scheduler, the controller's manager, the cloud's controller's manager) and the worker's nodes (the kubelet, the kube-proxy, the CRI's implementation, the CNI's plugins, the CSI's drivers).
  • The Kubernetes's objects: the pods (the smallest's deployable's unit), the Deployments (the stateless's applications), the ReplicaSets (the pods' count), the Services (the stable's network's identities), the Ingresses (the external's HTTP and HTTPS), the ConfigMaps and the Secrets (the configuration), the StatefulSets (the stateful's applications), the DaemonSets (the every node's pods), the Jobs and the CronJobs (the batch's workloads), the namespaces (the logical's partitions), the RBAC (the authorization), and the network's policies (the traffic's rules).
  • The Kubernetes's declarative's model: the operators declare the desired's state (the manifests), and the Kubernetes's controllers (the reconciliation's loops) make the actual's state match the desired's state. The kubectl's commands (the imperative's and the declarative's), the reconciliation's loops, and the GitOps's model (the manifests in the Git, the ArgoCD's and the Flux's tools).
  • The Kubernetes's scheduling: the resource's requests and limits, the node's selection's rules (the nodeSelector, the nodeName, the affinity, the taints and the tolerations), the scheduler's policies (the filtering and the scoring), and the scheduler's profiles.
  • The Kubernetes's networking: the network's model (the every pod has its own's IP), the CNI's plugins (the Calico's, the Cilium's, the Flannel's, the Weave's, the Antrea's, the Kube-router's), the services' networking (the ClusterIP's, the NodePort's, the LoadBalancer's, the kube-proxy's modes), and the DNS's resolution (the CoreDNS).
  • The orchestration's alternatives: the Docker Swarm (the Docker's native's orchestration), the HashiCorp's Nomad (the HashiCorp's orchestration), the Apache Mesos (the Apache's cluster's manager), and the cloud's providers' services (the ECS's, the EKS's, the GKE's, the AKS's, the ACK's, the DOKS's).
  • The orchestration's security: the cluster's layers (the cloud's infrastructure's, the cluster's, the node's, the pod's, the application's), the API's server's security (the authentication, the authorization, the admission, the audit's logging), the pod's security (the security's context, the Pod Security's Standards, the Pod Security's Admission), the network's security (the network's policies, the service's mesh's), the supply chain's security (the scanning, the signing, the attestation, the SBOM's, the admission's controllers), and the runtime's security (the Falco's, the Tetragon's, the Sysdig's).
  • The orchestration's ecosystem: the Helm (the package's manager), the Kustomize (the configuration's management), the Istio (the service's mesh), the Prometheus (the monitoring), the ArgoCD and the Flux (the GitOps's tools), and the Operators (the applications' operational's knowledge's encapsulation).
  • The orchestration's design's trade-offs: the declarative's model (the reproducibility, the versioning, the GitOps's, the self-healing's vs. the learning's curve, the debugging's difficulty), the scheduling's abstraction (the portability, the operations's automation vs. the control's loss), the pod's abstraction (the co-location vs. the complexity), the service's abstraction (the stable's identities vs. the networking's complexity), the cluster's abstraction (the scale, the multi-tenancy's vs. the management's complexity), and the ecosystem's diversity (the tools' choice vs. the integration's complexity).

Looking ahead

This lesson presented the container orchestration: the orchestration's concept and its concerns, the Kubernetes's architecture (the control's plane, the worker's nodes, the API's server, the etcd, the scheduler, the controller's manager, the kubelet, the kube-proxy, the CRI, the CNI, the CSI), the Kubernetes's objects (the pods, the Deployments, the ReplicaSets, the Services, the Ingresses, the ConfigMaps, the Secrets, the StatefulSets, the DaemonSets, the Jobs, the CronJobs, the namespaces, the RBAC, the network's policies), the declarative's model, the scheduling, the networking, the alternatives, the security, the operations, and the ecosystem. It referred several times to the cloud's operating systems — the platforms that provide the on-demand's computing over the orchestration's foundations — and to the cloud's providers' services (the AWS's, the Azure's, the GCP's, the Alibaba's). Lesson 13.6 presents the cloud operating systems in detail: the cloud's definition (the NIST's characteristics: the on-demand's self-service, the broad's network's access, the resource's pooling, the rapid's elasticity, the measured's service), the cloud's service's models (the IaaS's, the PaaS's, the SaaS's, the FaaS's), the cloud's deployment's models (the public's, the private's, the hybrid's, the community's), the cloud's operating systems (the OpenStack's, the Kubernetes's, the cloud's providers' services), the cloud's storage (the object's stores: the S3's, the blob's stores; the block's stores: the EBS's, the disks; the file's systems: the EFS's), the cloud's networking (the VPC's, the load's balancers, the CDNs), the cloud's security (the IAM's, the VPC's security, the encryption), the serverless's computing, and the cloud's economics. The lesson is the sixth of the unit's presentation of the virtualization's continuum, and it is the bridge to the future trends (Lesson 13.7).

11 References

  • Silberschatz, A., Galvin, P. B., & Gagne, G. Operating System Concepts, 10th ed., Chapter 18.
  • Arpaci-Dusseau, R. H., & Arpaci-Dusseau, A. C. Operating Systems: Three Easy Pieces, the Virtualization chapters. Available online at ostep.org.
  • Burns, B., Grant, B., Oppenheimer, D., Brewer, E., & Wilkes, J. Borg, Omega, and Kubernetes. ACM Queue, 2016.
  • Bernstein, D. Containers and Cloud: From LXC to Docker to Kubernetes. IEEE Cloud Computing, 2014.
  • Hightower, K., Burns, B., & Beda, J. Kubernetes: Up and Running, 3rd ed. O'Reilly, 2022.
  • Lukša, M. Kubernetes in Action, 2nd ed. Manning, 2020.
  • Kelsey Hightower's Kubernetes the Hard Way. The step-by-step's guide that builds the Kubernetes's cluster from the components.
  • The Kubernetes's documentation (kubernetes.io/docs): the concepts, the tasks, the tutorials, the reference, and the best practices.
  • The Cloud Native Computing Foundation (CNCF)'s landscape. The map of the orchestration's ecosystem.
  • Rice, L. Container Security. O'Reilly, 2020.
  • NIST SP 800-190. Application Container Security Guide. National Institute of Standards and Technology.
  • Linux man-pages: man 1 kubectl, man 1 kubectl-apply, man 1 kubectl-get, man 1 kubectl-describe, man 1 kubectl-logs, man 1 kubectl-exec, man 1 kubectl-rollout, man 1 kubectl-scale, man 1 kubectl-port-forward, man 1 minikube, man 1 kind, man 1 k3s, man 1 helm, man 1 k9s, man 1 stern, man 1 kubectx, man 1 kubens.
👤