Hello,
I have an nginx pod running in my cluster, and tried to expose it via the combination of an EndpointSlice object and a service without a selector.
First, I created a service without a selector by:
kubectl create svc clusterip nginx --tcp 80:80
Then. I created an EndpointSlice manually based on the snippet from
with a single endpoint address, that of the nginx pod running in my cluster.
I used the label ‘kubernetes.io/service-name: nginx’ as suggested in the docs.
I was expecting for K8s to associate the service with the EndpointSlice object, however that didn’t happen. The service has no endpoints, and after creating the service a new EndpointSlice object with a random suffix in its name, no ports and no endpoints is automatically created.
If someone has tried and succeeded in exposing a set of pods via a manually created EndpointSlice with the pod IP addresses, I would appreciate your feedback and help on how to make this work.
Thanks in advance.
Hi! Can you share your configuration for pod and EndpointSlice?
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: test
spec:
containers:
- name: nginx
image: nginx:alpine
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: test
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 80
Then I check the IP assigned to the pod, let’s say it’s 192.168.1.4. I go on and create an endpointslice object as follows.
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: nginx
labels:
kubernetes.io/service-name: nginx
app: test
addressType: IPv4
ports:
- name: http
protocol: TCP
port: 80
endpoints:
- addresses:
- "192.168.1.4"
So after having created these 3 objects, I check for endpoints with “kubectl get ep”, but no endpoints object has been created for the nginx service.
What am I missing?
It looks like this issue has recently been acknowledged and fixed.
We’ll have to keep an eye on which upcoming Kubernetes release will include the fix.