We have an external webserver running on
student-node
which is exposed at port9999
.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.