CKAD mock exam 3, Q 9

I have got wrong answer on this question because it seems that the grader checks the labels given to the services, instead of just checking that the selector of each service matches the targeted pod labels

image

my understanding of the question and services in general is that service labels themselves can be anything

here is service yaml that failed

	
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: "2024-12-31T17:44:40Z"
  labels:
    app: lb1-ckad17-svcn
			  
  name: lb1-ckad17-svcn
  namespace: ns-ckad17-svcn
  resourceVersion: "4727"
  uid: 6f8784b9-a1d0-40ce-bae2-98a556c188e9
spec:
  allocateLoadBalancerNodePorts: true
  clusterIP: 172.20.130.141
  clusterIPs:
  - 172.20.130.141
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: "80"
    nodePort: 31890
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    criteria: location
    exam: ckad
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer: {}

once I changed service labels to below it went fine

labels:
  criteria: location
  exam: ckad

I suspect you are being checked on the assumption you used “kubectl expose” to create the services, which have those ports on the services set. That would explain the problem; doing that and editing the services to get the nodePorts right passes the grader.