Kubernetes MCQ

Kubernetes, also known as K8s, is an open-source system for automating the deployment, scaling, and management of containerized applications. With its increasing popularity in cloud-native deployments, it’s crucial to understand its fundamental concepts. Dive into this set of 25 multiple-choice questions to test and expand your Kubernetes knowledge!

1. What is Kubernetes?

a) A programming language
b) A cloud provider
c) A container runtime
d) A container orchestration platform

Answer:

d) A container orchestration platform

Explanation:

Kubernetes is a platform designed to automate deploying, scaling, and operating application containers.

2. Which Kubernetes object provides declarative updates for Pods and ReplicaSets?

a) Nodes
b) Deployments
c) Services
d) ConfigMaps

Answer:

b) Deployments

Explanation:

Deployments are high-level objects that manage the desired state of an application, ensuring specified numbers of Pods and ReplicaSets are maintained.

3. What is a Pod in Kubernetes?

a) A storage unit
b) The smallest and simplest unit in the Kubernetes object model
c) A cluster
d) A network policy

Answer:

b) The smallest and simplest unit in the Kubernetes object model

Explanation:

A Pod represents a single unit of deployment and can encapsulate one or more containers.

4. Which Kubernetes component schedules the pods to worker nodes?

a) Kubelet
b) Kube-proxy
c) Scheduler
d) API Server

Answer:

c) Scheduler

Explanation:

The Scheduler is responsible for placing Pods onto Nodes based on factors like resources and affinity rules.

5. What do you use to communicate with a Kubernetes cluster?

a) kubeadm
b) kubectl
c) kubeconfig
d) kube-dns

Answer:

b) kubectl

Explanation:

kubectl is the command-line tool used to interact with the Kubernetes cluster.

6. Which Kubernetes component provides a REST interface for tasks like starting and stopping pods?

a) kubelet
b) kubectl
c) kube-proxy
d) kube-apiserver

Answer:

d) kube-apiserver

Explanation:

The kube-apiserver exposes the Kubernetes API, which provides the front end for the cluster's shared state through which all other components interact.

7. What is the primary role of the 'etcd' in a Kubernetes cluster?

a) Load balancing
b) Data storage for cluster configuration
c) Scaling applications
d) Monitoring services

Answer:

b) Data storage for cluster configuration

Explanation:

etcd is a consistent and highly-available key-value store used by Kubernetes to store all cluster data.

8. Which Kubernetes object can you use to ensure that there are always a specified number of replica Pods running?

a) DaemonSet
b) ReplicaSet
c) Job
d) Volume

Answer:

b) ReplicaSet

Explanation:

ReplicaSet ensures that a specified number of replica Pods are running at any given time.

9. In Kubernetes, which object is used to create a gateway for inbound traffic to your cluster?

a) Ingress
b) NetworkPolicy
c) Volume
d) ConfigMap

Answer:

a) Ingress

Explanation:

Ingress manages external access to the services in a cluster, typically HTTP.

10. What is the role of a 'Service' in Kubernetes?

a) To scale applications
b) To abstract how to access Pods
c) To manage storage
d) To deploy applications

Answer:

b) To abstract how to access Pods

Explanation:

Services enable communication between various components within and outside of the application. It abstracts the way to access the Pods, providing a stable endpoint.

11. Which of the following is a container runtime used by Kubernetes?

a) Jenkins
b) Docker
c) Helm
d) Prometheus

Answer:

b) Docker

Explanation:

Docker is a container runtime that Kubernetes can use to run containers. Other runtimes include containerd and CRI-O.

12. Which Kubernetes command is used to list all the pods in the current namespace?

a) kubectl pods
b) kubectl get pods
c) kubectl list pods
d) kubectl show pods

Answer:

b) kubectl get pods

Explanation:

13. If a Node in Kubernetes becomes unresponsive, what will happen to the pods running on that node?

a) They are deleted and not rescheduled
b) They are paused until the node is responsive again
c) They are rescheduled on another node
d) They are automatically fixed

Answer:

c) They are rescheduled on another node

Explanation:

If a node becomes unresponsive, the pods on that node are deemed lost. Kubernetes reschedules these pods onto a healthy node.

14. What is a 'namespace' in Kubernetes?

