Complete the code to define a ClusterIP service in Kubernetes.
apiVersion: v1 kind: Service metadata: name: my-service spec: type: [1] selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
The ClusterIP type exposes the service on a cluster-internal IP. This means the service is reachable only within the cluster.
Complete the code to specify the port that the ClusterIP service listens on.
spec:
ports:
- protocol: TCP
port: [1]
targetPort: 8080The port field defines the port that the service will listen on inside the cluster. Port 80 is the common HTTP port.
Fix the error in the service type to correctly create a ClusterIP service.
spec:
type: [1]The service type ClusterIP is case-sensitive and must be written exactly as shown.
Fill both blanks to complete the selector and port configuration for a ClusterIP service.
spec:
selector:
app: [1]
ports:
- port: [2]The selector matches pods labeled MyApp. The service listens on port 80.
Fill all three blanks to define a ClusterIP service with correct type, selector, and port.
apiVersion: v1 kind: Service metadata: name: example-service spec: type: [1] selector: app: [2] ports: - protocol: TCP port: [3] targetPort: 8080
This defines a ClusterIP service named example-service that selects pods labeled MyApp and listens on port 80.