Complete the code to create a Pod that listens on port 80.
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: web
image: nginx
ports:
- containerPort: [1]The standard HTTP port is 80, so the container should listen on port 80 for web traffic.
Complete the command to check the IP address of a Pod named 'my-pod'.
kubectl get pod my-pod -o [1]The jsonpath option with '{.status.podIP}' extracts the Pod's IP address.
Fix the error in the Service definition to expose port 80 correctly.
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: [1]
targetPort: 8080The Service port should be 80 to expose the application on the standard HTTP port, while targetPort can be different.
Fill both blanks to create a NetworkPolicy that allows ingress only from Pods with label 'role=frontend'.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-frontend
spec:
podSelector: {}
ingress:
- from:
- podSelector:
matchLabels:
[1]: [2]The NetworkPolicy allows ingress from Pods labeled with 'role=frontend'.
Fill all three blanks to create a ConfigMap with keys 'host' and 'port'.
apiVersion: v1 kind: ConfigMap metadata: name: service-config data: [1]: example.com [2]: "[3]"
The ConfigMap defines 'host' as example.com and 'port' as 'http'.