# Kubernetes Architecture, Pods, Deployments, Services & Ingress (CKA/CKAD)

> Certified Kubernetes Administrator (CKA) and Application Developer (CKAD) core mastery covering Control Plane and Worker Node components, etcd Raft consensus and backup/restore, multi-container Pod patterns, Liveness/Readiness/Startup Probes, Workload controllers (Deployments, DaemonSets, StatefulSets, Jobs), Services, Ingress/Gateway API, and NetworkPolicies.

- **Canonical URL:** https://flashcards.world/flashcards/sets/d9e3775a-2a02-4ed6-a840-564b4390a887/
- **Markdown URL:** https://flashcards.world/flashcards/sets/d9e3775a-2a02-4ed6-a840-564b4390a887.md
- **Category:** Kubernetes (CKA / CKAD), Docker Containers, Linux (LPIC-1 / RHCSA) & Git CI/CD
- **Level:** intermediate
- **Languages:** en → en
- **Total Cards:** 32

## Flashcards (32 Cards)

| # | Front (Term / Prompt) | Back (Definition / Answer) | Example | Multiple-Choice Options |
| :--- | :--- | :--- | :--- | :--- |
| 1 | What resources do multiple containers inside the same Kubernetes Pod share with one another? | All containers in a Pod share: 1. The same Network Namespace (initialized by the hidden `pause` / sandbox container)—they share the exact same IP address and port space and communicate with each other over `localhost`; 2. The same IPC Namespace (shared memory); 3. Optionally the same PID Namespace (`shareProcessNamespace: true`); 4. Any Pod-level `volumes` mounted into their respective `volumeMounts` paths. |  |  |
| 2 | What are the four probe check mechanisms supported by Kubernetes `livenessProbe`, `readinessProbe`, and `startupProbe`? | 1. `httpGet`: Sends an HTTP GET request to a specified `port`, `path`, and `httpHeaders`; succeeds if HTTP status code is `200 <= code < 400`. 2. `tcpSocket`: Attempts to open a TCP connection on the specified `port`; succeeds if the socket connects. 3. `exec`: Executes a command inside the container; succeeds if the command exits with status code `0`. 4. `grpc`: Performs a native gRPC health check on the configured `port` and `service`. |  |  |
| 3 | How does CoreDNS resolve Service names and Pod names inside a Kubernetes cluster? | Every Pod's `/etc/resolv.conf` points `nameserver` to the `kube-dns` Service IP and sets `search <namespace>.svc.cluster.local svc.cluster.local cluster.local`. Therefore, a Service in the same namespace can be reached simply as `<service-name>`, in another namespace as `<service-name>.<namespace>`, or by full FQDN `<service-name>.<namespace>.svc.cluster.local`. Standard Pods resolve via `<pod-ip-with-dashes>.<namespace>.pod.cluster.local` (e.g., `10-244-1-5.default.pod.cluster.local`). |  |  |
| 4 | Compare `Prefix` and `Exact` `pathType` matching in a Kubernetes Ingress rule. | `Exact`: Matches the URL path with strict case-sensitivity and exact string equality (`/foo` matches `/foo`, NOT `/foo/` or `/foo/bar`). `Prefix`: Matches based on URL path segments split by `/`; `/foo` matches `/foo`, `/foo/`, and `/foo/bar`, but does NOT match `/foobar`! When multiple paths match a request, longest matching path wins (and `Exact` takes precedence over `Prefix` of equal length). |  |  |
| 5 | What is the default Pod-to-Pod network behavior in Kubernetes, and what happens the moment you apply a `NetworkPolicy` selecting a Pod? | By default in Kubernetes, all Pods are 'non-isolated'—any Pod can communicate with any other Pod in any namespace without restriction (provided the CNI plugin like Calico, Cilium, or Weave Net supports NetworkPolicy; note that basic Flannel does NOT enforce NetworkPolicies!). The moment a `NetworkPolicy` selects a Pod via `podSelector` for a given `policyTypes` (`Ingress` and/or `Egress`), that Pod becomes isolated: ALL traffic in that direction is implicitly DENIED unless explicitly allowed by a policy rule. |  |  |
| 6 | Explain the step-by-step sequence of a Graceful Pod Termination in Kubernetes when `kubectl delete pod` is executed. | 1. Pod status changes to `Terminating` and a `deletionGracePeriodSeconds` (default `30s`) timer starts. 2. Concurrently (in parallel!): (a) Endpoint controller removes the Pod IP from Service `Endpoints`/`EndpointSlices` so `kube-proxy` and Ingress stop routing new traffic to it; AND (b) `kubelet` runs the `preStop` lifecycle hook (if defined) inside the container, then sends `SIGTERM` to container `PID 1`. 3. If the container is still running when `terminationGracePeriodSeconds` expires, `kubelet` sends immediate `SIGKILL` (`9`). Tip: Add a brief `sleep 5` in `preStop` so `kube-proxy`/ALB endpoint removal propagates before the app stops accepting connections! |  |  |
| 7 | How do `completions`, `parallelism`, `backoffLimit`, and `activeDeadlineSeconds` work in a Kubernetes `Job`? | A `Job` runs batch Pods to successful completion (exit code `0`; requires `restartPolicy: Never` or `OnFailure`). `completions` specifies the total number of successful Pod runs required; `parallelism` specifies how many Pods can run concurrently at any moment; `backoffLimit` (default `6`) sets how many times a Job retries failing Pods with exponential backoff before marking the Job `Failed`; `activeDeadlineSeconds` sets a hard wall-clock timeout for the entire Job. |  |  |
| 8 | What is the Container Network Interface (CNI) in Kubernetes, where are its binaries/configs stored on nodes, and what is the Kubernetes Networking Model rule? | The Kubernetes Networking Model mandates that every Pod gets its own unique IP address and can communicate with all other Pods on any node WITHOUT Network Address Translation (NAT). `kubelet` invokes CNI plugin binaries (located in `/opt/cni/bin/`) configured via `/etc/cni/net.d/` whenever a Pod sandbox is created or destroyed to attach the `veth` interface, assign an IP (IPAM), and program overlay (VXLAN/Geneve) or BGP routes (e.g., Cilium eBPF, Calico, Flannel). |  |  |
| 9 | What is a Static Pod in Kubernetes, how do you identify one, and where are its manifests stored on a `kubeadm` node? | A Static Pod is managed directly by the `kubelet` daemon on a specific node without the `kube-apiserver` or `kube-scheduler` (used by `kubeadm` to bootstrap `kube-apiserver`, `etcd`, `kube-scheduler`, and `kube-controller-manager`). `kubelet` watches `staticPodPath` (configured in `/var/lib/kubelet/config.yaml`, defaulting to `/etc/kubernetes/manifests/`). It creates a read-only 'Mirror Pod' in the API server whose name always ends with the node hostname suffix (e.g., `etcd-controlplane`). Deleting a Mirror Pod via `kubectl delete pod` will NOT remove it; you must move/delete the YAML from `/etc/kubernetes/manifests/`. |  |  |
| 10 | Explain the critical difference between YAML list items (OR logic) and a single YAML map item (AND logic) in `NetworkPolicy` `from`/`to` selectors! | This is a classic CKA exam trap! If `namespaceSelector` and `podSelector` are in the SAME list item (only one `-` dash): `- namespaceSelector: ... \n  podSelector: ...`, it uses boolean AND (traffic allowed ONLY from Pods matching `podSelector` that reside INSIDE namespaces matching `namespaceSelector`). If they have TWO separate `-` dashes: `- namespaceSelector: ... \n - podSelector: ...`, it uses boolean OR (traffic allowed from ALL Pods in matching namespaces, OR from matching Pods inside the policy's own namespace)! |  |  |
| 11 | How do `maxSurge` and `maxUnavailable` control a Kubernetes Deployment's `RollingUpdate` strategy? | Given a Deployment with `replicas: 10`: `maxUnavailable` (default `25%`) is the maximum number of Pods that can be unavailable during the update (at least $10 - 2 = 8$ Pods must remain available). `maxSurge` (default `25%`) is the maximum number of extra Pods that can be created above the desired replica count during the update (up to $10 + 3 = 13$ total Pods). Setting `maxSurge: 1, maxUnavailable: 0` ensures a new Pod is completely Ready before an old Pod is terminated. |  |  |
| 12 | How does a Service connect to backing Pods, and how do you use a Service + manual `Endpoints`/`EndpointSlice` to route to an external IP address? | Normally, a Service uses `spec.selector` to match Pod labels; the EndpointSlice controller continuously populates an `Endpoints` / `EndpointSlice` object (with the exact same name as the Service) containing the Ready Pod IPs. If you create a Service WITHOUT a `spec.selector`, Kubernetes does not create `Endpoints` automatically—allowing you to manually create an `Endpoints` (or `EndpointSlice`) object with the same name pointing to an external database IP outside the cluster! |  |  |
| 13 | Compare the four multi-container Pod design patterns: Init Container, Sidecar, Adapter, and Ambassador. | 1. Init Container (`spec.initContainers`): Runs sequentially to completion BEFORE any main `containers` start (e.g., waiting for a DB service, running schema migrations, cloning config). 2. Sidecar: Runs alongside the main container (supported natively in K8s 1.28+ via `initContainers` with `restartPolicy: Always`) to provide auxiliary tasks like log shipping (Fluent Bit) or service mesh mTLS (Envoy). 3. Adapter: Standardizes/transforms heterogeneous app output (e.g., converting custom logs/metrics into Prometheus format). 4. Ambassador: Local proxy on `localhost` simplifying outbound connections to external shards/services. |  |  |
| 14 | How do you generate YAML manifests rapidly during the CKA/CKAD exam without writing YAML from scratch? | Use imperative `kubectl` commands with `--dry-run=client -o yaml > manifest.yaml`! Examples: `kubectl run nginx --image=nginx --port=80 --dry-run=client -o yaml` (Pod); `kubectl create deployment web --image=nginx --replicas=3 --dry-run=client -o yaml` (Deployment); `kubectl expose pod nginx --port=80 --target-port=8080 --name=nginx-svc --type=NodePort --dry-run=client -o yaml` (Service); `kubectl create job myjob --image=busybox --dry-run=client -o yaml -- date` (Job). |  |  |
| 15 | Explain the difference between `port`, `targetPort`, and `nodePort` in a Kubernetes Service specification. | `port`: The port exposed on the Service's internal virtual `ClusterIP` (what other Pods inside the cluster connect to). `targetPort`: The actual port on the backing Pod/container (`containerPort`) where your application process is listening (defaults to the same value as `port` if omitted; can also be a named port like `http-web`). `nodePort`: The external port (`30000–32767`) opened on every Kubernetes node for `NodePort` or `LoadBalancer` services. |  |  |
| 16 | What are the three core Worker Node components in Kubernetes and how do they interact? | 1. `kubelet`: Node agent that watches the `kube-apiserver` for PodSpecs assigned to its node, instructs the container runtime to start containers, executes probes, mounts volumes, and reports node/pod status. 2. Container Runtime (`containerd` or `CRI-O`): Implements the Container Runtime Interface (CRI) to pull images and manage OCI containers (Note: `dockershim` was removed in K8s v1.24). 3. `kube-proxy`: Runs on every node to program `iptables`, `IPVS`, or `nftables` rules that route Service ClusterIP virtual IPs to backend Pod IPs. |  |  |
| 17 | Trace the step-by-step lifecycle of what happens in Kubernetes when you run `kubectl create deployment nginx --image=nginx`. | 1. `kubectl` sends an HTTP `POST` to `kube-apiserver` -> 2. API server authenticates, authorizes (RBAC), runs Mutating & Validating Admission Webhooks, and writes the `Deployment` object to `etcd` -> 3. Deployment controller (in `kube-controller-manager`) notices via watch and creates a `ReplicaSet` via API server -> 4. ReplicaSet controller creates `Pod` objects (status `Pending`, `nodeName` empty) -> 5. `kube-scheduler` binds Pods to a healthy node (`nodeName: node01`) -> 6. `kubelet` on `node01` sees the bound Pod, calls `containerd` (CRI) and CNI plugin to allocate IP and start the container, updating status to `Running`. |  |  |
| 18 | How does the modern Kubernetes `Gateway API` (`GatewayClass`, `Gateway`, `HTTPRoute`) improve over the legacy `Ingress` resource? | The `Gateway API` replaces vendor-specific Ingress annotation sprawl with a role-oriented, expressive, portable standard: 1. `GatewayClass` (managed by Infrastructure Provider: defines the controller type); 2. `Gateway` (managed by Cluster Ops: defines network entrypoints, listeners, ports, and TLS certificates); 3. `HTTPRoute` / `GRPCRoute` / `TCPRoute` / `TLSRoute` (managed by App Developers in their namespaces: defines L7 header matching, canary traffic splitting via `weight`, request mirroring, and cross-namespace attachment guarded by `ReferenceGrant`). |  |  |
| 19 | What are the four core Control Plane components of a Kubernetes cluster and their responsibilities? | 1. `kube-apiserver`: The sole frontend REST gateway to the cluster; handles authentication, authorization (RBAC), admission control, schema validation, and is the ONLY component that talks directly to `etcd`. 2. `etcd`: Distributed, consistent key-value store persisting all cluster state. 3. `kube-scheduler`: Watches for newly created Pods with no `nodeName` and selects an optimal node via Filtering and Scoring phases. 4. `kube-controller-manager`: Runs reconciliation control loops (Node, Replication, Endpoints/EndpointSlice, ServiceAccount controllers). |  |  |
| 20 | How does `etcd` use the Raft consensus algorithm to determine quorum, and why should you deploy an odd number of `etcd` nodes (3 or 5)? | Raft requires a strict majority quorum of $\lfloor N/2 \rfloor + 1$ healthy nodes to elect a leader and commit writes. A 3-node cluster requires 2 nodes for quorum (tolerates 1 failure). Adding a 4th node increases the quorum requirement to 3 nodes, so a 4-node cluster STILL only tolerates 1 failure while slowing down write replication! A 5-node cluster requires 3 nodes for quorum and tolerates 2 node failures. |  |  |
| 21 | Compare Kubernetes `Deployment`, `DaemonSet`, and `StatefulSet` controllers. | `Deployment`: Manages stateless, interchangeable Pod replicas via ReplicaSets (random pod hashes like `web-6d4f7-x9z2k`). `DaemonSet`: Ensures a copy of a Pod runs on ALL (or a filtered subset of) nodes in the cluster, automatically adding Pods to new nodes (used for CNI plugins, `kube-proxy`, node log shippers, and storage daemons). `StatefulSet`: Manages stateful distributed systems (databases, Kafka, ZooKeeper) requiring stable ordinal identities (`mysql-0`, `mysql-1`), ordered deployment/scaling, and dedicated per-pod PersistentVolumeClaims via `volumeClaimTemplates`. |  |  |
| 22 | What does setting `externalTrafficPolicy: Local` vs. `Cluster` (default) on a `NodePort` or `LoadBalancer` Service do? | `Cluster` (default): `kube-proxy` routes incoming traffic arriving at a node to ANY Ready Pod across the entire cluster; this distributes load evenly, but introduces an extra network hop between nodes AND replaces the client's original Source IP with the node's IP via SNAT! `Local`: `kube-proxy` only routes traffic to Pods running locally on that specific receiving node (dropping traffic if the node has no local Pod); this avoids extra inter-node hops AND preserves the true external client Source IP. |  |  |
| 23 | Compare `startupProbe`, `readinessProbe`, and `livenessProbe` in a Kubernetes Pod, including what happens when each fails. | 1. `startupProbe`: Runs first; disables both liveness and readiness checks until it succeeds (prevents slow-starting legacy/JVM apps from being killed before they finish booting; if it fails `failureThreshold` times, the container is killed and restarted). 2. `livenessProbe`: Checks if the container is deadlocked; if it fails, `kubelet` kills and restarts the container according to `restartPolicy`. 3. `readinessProbe`: Checks if the Pod is ready to accept traffic; if it fails, the Pod is NOT restarted, but its IP is removed from Service `Endpoints`/`EndpointSlices`. |  |  |
| 24 | What happens to the `PersistentVolumeClaims` created by a StatefulSet's `volumeClaimTemplates` when the StatefulSet is scaled down or deleted? | By default (unless configured otherwise via `persistentVolumeClaimRetentionPolicy` in newer K8s versions), scaling down or deleting a StatefulSet does NOT delete the associated `PersistentVolumeClaims` (PVCs)! This is a safety mechanism to prevent accidental data loss; when `mysql-1` is scaled back up later, it automatically reattaches to its existing `data-mysql-1` PVC. |  |  |
| 25 | What `kubectl rollout` commands are used to inspect history, monitor progress, pause/resume, and roll back a Deployment? | `kubectl rollout status deployment/web` watches real-time rollout completion; `kubectl rollout history deployment/web` lists ReplicaSet revisions; `kubectl rollout undo deployment/web` rolls back to the immediately preceding revision (or `--to-revision=2` for a specific revision); `kubectl rollout pause/resume deployment/web` pauses or resumes an active rollout; `kubectl rollout restart deployment/web` triggers a zero-downtime rolling restart of all Pods. |  |  |
| 26 | How do you write a `Default Deny All Ingress and Egress` NetworkPolicy for a namespace in Kubernetes? | Create a `NetworkPolicy` in that namespace with an empty `podSelector: {}` (which selects ALL Pods in the namespace), specify `policyTypes: ["Ingress", "Egress"]`, and omit the `ingress:` and `egress:` allow lists entirely. Note: When restricting `Egress`, remember to add an explicit egress rule allowing UDP/TCP port `53` to `kube-system` (`k8s-app: kube-dns`), or Pods will fail all DNS lookups! |  |  |
| 27 | What is a Kubernetes `Ingress` resource, why does it do nothing without an Ingress Controller, and what does `ingressClassName` do? | An `Ingress` is an API object defining Layer 7 HTTP/HTTPS routing rules (host-based virtual hosting like `api.example.com`, URL path routing like `/v1`, and TLS termination via a `kubernetes.io/tls` Secret) pointing to internal `ClusterIP` Services. However, `Ingress` is purely a declarative spec—an Ingress Controller pod (NGINX, Traefik, Envoy, AWS ALB Controller) must be running in the cluster to watch `Ingress` objects matching `spec.ingressClassName` and configure an actual reverse proxy/load balancer. |  |  |
| 28 | What are the exact `etcdctl` commands to take a snapshot backup and restore an `etcd` cluster in the CKA exam? | Backup: `ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key snapshot save /tmp/etcd-backup.db` (verify with `etcdctl snapshot status /tmp/etcd-backup.db -w table`). Restore: `ETCDCTL_API=3 etcdctl snapshot restore /tmp/etcd-backup.db --data-dir=/var/lib/etcd-restored`, then update `hostPath` in `/etc/kubernetes/manifests/etcd.yaml` to point to `/var/lib/etcd-restored`. |  |  |
| 29 | How do Kubernetes Labels, Selectors (equality vs. set-based), and Annotations differ? | Labels (`metadata.labels`) are key/value pairs attached to objects used for identifying, grouping, and selecting subsets of objects via Equality selectors (`env=prod,tier!=frontend`) or Set-based selectors (`env in (prod, staging)`). Annotations (`metadata.annotations`) attach non-identifying arbitrary metadata (can be much larger, hold structured JSON/URLs, build numbers, or controller configuration like `nginx.ingress.kubernetes.io/rewrite-target`) that cannot be queried via label selectors. |  |  |
| 30 | Compare the four Kubernetes Service types: `ClusterIP`, `NodePort`, `LoadBalancer`, and `ExternalName`. | 1. `ClusterIP` (default): Exposes the Service on a cluster-internal virtual IP reachable only from within the cluster. 2. `NodePort`: Builds on `ClusterIP` and opens a static port (`30000–32767`) on EVERY Node's IP (`<NodeIP>:<NodePort>`). 3. `LoadBalancer`: Builds on `NodePort` and `ClusterIP` by provisioning an external cloud load balancer (ALB/NLB/Azure LB/GCP LB) routing to the nodes. 4. `ExternalName`: No selectors or proxying; returns a DNS `CNAME` record mapping the Service name to an external FQDN (e.g., `mydb.rds.amazonaws.com`). |  |  |
| 31 | What are the three `concurrencyPolicy` options in a Kubernetes `CronJob`? | `Allow` (default): Allows multiple Job instances to run concurrently if a previous scheduled run has not finished before the next schedule triggers. `Forbid`: Skips the new scheduled run completely if the previous Job is still running. `Replace`: Cancels and replaces the currently running Job with a newly scheduled Job. |  |  |
| 32 | Why does a Kubernetes `StatefulSet` require a Headless Service (`clusterIP: None`), and what DNS records are generated for its Pods? | Unlike a standard Service which load-balances across all Pods behind a single virtual IP, a Headless Service (`clusterIP: None`) allocates no virtual IP and instead returns individual DNS `A`/`AAAA` records directly for each Pod. Combined with a StatefulSet's `serviceName`, CoreDNS creates a deterministic, stable FQDN for every individual Pod: `<pod-name>.<service-name>.<namespace>.svc.cluster.local` (e.g., `mysql-0.mysql-headless.default.svc.cluster.local`), which persists across Pod rescheduling. |  |  |

---
Study this deck interactively with FSRS-6 spaced repetition, audio review, and multiple-choice mode at [Flashcards World](https://flashcards.world/flashcards/sets/d9e3775a-2a02-4ed6-a840-564b4390a887/).
