Hi Team,
I’m new to Kubernetes and have a question regarding the behavior of Endpoints
and EndpointSlice
in Kubernetes. After reviewing multiple pieces of documentation, I found that every Service in Kubernetes needs an associated Endpoints
, which contains a group of IPs, and these are further split into EndpointSlices
to optimize networking, especially in large clusters.
From what I gathered, Kubernetes automatically creates Endpoints
and EndpointSlice
resources for a Service when the Service is deployed and has a selector.
Now, here’s my specific scenario and question:
I have a custom SMTP server that I need to reach from my Kubernetes cluster. To achieve this, I created a Service without a selector and set clusterIP: None
. I then deployed an Endpoints
YAML file (not an EndpointSlice
). Upon doing so, Kubernetes automatically created an EndpointSlice
, and everything worked as expected—I was able to reach the SMTP server successfully.
However, while reviewing the Kubernetes documentation on services without selectors, I noticed it mentions that creating a Service and an associated EndpointSlice
should work seamlessly. But when I tried this approach, the IPs mentioned in the EndpointSlice
were not allocated to the Service, and I couldn’t reach the SMTP server.
Here are my questions:
- Is my understanding of how Services,
Endpoints
, andEndpointSlice
interact (with and without selectors) correct? - Why does the functionality fail when I rely solely on a manually created
EndpointSlice
as described in the documentation? - The documentation refers to
Endpoints
as “legacy.” Can someone clarify what this means and whether there are specific scenarios whereEndpointSlice
cannot fully replaceEndpoints
?
Cluster information:
Kubernetes version:
Client Version: v1.30.3
Server Version: v1.30.5-gke.1713000
Cloud being used: GKE
Installation method: gcloud CLI
Host OS: Container-Optimized OS
CNI and version: fluent-bit:v1.8.12-gke.46
CRI and version: containerd://1.7.23
Details of the Endpoints and Endpointslice Yaml that i used for testing purposes
(Using a dummy IP for reference purposes)
Endpoint.yaml
apiVersion: v1
kind: Endpoints
metadata:
name: smtp
subsets:
- addresses:
- ip: 192.00.00.01
- ip: 192.00.00.01
ports:
- name: http
port: 587
Service.yaml
apiVersion: v1
kind: Service
metadata:
name: smtp
spec:
clusterIP: None
ports:
- name: http
protocol: TCP
port: 80
targetPort: 587
Endpointslice.yaml
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: smtp
namespace: test-green
labels:
kubernetes.io/service-name: smtp
app: smtp
endpointslice.kubernetes.io/managed-by: devops-managed
addressType: IPv4
ports:
- name: http
protocol: TCP
port: 587
endpoints:
- addresses:
- 192.00.00.01
conditions:
ready: true
- addresses:
- 192.00.00.01
conditions:
ready: true
Thanks
Srimathi S