a) A storage unit
b) A type of Pod
c) An isolated segment of the cluster for resources
d) A network policy

Answer:

c) An isolated segment of the cluster for resources

Explanation:

Namespaces are used to provide scope for names and can be used to divide cluster resources among multiple users.

15. Which tool can be used for package management in Kubernetes?

a) Docker Compose
b) Helm
c) Git
d) Terraform

Answer:

b) Helm

Explanation:

Helm is the package manager for Kubernetes that allows developers and operators to more easily configure and deploy applications on Kubernetes clusters.

16. Which command is used to deploy an application from a manifest file named "deployment.yaml"?

a) kubectl run deployment.yaml
b) kubectl create deployment.yaml
c) kubectl apply -f deployment.yaml
d) kubectl launch -f deployment.yaml

Answer:

c) kubectl apply -f deployment.yaml

Explanation:

The kubectl apply command is used to apply a configuration change to a resource from a file or stdin.

17. How can you get the logs of a specific pod?

a) kubectl describe pod <POD_NAME>
b) kubectl get logs <POD_NAME>
c) kubectl log <POD_NAME>
d) kubectl logs <POD_NAME>

Answer:

d) kubectl logs <POD_NAME>

Explanation:

The kubectl logs command is used to retrieve logs from a specific pod.

18. What does 'K8s' stand for?

a) Kube 8 system
b) Kubernetes
c) Kubernet eight
d) Kube system

Answer:

b) Kubernetes

Explanation:

'K8s' is a numeronym for Kubernetes, where 8 stands for the number of letters between K and s.

19. Which command initializes a Kubernetes master node?

a) kubectl init
b) kubeadm setup
c) kubeadm init
d) kube-start master

Answer:

c) kubeadm init

Explanation:

kubeadm init is used to bootstrap the Kubernetes master node.

20. Which of the following is a best practice for storing secrets in Kubernetes?

a) Store them in a ConfigMap
b) Hardcode them in the Pod manifest
c) Use environment variables in a Pod
d) Use the Kubernetes Secret object

Answer:

d) Use the Kubernetes Secret object

Explanation:

Kubernetes 'Secret' object allows for more control over how sensitive information is stored and can be updated without redeploying pods.

21. How can you scale a deployment in Kubernetes?

a) kubectl scale deployment <DEPLOYMENT_NAME> –replicas=<NUMBER>
b) kubectl configure deployment <DEPLOYMENT_NAME> –replicas=<NUMBER>
c) kubectl update deployment <DEPLOYMENT_NAME> –replicas=<NUMBER>
d) kubectl set deployment <DEPLOYMENT_NAME> –replicas=<NUMBER>

Answer:

a) kubectl scale deployment <DEPLOYMENT_NAME> –replicas=<NUMBER>

Explanation:

The kubectl scale command allows you to adjust the number of replicas in a deployment.

22. Which Kubernetes feature allows you to automatically adjust the number of pod replicas based on CPU utilization or other select metric?

a) AutoScaling Group
b) ReplicaSet
c) Horizontal Pod Autoscaler (HPA)
d) Node Balancer

Answer:

c) Horizontal Pod Autoscaler (HPA)

Explanation:

HPA automatically scales the number of pods in a deployment or replica set based on observed metrics like CPU utilization.

23. Which command provides detailed information about a specific resource or group of resources in Kubernetes?

a) kubectl describe
b) kubectl info
c) kubectl details
d) kubectl show

Answer:

a) kubectl describe

Explanation:

The kubectl describe command provides detailed information about resources, including events associated with the resources.

24. How would you retrieve a list of all nodes in the cluster?

a) kubectl get nodes
b) kubectl describe nodes
c) kubectl list nodes
d) kubectl show nodes

Answer:

a) kubectl get nodes

Explanation:

The kubectl get nodes command provides a list of all nodes that belong to a Kubernetes cluster.

25. If you want to delete a service named "my-service", which command would you use?

a) kubectl remove service my-service
b) kubectl destroy service my-service
c) kubectl rm service my-service
d) kubectl delete service my-service

Answer:

d) kubectl delete service my-service

Explanation:

The kubectl delete command is used to delete resources either from a file, stdin, or specifying labels, names, resource selectors, or resources.


Leave a Comment

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

Scroll to Top