Kubernetes Container Orchestration Kubernetes 4 — Questions and Answers
Question 1: What happens when a Pod's liveness probe fails repeatedly?
- The Pod is evicted from the node
- The container is restarted according to the Pod's restart policy (Correct answer)
- The node is cordoned automatically
- The Deployment is paused
Correct answer: The container is restarted according to the Pod's restart policy
When a liveness probe fails beyond the threshold, kubelet restarts the container based on the Pod's restartPolicy.
Question 2: Which Kubernetes object is best suited for running a batch task that should complete successfully and then stop?
- Deployment
- DaemonSet
- CronJob
- Job (Correct answer)
Correct answer: Job
A Job creates one or more Pods and tracks their successful completions, terminating when the specified number of completions is reached.
Question 3: What is the purpose of resource requests in a Pod spec?
- They set the maximum CPU/memory a container can use
- They tell the scheduler how much CPU/memory to reserve for scheduling decisions (Correct answer)
- They trigger autoscaling when exceeded
- They configure quality-of-service for network traffic
Correct answer: They tell the scheduler how much CPU/memory to reserve for scheduling decisions
Resource requests inform the scheduler of the minimum resources needed, which it uses to find an appropriate node for placement.
Question 4: Which Kubernetes feature allows a Secret or ConfigMap to be projected into a Pod as environment variables or mounted files?
- Volume mounts and envFrom/env fields (Correct answer)
- ServiceAccount token projection only
- NetworkPolicy rules
- PodDisruptionBudget
Correct answer: Volume mounts and envFrom/env fields
ConfigMaps and Secrets can be consumed in Pods via envFrom/env fields for environment variables or via volumeMounts for file projection.
Question 5: What does 'kubectl cordon <node>' do?
- Drains all Pods from the node and deletes it
- Marks the node as unschedulable so no new Pods are placed on it (Correct answer)
- Reboots the node gracefully
- Removes the node from the cluster permanently
Correct answer: Marks the node as unschedulable so no new Pods are placed on it
Cordoning a node sets it to 'SchedulingDisabled', preventing the scheduler from placing new Pods while existing Pods continue running.
Question 6: Which type of Service exposes an application externally by provisioning a cloud load balancer?
- ClusterIP
- NodePort
- LoadBalancer (Correct answer)
- ExternalName
Correct answer: LoadBalancer
A LoadBalancer Service type requests the cloud provider to provision an external load balancer that routes traffic to the Service's endpoints.
Question 7: What is a Kubernetes InitContainer used for?
- Running sidecar proxies alongside the main container
- Performing setup tasks that must complete before the main containers start (Correct answer)
- Replacing the main container if it crashes
- Injecting environment variables at deploy time
Correct answer: Performing setup tasks that must complete before the main containers start
InitContainers run and complete sequentially before any app containers start, commonly used for setup tasks like waiting for dependencies.
What happens when a Pod's liveness probe fails repeatedly?