Complete the code to create a Kubernetes pod manifest with a single container.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: [1]The image field specifies the container image to run inside the pod. 'nginx' is a valid container image name.
Complete the command to list all pods in the default namespace.
kubectl [1] podsThe kubectl get pods command lists all pods in the current namespace.
Fix the error in the command to apply a configuration file named pod.yaml.
kubectl [1] -f pod.yamlThe kubectl apply -f command applies changes from a configuration file to the cluster.
Fill both blanks to create a service that exposes pods on port 80.
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: [1]
ports:
- protocol: TCP
port: [2]The selector matches pods labeled 'app: webapp'. The port 80 exposes the service on HTTP default port.
Fill all three blanks to create a deployment with 3 replicas of nginx pods.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: [1] selector: matchLabels: app: [2] template: metadata: labels: app: [3] spec: containers: - name: nginx image: nginx
The deployment runs 3 replicas. The label app: nginx is used consistently to match pods and selector.