
































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































































Question 1. Which of the following Kubernetes objects is used to ensure that a specified number of pod replicas are running at any given time? A) Service B) Deployment C) Namespace D) ConfigMap Answer: B Explanation: A Deployment manages a set of identical pods, ensuring that a specified number of replicas are always running and available. Question 2. What is the default namespace in a Kubernetes cluster when no namespace is specified? A) kube-public B) kube-system C) default D) user Answer: C Explanation: The 'default' namespace is used if no namespace is specified when creating resources. Question 3. Which kubectl command would you use to create a resource from a YAML file? A) kubectl apply - f B) kubectl get - f C) kubectl expose - f D) kubectl delete - f Answer: A Explanation: 'kubectl apply - f' applies the configuration in a YAML file to the cluster. Question 4. What does the 'Pending' pod phase indicate? A) The pod is running with all containers healthy B) The pod has completed execution
C) The pod is scheduled but not yet running D) The pod has failed Answer: C Explanation: 'Pending' means the pod has been accepted by the cluster but not all containers are running. Question 5. Which Kubernetes object exposes pods to external traffic? A) Deployment B) ConfigMap C) Service D) ReplicaSet Answer: C Explanation: A Service enables network access to a set of pods. Question 6. How do you list all pods in all namespaces using kubectl? A) kubectl get pods B) kubectl get pods --all C) kubectl get pods - A D) kubectl list pods Answer: C Explanation: 'kubectl get pods - A' lists pods in all namespaces. Question 7. Which field in a Deployment manifest specifies the Docker image for the application? A) metadata.image B) spec.image C) spec.template.spec.containers.image D) containers.image Answer: C Explanation: The image is specified under 'spec.template.spec.containers.image'.
C) ConfigMap data is encrypted D) Both store sensitive data Answer: B Explanation: Secrets are intended for sensitive data and are stored base64-encoded. Question 12. Which field in a Pod manifest sets the Linux user ID for the container? A) runAsUser B) userName C) userID D) securityUser Answer: A Explanation: 'runAsUser' sets the Linux user ID under 'securityContext'. Question 13. What is the purpose of a ServiceAccount? A) To limit resource usage B) To provide identity and permissions for pods C) To expose services to the internet D) To store configuration data Answer: B Explanation: ServiceAccounts provide an identity for processes in pods to interact with the Kubernetes API. Question 14. Which type of container runs and completes its task before application containers start in a Pod? A) Sidecar B) Main C) Init Container D) Adapter Answer: C
Explanation: Init Containers run before the main application containers and must complete before they start. Question 15. What is the main role of a Sidecar container? A) Serve as the main application B) Prepare data for the main container C) Run alongside the main container to provide a supporting function D) Expose the pod to the internet Answer: C Explanation: Sidecar containers provide supporting features, like logging, proxies, etc. Question 16. How do you check 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-name] D) kubectl get logs Answer: B Explanation: '-c [container-name]' specifies which container's logs to view. Question 17. What is a 'Readiness Probe' used for in a pod? A) To check if the pod is running B) To restart failed containers C) To determine if a container is ready to accept traffic D) To check resource usage Answer: C Explanation: Readiness probes indicate if a container is ready to serve traffic. Question 18. Which probe can be used to automatically restart a container if it becomes unhealthy? A) Readiness
Explanation: Namespaces logically isolate resources within a Kubernetes cluster. Question 22. How do you delete a Kubernetes deployment named "webapp"? A) kubectl remove deployment webapp B) kubectl delete deployment webapp C) kubectl destroy deployment webapp D) kubectl erase deployment webapp Answer: B Explanation: 'kubectl delete deployment [name]' deletes the specified deployment. Question 23. What is the default restart policy for a Kubernetes pod? A) Never B) OnFailure C) Always D) Manual Answer: C Explanation: The default restart policy for pods is 'Always'. Question 24. Which resource is used to provide persistent storage to pods? A) ConfigMap B) Secret C) PersistentVolumeClaim D) Namespace Answer: C Explanation: PersistentVolumeClaim requests persistent storage for pods. Question 25. What type of Service provides a stable IP address and DNS name within the cluster? A) ClusterIP
B) NodePort C) LoadBalancer D) ExternalName Answer: A Explanation: ClusterIP provides a stable internal IP and DNS for accessing services within the cluster. Question 26. Which of the following is NOT a valid pod phase? A) Running B) Pending C) Stopped D) Succeeded Answer: C Explanation: 'Stopped' is not a valid pod phase; valid phases are Pending, Running, Succeeded, Failed, Unknown. Question 27. Where does a Secret store its data? A) In plain text B) In base64-encoded format C) In JSON format D) In encrypted format Answer: B Explanation: Secrets store data base64-encoded. Question 28. Which field in a container specification sets the resource limits? A) resources.limits B) resources.requests C) spec.limits D) metadata.limits Answer: A
B) kubectl get pod my-pod - o yaml C) kubectl describe pod my-pod D) kubectl yaml pod my-pod Answer: B Explanation: '-o yaml' outputs the YAML definition of the resource. Question 33. What is the function of a Deployment's 'replicas' field? A) Number of containers per pod B) Number of pods to maintain C) Number of services D) Number of namespaces Answer: B Explanation: The 'replicas' field specifies how many pod replicas the deployment should maintain. Question 34. How can a pod consume a ConfigMap as environment variables? A) Using envFrom in the container spec B) Using volumes C) Using ports D) Using resources Answer: A Explanation: 'envFrom' in the container spec references a ConfigMap as environment variables. Question 35. Which command lists all deployments in the current namespace? A) kubectl get all B) kubectl get deployments C) kubectl show deployments D) kubectl get pods Answer: B
Explanation: 'kubectl get deployments' lists all deployments in the current namespace. Question 36. What does 'kubectl apply' do if a resource already exists? A) Fails with error B) Updates the resource C) Ignores the request D) Deletes and recreates the resource Answer: B Explanation: 'kubectl apply' updates the resource to match the manifest. Question 37. Which field in a Pod manifest is used to specify the container's working directory? A) workingDir B) dir C) workDir D) containerDir Answer: A Explanation: 'workingDir' sets the working directory for the container. Question 38. What is a major benefit of using declarative YAML files for resource management? A) Manual scaling B) Version control and repeatability C) Faster deployment D) No need for kubelet Answer: B Explanation: YAML files provide version control and can be reused for reproducible deployments. Question 39. How do you expose a deployment as a new service on port 80? A) kubectl expose deployment [name] --port=
Explanation: 'kubectl exec [pod] -- /bin/sh' starts a shell in the container. Question 43. What is the maximum number of containers you can run in a single pod? A) 1 B) 2 C) No fixed limit D) 5 Answer: C Explanation: There is no strict limit, but practical limits depend on node resources. Question 44. Which field under 'securityContext' elevates container privileges? A) runAsUser B) privileged C) allowPrivilegeEscalation D) capabilities Answer: B Explanation: 'privileged: true' runs the container in privileged mode. Question 45. What is the default type of Kubernetes Service? A) LoadBalancer B) NodePort C) ClusterIP D) ExternalName Answer: C Explanation: ClusterIP is the default Service type. Question 46. What command creates a Secret from a literal value? A) kubectl create secret generic mysecret --from-literal=key=value
B) kubectl apply secret mysecret --from-literal=key=value C) kubectl add secret mysecret --from-literal=key=value D) kubectl expose secret mysecret --from-literal=key=value Answer: A Explanation: 'kubectl create secret generic' with '--from-literal' creates a Secret from a value. Question 47. What is the correct way to set a resource request for memory in a container? A) resources.requests.memory B) memory.requests C) requests.resources.memory D) resources.memory.requests Answer: A Explanation: 'resources.requests.memory' sets the memory request. Question 48. What does 'kubectl rollout status deployment/myapp' show? A) Status of pod scaling B) Status of deployment rollout C) Logs of the deployment D) Status of services Answer: B Explanation: It shows the rollout (update) status for the deployment. Question 49. Which is NOT a common multi-container pod pattern? A) Sidecar B) Init Container C) Load Balancer D) Adapter Answer: C
B) kube-apiserver C) kubelet D) etcd Answer: C Explanation: kubelet runs on each node and manages pods. Question 54. How do you specify a container's command in a Pod manifest? A) entrypoint B) command C) run D) exec Answer: B Explanation: 'command' overrides the container's entrypoint. Question 55. Which field in a Pod manifest sets environment variables? A) env B) environment C) variables D) config Answer: A Explanation: 'env' specifies environment variables for the container. Question 56. How can you specify multiple containers in a pod? A) containers: [ ... ] B) containers:
Answer: B Explanation: Multiple containers are listed under 'containers' as YAML list items. Question 57. What type of Service allows inbound connections to a cluster node's IP at a specific port? A) LoadBalancer B) ClusterIP C) NodePort D) ExternalName Answer: C Explanation: NodePort exposes the service on a node IP and port. Question 58. How do you mount a ConfigMap as a volume in a pod? A) Use configMap under volumes B) Use configVolume C) Use mountConfig D) Use envFrom Answer: A Explanation: 'configMap' under 'volumes' mounts a ConfigMap as a volume. Question 59. What does 'kubectl delete pod [pod-name]' do? A) Deletes the pod and its deployment B) Deletes the specified pod C) Deletes all pods D) Deletes the Service Answer: B Explanation: It deletes the specified pod. Question 60. Which object can be used to control access to Kubernetes API resources?
Answer: B Explanation: ReplicaSet ensures a specified number of pod replicas are running. Question 64. What is a DaemonSet? A) Deploys pods to every node B) Scales pods automatically C) Exposes pods D) Schedules jobs Answer: A Explanation: DaemonSets ensure a pod runs on every node. Question 65. What does the 'hostPort' field do in a pod spec? A) Opens a port on the host node for pod traffic B) Exposes a service externally C) Sets container port D) Assigns a NodePort Answer: A Explanation: 'hostPort' maps a container port directly to a host node port. Question 66. Which resource is best for one-time jobs? A) Deployment B) ReplicaSet C) Job D) DaemonSet Answer: C Explanation: Jobs run one-off tasks to completion. Question 67. How do you view events in the cluster?
A) kubectl get events B) kubectl describe events C) kubectl show events D) kubectl view events Answer: A Explanation: 'kubectl get events' lists cluster events. Question 68. What does 'kubectl rollout undo deployment/myapp' do? A) Deletes the deployment B) Rolls back to the previous deployment revision C) Restarts the deployment D) Deletes all pods Answer: B Explanation: It rolls back the last deployment update. Question 69. How do you specify a container's image pull policy? A) imagePullPolicy B) imagePolicy C) pullPolicy D) imagePull Answer: A Explanation: 'imagePullPolicy' specifies when the image is pulled. Question 70. Which field sets the minimum number of seconds a pod must be ready before it is considered available? A) minReadySeconds B) minAvailableSeconds C) readinessSeconds D) minSeconds