# Kubernetes Fundamentals Quiz - Section 1 ## Question 1 What is the correct way to create a new pod in Kubernetes using kubectl? - [ ] A) kubectl create pod nginx - [ ] B) kubectl run nginx --image=nginx - [ ] C) kubectl start nginx --image=nginx - [ ] D) kubectl deploy nginx-pod --image=nginx <details> <summary>Show Answer</summary> **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. </details> ## Question 2 What's the purpose of a ReplicaSet in Kubernetes? - [ ] A) To ensure a specified number of pod replicas are running at any time - [ ] B) To replicate data across multiple storage volumes - [ ] C) To copy configurations across different namespaces - [ ] D) To duplicate services across multiple clusters <details> <summary>Show Answer</summary> **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. </details> ## Question 3 Which component of Kubernetes is responsible for maintaining the desired state of the cluster? - [ ] A) kubelet - [ ] B) kube-proxy - [ ] C) kube-controller-manager - [ ] D) kube-scheduler <details> <summary>Show Answer</summary> **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. </details> ## Question 4 What is the difference between a Deployment and a StatefulSet? - [ ] A) Deployments are for stateless apps, StatefulSets for stateful apps - [ ] B) Deployments support rolling updates, StatefulSets don't - [ ] C) StatefulSets are deprecated, Deployments are the new standard - [ ] D) There is no difference, they are interchangeable <details> <summary>Show Answer</summary> **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. </details> ## Question 5 What Kubernetes resource would you use to expose a service externally using a load balancer? - [ ] A) ExternalName - [ ] B) NodePort - [ ] C) LoadBalancer - [ ] D) ClusterIP <details> <summary>Show Answer</summary> **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. </details> ## Question 6 Which of these correctly describes a Kubernetes namespace? - [ ] A) A virtual cluster inside your Kubernetes cluster - [ ] B) A networking segmentation tool - [ ] C) A type of container runtime - [ ] D) A storage class definition <details> <summary>Show Answer</summary> **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. </details> ## Question 7 What happens to the pods managed by a ReplicaSet when it is deleted? - [ ] A) Pods continue running - [ ] B) Pods are automatically deleted - [ ] C) Pods enter a suspended state - [ ] D) Pods are moved to another ReplicaSet <details> <summary>Show Answer</summary> **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. </details> ## Question 8 Which command shows the logs of a specific container in a multi-container pod? - [ ] A) kubectl logs pod-name - [ ] B) kubectl logs pod-name -c container-name - [ ] C) kubectl describe pod pod-name - [ ] D) kubectl get logs pod-name container-name <details> <summary>Show Answer</summary> **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. </details> ## Question 9 What is the purpose of a DaemonSet? - [ ] A) To run a Pod on all (or some) nodes in the cluster - [ ] B) To run system daemons - [ ] C) To manage stateful applications - [ ] D) To handle network routing <details> <summary>Show Answer</summary> **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. </details> ## Question 10 How do you scale a deployment named "nginx-deployment" to 5 replicas? - [ ] A) kubectl scale deployment nginx-deployment --replicas=5 - [ ] B) kubectl set replicas deployment/nginx-deployment 5 - [ ] C) kubectl deployment scale nginx-deployment --to=5 - [ ] D) kubectl edit deployment nginx-deployment replicas=5 <details> <summary>Show Answer</summary> **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. </details> # Kubernetes Fundamentals Quiz - Section 2 ## Question 11 What is the purpose of a Service Account in Kubernetes? - [ ] A) To authenticate human users - [ ] B) To provide an identity for pods running in the cluster - [ ] C) To manage billing information - [ ] D) To store sensitive credentials <details> <summary>Show Answer</summary> **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. </details> ## Question 12 Which Kubernetes primitive should you use to run a one-time task that exits upon completion? - [ ] A) Deployment - [ ] B) Job - [ ] C) CronJob - [ ] D) DaemonSet <details> <summary>Show Answer</summary> **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. </details> ## Question 13 What is the purpose of a PodDisruptionBudget? - [ ] A) To limit resource usage by pods - [ ] B) To ensure high availability during voluntary disruptions - [ ] C) To schedule pods on specific nodes - [ ] D) To manage pod networking policies <details> <summary>Show Answer</summary> **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. </details> ## Question 14 How do you apply a label to an existing pod? - [ ] A) kubectl label pod podname key=value - [ ] B) kubectl set label pod podname key=value - [ ] C) kubectl annotate pod podname key=value - [ ] D) kubectl tag pod podname key=value <details> <summary>Show Answer</summary> **Correct Answer: A) kubectl label pod podname key=value** The kubectl label command is used to add or update labels on existing resources. </details> ## Question 15 What is the purpose of the kube-proxy component? - [ ] A) To provide authentication services - [ ] B) To manage network rules for pod communication - [ ] C) To schedule pods on nodes - [ ] D) To manage container runtime <details> <summary>Show Answer</summary> **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. </details> ## Question 16 What command would you use to create a new namespace called "production"? - [ ] A) kubectl create production - [ ] B) kubectl create namespace production - [ ] C) kubectl namespace new production - [ ] D) kubectl new namespace production <details> <summary>Show Answer</summary> **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. </details> ## Question 17 How do you create a ConfigMap from a file? - [ ] A) kubectl apply configmap --from-file=config.properties - [ ] B) kubectl create configmap myconfig --from-file=config.properties - [ ] C) kubectl config create --from-file=config.properties - [ ] D) kubectl create config --file=config.properties <details> <summary>Show Answer</summary> **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. </details> ## Question 18 What is the purpose of a Pod's readiness probe? - [ ] A) To determine if a pod should be restarted - [ ] B) To check if a pod is ready to accept traffic - [ ] C) To monitor pod resource usage - [ ] D) To verify pod security settings <details> <summary>Show Answer</summary> **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. </details> ## Question 19 Which of these storage options provides persistent storage that survives pod restarts? - [ ] A) emptyDir - [ ] B) PersistentVolume - [ ] C) hostPath - [ ] D) configMap <details> <summary>Show Answer</summary> **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. </details> ## Question 20 What is the purpose of a NetworkPolicy? - [ ] A) To configure cluster networking - [ ] B) To define pod-to-pod communication rules - [ ] C) To set up load balancing - [ ] D) To manage external access to services <details> <summary>Show Answer</summary> **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. </details> # Kubernetes Fundamentals Quiz - Section 3 ## Question 21 What is the purpose of a HorizontalPodAutoscaler? - [ ] A) To automatically scale nodes in the cluster - [ ] B) To automatically scale the number of pods based on resource usage - [ ] C) To manage pod placement across nodes - [ ] D) To scale persistent volumes <details> <summary>Show Answer</summary> **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. </details> ## Question 22 Which command is used to create a secret from literal values? - [ ] A) kubectl create secret generic mysecret --from-literal=password=mypass - [ ] B) kubectl apply secret mysecret --value=password=mypass - [ ] C) kubectl secret create mysecret password=mypass - [ ] D) kubectl create mysecret --from-literal=password=mypass <details> <summary>Show Answer</summary> **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". </details> ## Question 23 Omitted. ## Question 24 How do you forcefully delete a pod without waiting for graceful termination? - [ ] A) kubectl delete pod mypod --force - [ ] B) kubectl delete pod mypod --grace-period=0 --force - [ ] C) kubectl remove pod mypod --now - [ ] D) kubectl terminate pod mypod <details> <summary>Show Answer</summary> **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. </details> ## Question 25 What is the purpose of a Service's sessionAffinity field? - [ ] A) To maintain persistent storage - [ ] B) To keep user sessions on the same pod - [ ] C) To manage service accounts - [ ] D) To configure load balancing algorithms <details> <summary>Show Answer</summary> **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. </details> ## Question 26 Which component is responsible for container runtime operations? - [ ] A) kube-scheduler - [ ] B) kubelet - [ ] C) kube-proxy - [ ] D) controller-manager <details> <summary>Show Answer</summary> **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. </details> ## Question 27 What is the purpose of a RoleBinding? - [ ] A) To define permissions - [ ] B) To assign roles to users or service accounts - [ ] C) To create new roles - [ ] D) To manage pod scheduling <details> <summary>Show Answer</summary> **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. </details> ## Question 28 How do you view the current resource usage of nodes? - [ ] A) kubectl top nodes - [ ] B) kubectl describe nodes - [ ] C) kubectl get nodes --show-metrics - [ ] D) kubectl metrics nodes <details> <summary>Show Answer</summary> **Correct Answer: A) kubectl top nodes** The kubectl top nodes command shows the resource usage (CPU and memory) of nodes in the cluster. </details> ## Question 29 What is the purpose of an Init Container? - [ ] A) To run setup tasks before app containers start - [ ] B) To initialize the Kubernetes cluster - [ ] C) To create initial pod configurations - [ ] D) To start the container runtime <details> <summary>Show Answer</summary> **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. </details> ## Question 30 Which field in a pod specification ensures the pod is scheduled on a specific node? - [ ] A) nodeSelector - [ ] B) nodeName - [ ] C) hostName - [ ] D) schedulerName <details> <summary>Show Answer</summary> **Correct Answer: B) nodeName** The nodeName field directly specifies which node the pod should be scheduled on, bypassing the scheduler entirely. </details> # Kubernetes Fundamentals Quiz - Section 4 ## Question 31 What is the purpose of a Taint in Kubernetes? - [ ] A) To mark a node as preferred for certain pods - [ ] B) To prevent pods from being scheduled on a node - [ ] C) To isolate network traffic - [ ] D) To mark pods as vulnerable <details> <summary>Show Answer</summary> **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. </details> ## Question 32 Which command would you use to get the YAML definition of a running pod? - [ ] A) kubectl get pod mypod -o yaml - [ ] B) kubectl describe pod mypod --yaml - [ ] C) kubectl pod mypod --output=yaml - [ ] D) kubectl yaml pod mypod <details> <summary>Show Answer</summary> **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. </details> ## Question 33 What is the purpose of a ResourceQuota? - [ ] A) To limit resource usage within a namespace - [ ] B) To request resources for pods - [ ] C) To monitor resource availability - [ ] D) To allocate resources to nodes <details> <summary>Show Answer</summary> **Correct Answer: A) To limit resource usage within a namespace** ResourceQuotas provide constraints that limit aggregate resource consumption per namespace, helping maintain cluster stability. </details> ## Question 34 How do you view logs from a previous instance of a pod? - [ ] A) kubectl logs mypod --history - [ ] B) kubectl logs mypod --previous - [ ] C) kubectl logs mypod --old - [ ] D) kubectl logs mypod -p <details> <summary>Show Answer</summary> **Correct Answer: B) / D) kubectl logs mypod --previous** The --previous (-p abbreviated) flag allows you to see logs from a previous instance of a container in the pod if it has been restarted. </details> ## Question 35 What is the purpose of a LimitRange? - [ ] A) To set default resource limits for pods - [ ] B) To limit cluster size - [ ] C) To restrict network bandwidth - [ ] D) To control pod scaling limits <details> <summary>Show Answer</summary> **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. </details> ## Question 36 Which component manages load balancing of service traffic? - [ ] A) kube-proxy - [ ] B) kubelet - [ ] C) service-proxy - [ ] D) load-balancer <details> <summary>Show Answer</summary> **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. </details> ## Question 37 Omitted. ## Question 38 How do you update a deployment's image without downtime? - [ ] A) kubectl set image deployment/myapp container=newimage - [ ] B) kubectl update deployment myapp --image=newimage - [ ] C) kubectl rolling-update myapp --image=newimage - [ ] D) kubectl deploy myapp --image=newimage --rolling <details> <summary>Show Answer</summary> **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. </details> ## Question 39 What is the purpose of a StorageClass? - [ ] A) To define different types of storage - [ ] B) To classify pod storage requirements - [ ] C) To manage storage drivers - [ ] D) To limit storage usage <details> <summary>Show Answer</summary> **Correct Answer: A) To define different types of storage** StorageClasses provide a way to describe the different "classes" of storage offered by cluster administrators. </details> ## Question 40 Which feature ensures pods are distributed across nodes in the cluster? - [ ] A) Pod anti-affinity - [ ] B) Node selector - [ ] C) Pod affinity - [ ] D) Node affinity <details> <summary>Show Answer</summary> **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. </details> # Kubernetes Fundamentals Quiz - Section 5 ## Question 41 What is the purpose of a CustomResourceDefinition (CRD)? - [ ] A) To define custom resources in Kubernetes - [ ] B) To create custom commands - [ ] C) To modify existing resources - [ ] D) To customize the API server <details> <summary>Show Answer</summary> **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. </details> ## Question 42 How do you create a static pod? - [ ] A) Place pod manifest in the static pod path - [ ] B) Use kubectl create static pod - [ ] C) Add static label to pod - [ ] D) Use static namespace <details> <summary>Show Answer</summary> **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. </details> ## Question 43 What is the purpose of a ValidatingWebhookConfiguration? - [ ] A) To validate API requests before persistence - [ ] B) To validate pod configurations - [ ] C) To verify user credentials - [ ] D) To check node health <details> <summary>Show Answer</summary> **Correct Answer: A) To validate API requests before persistence** ValidatingWebhookConfiguration defines webhooks that intercept and validate API requests before they are persisted to etcd. </details> ## Question 44 Which command shows the events in a namespace? - [ ] A) kubectl get events - [ ] B) kubectl describe events - [ ] C) kubectl show events - [ ] D) kubectl list events <details> <summary>Show Answer</summary> **Correct Answer: A) kubectl get events** kubectl get events shows all events in the current namespace, helping with debugging and monitoring cluster state. </details> ## Question 45 What is the purpose of the pause container? - [ ] A) To hold pod namespace and networking - [ ] B) To pause pod execution - [ ] C) To debug containers - [ ] D) To store container images <details> <summary>Show Answer</summary> **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. </details> ## Question 46 How do you perform a rollback of a deployment? - [ ] A) kubectl rollout undo deployment/myapp - [ ] B) kubectl deployment rollback myapp - [ ] C) kubectl undo deployment myapp - [ ] D) kubectl revert deployment/myapp <details> <summary>Show Answer</summary> **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. </details> ## Question 47 What's the purpose of a MutatingWebhookConfiguration? - [ ] A) To modify objects before they are stored - [ ] B) To validate object configurations - [ ] C) To mutate pod specifications - [ ] D) To change running containers <details> <summary>Show Answer</summary> **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. </details> ## Question 48 What is the purpose of a PodDisruptionBudget's minAvailable field? - [ ] A) To specify minimum pods that must be available during disruption - [ ] B) To set minimum pod resources - [ ] C) To define minimum pod replicas - [ ] D) To set minimum node availability <details> <summary>Show Answer</summary> **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. </details> ## Question 49 Which component is responsible for cluster DNS services? - [ ] A) CoreDNS - [ ] B) kube-dns - [ ] C) dns-controller - [ ] D) Both A and B are correct <details> <summary>Show Answer</summary> **Correct Answer: D) Both A and B are correct** Both CoreDNS (newer) and kube-dns (older and deprecated) can provide DNS services in a Kubernetes cluster, with CoreDNS being the default since Kubernetes 1.13. </details> ## Question 50 What is the purpose of a cluster-autoscaler? - [ ] A) To automatically adjust the number of nodes in the cluster - [ ] B) To scale pod replicas - [ ] C) To adjust resource limits - [ ] D) To scale persistent volumes <details> <summary>Show Answer</summary> **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. </details>