Kubernetes MCQs – Best Practices and Real-World Use Cases

Kubernetes is widely adopted for deploying, scaling, and managing containerized applications. To ensure production-grade reliability and efficiency, it’s crucial to follow best practices such as resource limits, security configurations, and cluster monitoring.

In this post, we present a curated set of multiple-choice questions (MCQs) on Kubernetes best practices and real-world use cases. These MCQs are designed to reinforce practical knowledge for interviews, exams, and real-world Kubernetes usage in enterprise environments.

1.) What is a recommended way to avoid resource starvation in Kubernetes Pods?

A) Increase the number of replicas
B) Set resource requests and limits
C) Use hostPath volumes
D) Use default namespaces only

Answer: Option B

Explanation: Defining CPU and memory requests and limits ensures fair resource allocation and prevents starvation.

2.) Why should you use readiness probes in production applications?

A) To log container metrics
B) To auto-scale pods
C) To delay traffic until the app is ready
D) To increase memory

Answer: Option C

Explanation: Readiness probes ensure traffic is only routed to healthy and ready containers.

3.) Which command shows the current resource usage of nodes and pods?

A) kubectl top
B) kubectl get pods –all-namespaces
C) kubectl describe node
D) kubectl logs

Answer: Option A

Explanation: kubectl top displays resource usage metrics like CPU and memory.

4.) What is the benefit of using namespaces in Kubernetes?

A) Increases pod startup speed
B) Improves DNS resolution
C) Reduces YAML file size
D) Provides resource and access isolation

Answer: Option D

Explanation: Namespaces help isolate resources and limit access within different environments (e.g., dev, prod).

5.) Why should ConfigMaps and Secrets be used instead of hardcoding values?

A) To reduce image size
B) For better CI/CD integration
C) To manage configuration externally
D) To support labels

Answer: Option C

Explanation: This approach decouples configurations from code, making updates and environment changes easier.

6.) What is the best practice for storing sensitive credentials in Kubernetes?

A) Store them in ConfigMaps
B) Use environment variables
C) Hardcode in YAML
D) Use Kubernetes Secrets

Answer: Option D

Explanation: Secrets are designed to store sensitive data like tokens and passwords securely.

7.) Which probe ensures that Kubernetes restarts a pod if it’s stuck?

A) Readiness probe
B) Startup probe
C) Liveness probe
D) Debug probe

Answer: Option C

Explanation: Liveness probes detect unresponsive containers and trigger restarts.

8.) What does the command kubectl get all -n production return?

A) All resources in the “production” namespace
B) All resources in the default namespace
C) All logs in the cluster
D) Nothing, unless a label is specified

Answer: Option A

Explanation: This command lists all workloads and services in the specified namespace.

9.) What is the main purpose of using Horizontal Pod Autoscaler (HPA)?

A) To delete unused pods
B) To scale pods based on resource usage
C) To automatically add nodes
D) To create static pod replicas

Answer: Option B

Explanation: HPA adjusts the number of pods based on CPU or custom metrics.

10.) How can you apply a YAML manifest to a cluster?

A) kubectl deploy
B) kubectl install
C) kubectl apply -f <file>
D) kubectl exec -f <file>

Answer: Option C

Explanation: This is the standard command to apply changes defined in a YAML file.

Leave a Reply

Your email address will not be published. Required fields are marked *