0
0
Kubernetesdevops~10 mins

Headless services concept in Kubernetes - Interactive Code Practice

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

Complete the code to define a headless service by setting the correct clusterIP value.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: my-headless-service
spec:
  clusterIP: [1]
  selector:
    app: myapp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9376
Drag options to blanks, or click blank then click option'
ALoadBalancer
B10.0.0.1
CNone
DClusterIP
Attempts:
3 left
💡 Hint
Common Mistakes
Using a normal IP address instead of 'None'.
Setting clusterIP to 'ClusterIP' or 'LoadBalancer' which are not valid values here.
2fill in blank
medium

Complete the command to create a headless service from a YAML file named service.yaml.

Kubernetes
kubectl [1] -f service.yaml
Drag options to blanks, or click blank then click option'
Adelete
Bapply
Cget
Ddescribe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' which only retrieves information.
Using 'delete' which removes resources.
Using 'describe' which shows details but does not create.
3fill in blank
hard

Fix the error in the service selector to correctly match pods with label 'app: myapp'.

Kubernetes
spec:
  selector:
    app: [1]
Drag options to blanks, or click blank then click option'
Amyapp
Bapp
Cmy-app
Dmyapp1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different label value like 'my-app' or 'myapp1'.
Using the label key instead of the value.
4fill in blank
hard

Fill both blanks to create a headless service that selects pods labeled 'app: web' and exposes port 8080.

Kubernetes
spec:
  clusterIP: [1]
  selector:
    app: [2]
  ports:
  - port: 8080
Drag options to blanks, or click blank then click option'
ANone
Bweb
Cmyapp
DLoadBalancer
Attempts:
3 left
💡 Hint
Common Mistakes
Using a normal IP or LoadBalancer for clusterIP.
Using wrong label values in selector.
5fill in blank
hard

Fill all three blanks to define a headless service with name 'db-service', selecting pods labeled 'role: database' and exposing port 5432.

Kubernetes
apiVersion: v1
kind: Service
metadata:
  name: [1]
spec:
  clusterIP: [2]
  selector:
    role: [3]
  ports:
  - port: 5432
Drag options to blanks, or click blank then click option'
Adb-service
BNone
Cdatabase
Dfrontend
Attempts:
3 left
💡 Hint
Common Mistakes
Using a normal IP or LoadBalancer for clusterIP.
Using wrong service name or label values.