Kubernetes Container Orchestration Kubernetes 3 — Questions and Answers
Question 1: What is the default restart policy for a Kubernetes Pod?
- Never
- OnFailure
- Always (Correct answer)
- OnError
Correct answer: Always
The default restartPolicy for a Pod is 'Always', which means the container will always be restarted regardless of exit code.
Question 2: How does a Kubernetes HorizontalPodAutoscaler (HPA) determine when to scale?
- By monitoring node CPU temperature
- By observing Pod metrics such as CPU or memory utilization (Correct answer)
- By counting failed HTTP requests at the ingress
- By checking the number of pending PVCs
Correct answer: By observing Pod metrics such as CPU or memory utilization
HPA scales the number of Pod replicas based on observed metrics like CPU or custom metrics compared to target thresholds.
Question 3: Which resource type ensures exactly one Pod runs on every (or selected) node in a cluster?
- Deployment
- StatefulSet
- DaemonSet (Correct answer)
- ReplicaSet
Correct answer: DaemonSet
A DaemonSet ensures that a copy of a Pod runs on all (or some) nodes, commonly used for logging agents or monitoring daemons.
Question 4: What does a Kubernetes NetworkPolicy do?
- Assigns static IPs to Pods
- Controls which Pods can communicate with each other and with external endpoints (Correct answer)
- Balances traffic across service endpoints
- Manages DNS resolution inside the cluster
Correct answer: Controls which Pods can communicate with each other and with external endpoints
NetworkPolicy is a specification of how groups of Pods are allowed to communicate with each other and other network endpoints.
Question 5: Which kubectl command applies a configuration file to create or update resources?
- kubectl create -f
- kubectl apply -f (Correct answer)
- kubectl replace -f
- kubectl patch -f
Correct answer: kubectl apply -f
kubectl apply -f performs a declarative update — it creates resources if they don't exist and patches them if they do.
Question 6: What is the role of kube-proxy in a Kubernetes cluster?
- It schedules Pods onto nodes
- It maintains network rules on nodes to enable Service abstraction (Correct answer)
- It manages TLS certificates for the API server
- It syncs container images across nodes
Correct answer: It maintains network rules on nodes to enable Service abstraction
kube-proxy runs on each node and maintains iptables/IPVS rules that implement the virtual IP for Services.
Question 7: Which field in a Deployment spec controls how many old ReplicaSets are retained for rollback?
- maxSurge
- revisionHistoryLimit (Correct answer)
- progressDeadlineSeconds
- minReadySeconds
Correct answer: revisionHistoryLimit
revisionHistoryLimit specifies how many old ReplicaSets to retain to allow rollback; defaults to 10.
What is the default restart policy for a Kubernetes Pod?