Kubernetes Pods III
1.
How can you view the logs of a specific container within a multi-container pod?
kubectl logs pod-name
kubectl logs container-name pod-name
kubectl describe pod pod-name
Logs cannot be viewed for specific containers
2.
How can you set resource limits for a pod across all containers using a resource quota?
Use the `resources` field in the pod manifest
Reference the resource quota in the `limits` field
Resource limits cannot be set using resource quotas
Use the `quota` field in the pod manifest
3.
How can you scale the number of replicas in a StatefulSet?
kubectl scale statefulset
Updating the replicas field in the StatefulSet manifest
StatefulSets cannot have multiple replicas
Using the `kubectl set replicas` command
4.
How can you check the events related to a pod?
kubectl get events
kubectl describe pod events
kubectl pod events
kubectl events pod-name
5.
What is the purpose of the `affinity` and `anti-affinity` rules in a pod manifest?
To express preferences for scheduling a pod on specific nodes
To define the container's resource requirements
To specify network policies for the pod
There is no such concept
6.
How can you set environment variables for all containers in a pod using a ConfigMap?
Use the `env` field in the pod manifest
Reference the ConfigMap in the `env` field
Environment variables cannot be set using ConfigMaps
Use the `config` field in the pod manifest
7.
What is the purpose of the `securityContext` field in a container spec?
To define security policies for the entire pod
To set resource limits for the container
To specify container runtime parameters
There is no such field
8.
Which Kubernetes object is used to manage the deployment of stateless applications and ensures a specified number of replicas are running?
Pod
Deployment
Service
StatefulSet
9.
What is the purpose of the `nodeName` field in a pod manifest?
To specify the preferred node for scheduling the pod
To define the hostname of the pod
To indicate the node on which the pod is currently running
There is no such field
10.
How can you perform a rolling update of a deployment with a new image version?
kubectl update deployment
kubectl apply -f new-deployment.yaml
kubectl set image deployment
Rolling updates are not supported in Kubernetes
11.
What is the purpose of the `readinessProbe` in a pod manifest?
To determine if the pod can receive traffic
To check if the pod is running
To monitor resource usage
To restart the pod
12.
How can you expose a pod to the external world using a LoadBalancer service?
By specifying `serviceType: LoadBalancer` in the pod manifest
By using the `kubectl expose` command
LoadBalancer services cannot expose pods
By setting `external: true` in the pod manifest
13.
What happens if a pod's `livenessProbe` fails repeatedly?
The pod is terminated and automatically restarted
The pod continues running, but marked as unhealthy
The liveness probe has no effect on the pod
The pod is isolated from the network
14.
What is the purpose of the `imagePullPolicy` field in a container spec?
To specify the container's image registry
To determine when to pull the container image
To set the policy for pushing container images
There is no such field
15.
How can you execute a command within a running container in a pod?
kubectl exec
kubectl run
kubectl attach
kubectl command
16.
What is the purpose of the `tolerations` field in a pod manifest?
To express affinity towards certain nodes
To specify container affinity
To indicate pod affinity
To tolerate specified node taints
17.
What is the purpose of the `EmptyDir` volume type in a pod?
To create an empty directory in the host machine
To share files between containers in the same pod
To provide persistent storage for a pod
To temporarily store data that is deleted when the pod is restarted
18.
How can you specify the DNS policy for a pod?
Use the `dnsPolicy` field in the pod manifest
Specify it in the `containers` field
DNS policy cannot be configured for a pod
Use the `kubectl dns-policy` command
19.
What is the purpose of the `restartPolicy` field in a pod manifest?
To control when a pod should be restarted
To define the number of restarts allowed for the pod
To specify the restart behavior for containers
There is no such field