0
0
Kubernetesdevops~20 mins

LoadBalancer service type in Kubernetes - Practice Problems & Coding Challenges

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

In Kubernetes, what is the main purpose of a service with type LoadBalancer?

AIt exposes the service externally using a cloud provider's load balancer and assigns a public IP.
BIt only exposes the service inside the cluster without any external access.
CIt creates a DNS record for the service but does not expose it externally.
DIt automatically scales the number of pods based on incoming traffic.
Attempts:
2 left
💡 Hint

Think about how external users can access your service from outside the cluster.

💻 Command Output
intermediate
1:30remaining
Output of kubectl get svc for LoadBalancer service

What is the expected output of kubectl get svc for a LoadBalancer service just created in a cloud environment?

Kubernetes
kubectl get svc my-loadbalancer-service
A
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
my-loadbalancer-service NodePort       10.0.0.1       <none>           80:30080/TCP     5m
B
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
my-loadbalancer-service LoadBalancer   10.0.0.1       <pending>        80:30080/TCP     5m
C
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
my-loadbalancer-service ClusterIP     10.0.0.1       <none>           80/TCP           5m
D
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)          AGE
my-loadbalancer-service LoadBalancer   10.0.0.1       35.226.14.5      80:30080/TCP     5m
Attempts:
2 left
💡 Hint

Just after creation, the cloud provider has not yet provisioned the load balancer.

Configuration
advanced
2:00remaining
Correct YAML for a LoadBalancer service

Which YAML snippet correctly defines a Kubernetes service of type LoadBalancer exposing port 80?

A
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: LoadBalancer
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
B
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
C
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: ClusterIP
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
D
08 :troPtegrat      
08 :trop      
PCT :locotorp -    
:strop  
ppaym :ppa    
:rotceles  
recnalaBdaoL :epyt  
:ceps
ecivres-ym :eman  
:atadatem
ecivreS :dnik
1v :noisreVipa
Attempts:
2 left
💡 Hint

Check the service type and protocol used for HTTP traffic.

Troubleshoot
advanced
1:30remaining
Why is EXTERNAL-IP stuck at <pending>?

You created a LoadBalancer service in Kubernetes, but kubectl get svc shows <pending> in the EXTERNAL-IP column. What is the most likely cause?

AThe pod is crashing and restarting continuously.
BThe service selector labels do not match any pods.
CThe service port is not exposed in the pod containers.
DThe Kubernetes cluster is running on a local machine or environment without a cloud provider integration.
Attempts:
2 left
💡 Hint

Think about what provisions the external IP for LoadBalancer services.

🔀 Workflow
expert
2:30remaining
Steps to expose an app externally using LoadBalancer service

What is the correct order of steps to expose a Kubernetes app externally using a LoadBalancer service?

A2,1,3,4
B3,1,2,4
C1,2,3,4
D1,3,2,4
Attempts:
2 left
💡 Hint

Create both YAML files before applying them to the cluster.