CKAD Mock Exam 1, Q 10 endpoints x endpointslices

We have an external webserver running on student-node which is exposed at port 9999 .

We have also created a service called external-webserver-ckad01-svcn that can connect to our local webserver from within the cluster3 but, at the moment, it is not working as expected.

Fix the issue so that other pods within cluster3 can use external-webserver-ckad01-svcn service to access the webserver.

Solution suggest creating endpoint

apiVersion: v1
kind: Endpoints
metadata:
  name: external-webserver-ckad01-svcn
subsets:
  - addresses:
      - ip: 192.5.12.8
    ports:
      - port: 9999

It works.
Endpoints is reported 192.5.12.8:9999

k describe svc external-webserver-ckad01-svcn 
Name:              external-webserver-ckad01-svcn
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          <none>
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.101.195.79
IPs:               10.101.195.79
Port:              <unset>  80/TCP
TargetPort:        9999/TCP
Endpoints:         192.5.12.8:9999
Session Affinity:  None
Events:            <none>

However, the EndpointSlice is the recommended replacement for Endpoints.

I tried to create endpointslice

apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
  name: external-webserver-ckad01-svcn-endposl # By convention, use the Service name as a prefix
  labels:
    # This label must match the Service name
    kubernetes.io/service-name: external-webserver-ckad01-svcn
addressType: IPv4
ports:
  - protocol: TCP
    port: 9999
endpoints:
  - addresses:
      - "192.5.12.8"

But then Endpoints: is none below

k describe svc external-webserver-ckad01-svcn 
Name:              external-webserver-ckad01-svcn
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          <none>
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.101.195.79
IPs:               10.101.195.79
Port:              <unset>  80/TCP
TargetPort:        9999/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>

Can EndpointSlice be used to solve this question?
Thanks.

Hi @M-Skacel

Yes, you are correct, EndPointSlice is now the preferred/recommended approach ( per k8s docs) and this question can be resolved using the EndpointSlice as well. One thing to note about EndpointSlices is, that it is preferred due to their efficiency, especially for large clusters, and we can say are useful only in cases where we are dealing with a large number of Pods exposed. For limited No. workloads, Endpoints should suffice (until they are supported).

But, I believe the grader in the lab evaluates based on the Endpoint resource ( As we are dealing with only one Pod here :slight_smile: ), and that’s why your workflow of using EndpointSlice might be failing.

This issue has already been noted based on a similar scenario, and our engineers are working on a fix.

I’ll update here once it’s resolved.

PS: EnpointSlices are alternative to Endpoints and saying preferred/recommended would be an overstatement.

Regards.

1 Like