Complete the code to specify the desired number of replicas in a Kubernetes Deployment manifest.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: [1]
selector:
matchLabels:
app: my-appThe replicas field defines the desired number of pod copies. Setting it to 5 means Kubernetes will try to keep 5 pods running.
Complete the command to check the actual state of pods in the default namespace.
kubectl get [1]The kubectl get pods command lists all pods, showing the actual running state.
Fix the error in the command to apply a manifest file named deployment.yaml.
kubectl [1] -f deployment.yamlThe kubectl apply -f command applies changes from a manifest file to the cluster, updating the desired state.
Fill both blanks to create a label selector that matches pods with label app=web and environment=prod.
kubectl get pods -l [1]=[2]
The label selector app=web filters pods with label key 'app' and value 'web'.
Note: This task only fills one label selector; to filter both labels, you would combine selectors with commas.
Fill all three blanks to create a dictionary comprehension that maps pod names to their status phase if the phase is Running.
pod_status = {pod.metadata.name: pod.status.[1] for pod in pods if pod.status.[2] == '[3]'}This comprehension creates a dictionary of pod names to their phase, but only includes pods where the phase is 'Running'.