Bird
Raised Fist0
Kubernetesdevops~10 mins

ExternalName service type in Kubernetes - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the YAML to define a Kubernetes Service of type ExternalName.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: [1]
  externalName: example.com
Drag options to blanks, or click blank then click option'
AExternalName
BLoadBalancer
CNodePort
DClusterIP
Attempts:
3 left
💡 Hint
Common Mistakes
Using ClusterIP instead of ExternalName will create a normal internal service.
Using NodePort or LoadBalancer will expose pods, not map to external DNS.
2fill in blank
medium

Complete the YAML to specify the external DNS name for the ExternalName service.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: ExternalName
  externalName: [1]
Drag options to blanks, or click blank then click option'
A10.0.0.1
Bmy-service.local
Cexample.com
Dmy-service.default.svc.cluster.local
Attempts:
3 left
💡 Hint
Common Mistakes
Using an IP address instead of a DNS name.
Using internal cluster service names instead of external DNS.
3fill in blank
hard

Fix the error in this ExternalName service YAML by completing the missing field.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: ExternalName
  [1]: example.com
Drag options to blanks, or click blank then click option'
Aselector
BclusterIP
Cports
DexternalName
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a selector field which is not used for ExternalName services.
Adding ports which are ignored for ExternalName services.
4fill in blank
hard

Fill both blanks to create a valid ExternalName service YAML with correct type and externalName.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: external-service
spec:
  type: [1]
  externalName: [2]
Drag options to blanks, or click blank then click option'
AExternalName
BClusterIP
Cexample.org
D10.10.10.10
Attempts:
3 left
💡 Hint
Common Mistakes
Using ClusterIP as type for ExternalName service.
Using an IP address instead of a DNS name for externalName.
5fill in blank
hard

Fill all three blanks to define an ExternalName service with name, type, and externalName fields.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: [1]
spec:
  type: [2]
  externalName: [3]
Drag options to blanks, or click blank then click option'
Aexternal-service
BExternalName
Cexternal.example.com
Dmy-service
Attempts:
3 left
💡 Hint
Common Mistakes
Using internal service names for externalName.
Using wrong service type other than ExternalName.

Practice

(1/5)
1. What is the main purpose of a Kubernetes ExternalName service?
easy
A. To map a service to an external DNS name outside the cluster
B. To expose a pod's IP address inside the cluster
C. To load balance traffic between pods
D. To create a persistent volume claim

Solution

  1. Step 1: Understand ExternalName service role

    An ExternalName service maps a Kubernetes service to an external DNS name, allowing pods to access external services by a simple name.
  2. Step 2: Compare with other service types

    Other service types like ClusterIP or LoadBalancer expose pods or balance traffic, but ExternalName specifically maps to external DNS.
  3. Final Answer:

    To map a service to an external DNS name outside the cluster -> Option A
  4. Quick Check:

    ExternalName = external DNS mapping [OK]
Hint: ExternalName points to DNS, not IP or pods [OK]
Common Mistakes:
  • Confusing ExternalName with ClusterIP or LoadBalancer
  • Thinking it manages pod IPs
  • Assuming it handles ports inside the cluster
2. Which of the following is the correct minimal YAML snippet to create an ExternalName service named my-external pointing to example.com?
easy
A. apiVersion: v1\nkind: Service\nmetadata:\n name: my-external\nspec:\n type: LoadBalancer\n externalName: example.com
B. apiVersion: v1\nkind: Service\nmetadata:\n name: my-external\nspec:\n type: ExternalName\n externalName: example.com
C. apiVersion: v1\nkind: Service\nmetadata:\n name: my-external\nspec:\n type: ExternalName\n clusterIP: example.com
D. apiVersion: v1\nkind: Service\nmetadata:\n name: my-external\nspec:\n type: ClusterIP\n externalName: example.com

