What is the correct way to create a new pod in Kubernetes using kubectl?
Correct Answer: B) kubectl run nginx –image=nginx
This is the simplest way to create a single pod running the nginx image. The kubectl run
command creates a pod directly, while other options are either incorrect syntax or create different resources.
What's the purpose of a ReplicaSet in Kubernetes?
Correct Answer: A) To ensure a specified number of pod replicas are running at any time
A ReplicaSet's main purpose is to maintain a stable set of replica Pods running at any given time. It guarantees the availability of a specified number of identical Pods.
Which component of Kubernetes is responsible for maintaining the desired state of the cluster?
Correct Answer: C) kube-controller-manager
The kube-controller-manager runs controller processes that regulate the state of the cluster. It ensures that the cluster's current state matches the desired state specified in the control plane.
What is the difference between a Deployment and a StatefulSet?
Correct Answer: A) Deployments are for stateless apps, StatefulSets for stateful apps
StatefulSets are used for applications that require stable network identifiers, persistent storage, and ordered deployment and scaling, while Deployments are ideal for stateless applications.
What Kubernetes resource would you use to expose a service externally using a load balancer?
Correct Answer: C) LoadBalancer
The LoadBalancer service type creates an external load balancer in the cloud provider and assigns a fixed, external IP to the service.
Which of these correctly describes a Kubernetes namespace?
Correct Answer: A) A virtual cluster inside your Kubernetes cluster
Namespaces provide a mechanism for isolating groups of resources within a single cluster, acting as virtual clusters within a physical cluster.
What happens to the pods managed by a ReplicaSet when it is deleted?
Correct Answer: B) Pods are automatically deleted
When a ReplicaSet is deleted, all pods managed by it are also deleted by default, unless the cascading deletion is explicitly disabled.
Which command shows the logs of a specific container in a multi-container pod?
Correct Answer: B) kubectl logs pod-name -c container-name
The -c flag specifies which container's logs to show when a pod has multiple containers.
What is the purpose of a DaemonSet?
Correct Answer: A) To run a Pod on all (or some) nodes in the cluster
A DaemonSet ensures that all (or some) nodes run a copy of a Pod. Common uses include running cluster storage daemons or log collection daemons on every node.
How do you scale a deployment named "nginx-deployment" to 5 replicas?
Correct Answer: A) kubectl scale deployment nginx-deployment –replicas=5
This is the standard way to scale a deployment. It updates the desired number of replicas in the deployment specification.
What is the purpose of a Service Account in Kubernetes?
Correct Answer: B) To provide an identity for pods running in the cluster
Service Accounts provide an identity for processes running in a Pod to authenticate with the Kubernetes API server and interact with other cluster resources.
Which Kubernetes primitive should you use to run a one-time task that exits upon completion?
Correct Answer: B) Job
Jobs are perfect for running one-off tasks that should complete successfully and then stop, unlike Deployments which are meant for long-running processes.
What is the purpose of a PodDisruptionBudget?
Correct Answer: B) To ensure high availability during voluntary disruptions
PodDisruptionBudgets limit the number of pods that can be simultaneously down during voluntary disruptions, helping maintain application availability.
How do you apply a label to an existing pod?
Correct Answer: A) kubectl label pod podname key=value
The kubectl label command is used to add or update labels on existing resources.
What is the purpose of the kube-proxy component?
Correct Answer: B) To manage network rules for pod communication
kube-proxy maintains network rules on nodes that allow network communication to pods from inside or outside the cluster.
What command would you use to create a new namespace called "production"?
Correct Answer: B) kubectl create namespace production
The kubectl create namespace command is used to create a new namespace. This creates an isolated environment for resources within your cluster.
How do you create a ConfigMap from a file?
Correct Answer: B) kubectl create configmap myconfig –from-file=config.properties
This command creates a ConfigMap named "myconfig" with the contents of the config.properties file.
What is the purpose of a Pod's readiness probe?
Correct Answer: B) To check if a pod is ready to accept traffic
Readiness probes determine when a pod is ready to accept traffic. A pod is considered ready when all of its containers are ready.
Which of these storage options provides persistent storage that survives pod restarts?
Correct Answer: B) PersistentVolume
PersistentVolumes provide a way to store data that persists beyond the lifecycle of a pod and can survive pod restarts or rescheduling.
What is the purpose of a NetworkPolicy?
Correct Answer: B) To define pod-to-pod communication rules
NetworkPolicies specify how groups of pods are allowed to communicate with each other and other network endpoints.
What is the purpose of a HorizontalPodAutoscaler?
Correct Answer: B) To automatically scale the number of pods based on resource usage
HorizontalPodAutoscaler automatically scales the number of pods in a deployment, replication controller, or replica set based on observed CPU utilization or other metrics.
Which command is used to create a secret from literal values?
Correct Answer: A) kubectl create secret generic mysecret –from-literal=password=mypass
This command creates a secret named "mysecret" with a key-value pair where the key is "password" and the value is "mypass".
What is the purpose of a PodSecurityPolicy?
Correct Answer: B) To define a set of conditions that a pod must run with
PodSecurityPolicies define a set of conditions that a pod must run with in order to be accepted into the system, controlling security-sensitive aspects of pod specification.
How do you forcefully delete a pod without waiting for graceful termination?
Correct Answer: B) kubectl delete pod mypod –grace-period=0 –force
This command forcefully deletes the pod without waiting for graceful termination. The –grace-period=0 sets the termination period to 0 seconds.
What is the purpose of a Service's sessionAffinity field?
Correct Answer: B) To keep user sessions on the same pod
When sessionAffinity is set to "ClientIP", the service will route all requests from the same client IP to the same pod.
Which component is responsible for container runtime operations?
Correct Answer: B) kubelet
The kubelet is the primary node agent that runs on each node. It ensures containers are running in a pod and handles container runtime operations.
What is the purpose of a RoleBinding?
Correct Answer: B) To assign roles to users or service accounts
RoleBinding binds a Role or ClusterRole to users, groups, or service accounts, granting them the permissions defined in the role.
How do you view the current resource usage of nodes?
Correct Answer: A) kubectl top nodes
The kubectl top nodes command shows the resource usage (CPU and memory) of nodes in the cluster.
What is the purpose of an Init Container?
Correct Answer: A) To run setup tasks before app containers start
Init Containers run and complete before the app containers are started, perfect for setup tasks like database schema creation or waiting for dependencies.
Which field in a pod specification ensures the pod is scheduled on a specific node?
Correct Answer: B) nodeName
The nodeName field directly specifies which node the pod should be scheduled on, bypassing the scheduler entirely.
What is the purpose of a Taint in Kubernetes?
Correct Answer: B) To prevent pods from being scheduled on a node
Taints prevent pods from being scheduled on nodes unless the pods have matching tolerations, allowing nodes to repel certain pods.
Which command would you use to get the YAML definition of a running pod?
Correct Answer: A) kubectl get pod mypod -o yaml
This command outputs the complete YAML definition of the specified pod, including its current state and specifications.
What is the purpose of a ResourceQuota?
Correct Answer: A) To limit resource usage within a namespace
ResourceQuotas provide constraints that limit aggregate resource consumption per namespace, helping maintain cluster stability.
How do you view logs from a previous instance of a pod?
Correct Answer: B) kubectl logs mypod –previous
The –previous flag allows you to see logs from a previous instance of a container in the pod if it has been restarted.
What is the purpose of a LimitRange?
Correct Answer: A) To set default resource limits for pods
LimitRange provides constraints on resource allocations (limits and requests) for each type of resource in a namespace.
Which component manages load balancing of service traffic?
Correct Answer: A) kube-proxy
kube-proxy maintains network rules on nodes that allow network communication to your Pods from network sessions inside or outside of your cluster.
What is the purpose of a PodPreset?
Correct Answer: A) To inject common pod configurations
PodPresets are objects that inject certain information into pods at creation time, such as secrets, volumes, or environment variables.
How do you update a deployment's image without downtime?
Correct Answer: A) kubectl set image deployment/myapp container=newimage
This command performs a rolling update, updating pods gradually to ensure zero downtime during the update process.
What is the purpose of a StorageClass?
Correct Answer: A) To define different types of storage
StorageClasses provide a way to describe the different "classes" of storage offered by cluster administrators.
Which feature ensures pods are distributed across nodes in the cluster?
Correct Answer: A) Pod anti-affinity
Pod anti-affinity can be used to ensure that pods are scheduled on different nodes, helping to distribute the workload across the cluster.
What is the purpose of a CustomResourceDefinition (CRD)?
Correct Answer: A) To define custom resources in Kubernetes
CRDs allow you to define your own custom resources, extending the Kubernetes API with new types of objects specific to your needs.
How do you create a static pod?
Correct Answer: A) Place pod manifest in the static pod path
Static pods are created by placing a pod definition file in the designated static pod path on a node, which is watched by the kubelet.
What is the purpose of a ValidatingWebhookConfiguration?
Correct Answer: A) To validate API requests before persistence
ValidatingWebhookConfiguration defines webhooks that intercept and validate API requests before they are persisted to etcd.
Which command shows the events in a namespace?
Correct Answer: A) kubectl get events
kubectl get events shows all events in the current namespace, helping with debugging and monitoring cluster state.
What is the purpose of the pause container?
Correct Answer: A) To hold pod namespace and networking
The pause container serves as the parent container in a pod, holding the network namespace and other resources that are shared by all containers in the pod.
How do you perform a rollback of a deployment?
Correct Answer: A) kubectl rollout undo deployment/myapp
This command rolls back a deployment to its previous version. You can also specify a specific revision using –to-revision.
What's the purpose of a MutatingWebhookConfiguration?
Correct Answer: A) To modify objects before they are stored
MutatingWebhookConfiguration defines webhooks that can modify objects before they are persisted, allowing for automatic modifications to resources.
What is the purpose of a PodDisruptionBudget's minAvailable field?
Correct Answer: A) To specify minimum pods that must be available during disruption
minAvailable specifies the minimum number of pods that must remain available during voluntary disruptions, ensuring service availability.
Which component is responsible for cluster DNS services?
Correct Answer: D) Both A and B are correct
Both CoreDNS (newer) and kube-dns (older) can provide DNS services in a Kubernetes cluster, with CoreDNS being the default since Kubernetes 1.13.
What is the purpose of a cluster-autoscaler?
Correct Answer: A) To automatically adjust the number of nodes in the cluster
The cluster-autoscaler automatically adjusts the size of the Kubernetes cluster based on resource demands and configured policies.