0
0
Kubernetesdevops~20 mins

ClusterIP service type in Kubernetes - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ClusterIP Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the primary purpose of a ClusterIP service in Kubernetes?

Choose the best description of what a ClusterIP service does inside a Kubernetes cluster.

AIt assigns a static IP address to a pod for external access.
BIt exposes the service externally using a cloud provider's load balancer.
CIt creates a DNS record that points to an external IP address outside the cluster.
DIt exposes the service on a cluster-internal IP, making it reachable only within the cluster.
Attempts:
2 left
💡 Hint

Think about whether the service is reachable from outside the cluster or only inside.

💻 Command Output
intermediate
1:00remaining
What is the output of this command showing a ClusterIP service?

Given the command kubectl get svc my-service with this output, what is the ClusterIP address?

Kubernetes
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
my-service   ClusterIP   10.96.123.45    <none>        80/TCP     5m
A10.96.123.45
Bmy-service
C80/TCP
D<none>
Attempts:
2 left
💡 Hint

Look for the column labeled 'CLUSTER-IP'.

Configuration
advanced
2:00remaining
Identify the correct YAML snippet for a ClusterIP service

Which YAML snippet correctly defines a Kubernetes service of type ClusterIP exposing port 8080?

A
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: ClusterIP
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
B
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: LoadBalancer
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
C
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
D
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-app
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
Attempts:
2 left
💡 Hint

Check the type field for the service type.

Troubleshoot
advanced
1:30remaining
Why can't pods outside the cluster access a ClusterIP service?

You created a ClusterIP service, but external clients cannot reach it. What is the reason?

AThe service port is not open on the pod's container.
BThe service selector labels do not match any pods.
CClusterIP services are only accessible inside the cluster network, not from outside.
DThe pod is not running.
Attempts:
2 left
💡 Hint

Think about the network scope of ClusterIP services.

Best Practice
expert
2:00remaining
Which practice ensures stable internal communication using ClusterIP services?

To maintain stable communication between pods using a ClusterIP service, what is the best practice?

AExpose the service as LoadBalancer for internal traffic.
BUse the service's DNS name instead of pod IPs directly.
CUse pod IP addresses directly for communication.
DRestart pods frequently to refresh connections.
Attempts:
2 left
💡 Hint

Consider what changes when pods restart or reschedule.