Complete the code to create a Kubernetes Pod that runs the nginx container.
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx
image: [1]The image field specifies the container image to run. For a web server, nginx:latest is correct.
Complete the code to expose the nginx Pod with a Service of type LoadBalancer.
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
type: [1]
ports:
- protocol: TCP
port: 80
targetPort: 80The LoadBalancer type exposes the service externally using a cloud provider's load balancer.
Fix the error in the Deployment spec to ensure the container restarts automatically.
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest restartPolicy: [1]
In a Deployment, the restartPolicy must be Always to ensure containers restart automatically on failure.
Fill both blanks to create a readiness probe that checks HTTP on port 80.
readinessProbe:
httpGet:
path: [1]
port: [2]The readiness probe uses the path /healthz and port 80 to check if the container is ready.
Fill all three blanks to define resource limits for CPU and memory in the container spec.
resources:
limits:
cpu: [1]
memory: [2]
requests:
cpu: [3]CPU limit is set to '500m' (0.5 CPU), memory limit to '256Mi', and CPU request to '250m' to reserve resources.