Solution

  1. Step 1: Identify correct service type and field

    ExternalName service requires type: ExternalName and externalName field with the DNS name.
  2. Step 2: Check YAML correctness

    apiVersion: v1\nkind: Service\nmetadata:\n name: my-external\nspec:\n type: ExternalName\n externalName: example.com correctly sets type: ExternalName and externalName: example.com. Other options use wrong types or fields.
  3. Final Answer:

    YAML with type ExternalName and externalName: example.com -> Option B
  4. Quick Check:

    ExternalName YAML = type ExternalName + externalName field [OK]
Hint: ExternalName needs type and externalName fields exactly [OK]
Common Mistakes:
  • Using ClusterIP or LoadBalancer instead of ExternalName
  • Setting clusterIP instead of externalName
  • Omitting the externalName field
3. Given this ExternalName service YAML:
apiVersion: v1
kind: Service
metadata:
  name: ext-service
spec:
  type: ExternalName
  externalName: api.example.com

What happens when a pod inside the cluster runs nslookup ext-service?
medium
A. It returns the cluster IP of ext-service
B. It returns the IP address of the pod running the service
C. It returns an error because ExternalName services have no IP
D. It returns the IP address of api.example.com

Solution

  1. Step 1: Understand DNS resolution for ExternalName

    ExternalName services create a DNS CNAME record pointing to the externalName value, so queries resolve to that external DNS.
  2. Step 2: Analyze nslookup behavior

    Running nslookup ext-service returns the IP address of api.example.com by resolving the CNAME.
  3. Final Answer:

    It returns the IP address of api.example.com -> Option D
  4. Quick Check:

    ExternalName DNS = external DNS IP [OK]
Hint: ExternalName returns external DNS IP on lookup [OK]
Common Mistakes:
  • Expecting pod or cluster IP for ExternalName
  • Thinking ExternalName has its own IP
  • Assuming nslookup fails for ExternalName
4. You created this ExternalName service YAML:
apiVersion: v1
kind: Service
metadata:
  name: ext-svc
spec:
  type: ExternalName
  externalName: 123.45.67.89

Why does this configuration fail?
medium
A. externalName field is missing
B. type ExternalName cannot be used with metadata
C. externalName must be a DNS name, not an IP address
D. Service type must be ClusterIP for IP addresses

Solution

  1. Step 1: Check externalName field requirements

    The externalName must be a valid DNS name, not an IP address.
  2. Step 2: Identify error cause

    Using an IP address like 123.45.67.89 in externalName is invalid and causes failure.
  3. Final Answer:

    externalName must be a DNS name, not an IP address -> Option C
  4. Quick Check:

    externalName = DNS name only [OK]
Hint: externalName must be a DNS name, not IP [OK]
Common Mistakes:
  • Using IP instead of DNS in externalName
  • Confusing service type rules
  • Omitting externalName field
5. You want pods in your cluster to access an external database at db.external.com using the service name external-db. You also want to ensure no IP or port is configured inside the cluster. Which is the best way to configure this?
hard
A. Create an ExternalName service named external-db with externalName: db.external.com
B. Create a ClusterIP service named external-db with selector matching database pods
C. Create a LoadBalancer service named external-db pointing to db.external.com IP
D. Create a NodePort service named external-db with targetPort set to database port

Solution

  1. Step 1: Understand requirement for no IP or port inside cluster

    ExternalName service maps a service name to an external DNS without IP or port configuration inside the cluster.
  2. Step 2: Match requirement with service types

    ClusterIP, LoadBalancer, and NodePort require IPs or ports inside the cluster, so they don't fit the requirement.
  3. Final Answer:

    Create an ExternalName service named external-db with externalName: db.external.com -> Option A
  4. Quick Check:

    ExternalName = external DNS, no IP/port config [OK]
Hint: Use ExternalName for external DNS without cluster IP/port [OK]
Common Mistakes:
  • Using ClusterIP or LoadBalancer for external DNS
  • Configuring ports inside the cluster unnecessarily
  • Not using ExternalName for external services
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard