Bird
0
0

Which YAML snippet correctly creates a Kubernetes LoadBalancer service exposing port 443 and forwarding to targetPort 8443?

easy📝 Configuration Q3 of 15
Kubernetes - Services
Which YAML snippet correctly creates a Kubernetes LoadBalancer service exposing port 443 and forwarding to targetPort 8443?
Aspec: type: LoadBalancer ports: - port: 443 targetPort: 8443 selector: app: myapp
Bspec: type: NodePort ports: - port: 443 targetPort: 8443 selector: app: myapp
Cspec: type: ClusterIP ports: - port: 80 targetPort: 8080 selector: app: myapp
Dspec: type: LoadBalancer ports: - port: 80 targetPort: 80 selector: app: myapp
Step-by-Step Solution
Solution:
  1. Step 1: Identify LoadBalancer type

    The service must have type: LoadBalancer to provision an external load balancer.
  2. Step 2: Check ports and targetPorts

    Port 443 exposed externally and forwarded to targetPort 8443 is required.
  3. Step 3: Validate selector

    The selector must match the pods to route traffic correctly.
  4. Final Answer:

    spec: type: LoadBalancer ports: - port: 443 targetPort: 8443 selector: app: myapp correctly defines a LoadBalancer service exposing port 443 to targetPort 8443.
  5. Quick Check:

    LoadBalancer + port 443 + targetPort 8443 [OK]
Quick Trick: LoadBalancer with port and targetPort must match [OK]
Common Mistakes:
  • Using NodePort or ClusterIP instead of LoadBalancer
  • Mismatching port and targetPort
  • Omitting selector field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes