kubernetes: Both Endpoints and EndpointSlices not working with Service abstraction for external IPs
What happened?
As recommend in https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors I did try to abstract access to an externally hosted mariaDB. However, both the recommend approach and the legacy approach with Endpoints did not work as expected. There is a slight difference however, in the EndpointSlice case the service description showed Endpoints: <none> while in the endpoints case it was empty, i.e. Endpoints: .
What did you expect to happen?
The external database should be reachable through the service abstraction.
How can we reproduce it (as minimally and precisely as possible)?
It is a clean K3s with --disable traefik, nginx ingress as well as cert-manager installed via helm, plus GitLab Agent for Kubernetes also using Helm.
The Service:
apiVersion: v1
kind: Service
metadata:
name: mariadb
spec:
ports:
- protocol: TCP
port: 3306
targetPort: 3306
I’ve tried both, EndpointSlice:
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: mariadb-1
labels:
kubernetes.io/service-name: mariadb
addressType: IPv4
ports:
- name: mysql
port: 3306
protocol: TCP
endpoints:
- addresses:
- 10.0.0.5
, and Endpoints:
apiVersion: v1
kind: Endpoints
metadata:
name: mariadb
subsets:
- addresses:
- ip: 10.0.0.5
ports:
- name: mysql
port: 3306
Both were successfully deployed in the same namespace as the service and linked to the service.
case: EndpointSlices
kubectl get endpointslice -l kubernetes.io/service-name=mariadb
NAME ADDRESSTYPE PORTS ENDPOINTS AGE
mariadb-1 IPv4 3306 10.0.0.5 3m29s
kubectl describe service mariadb
Name: mariadb
Namespace: keldysh-projects-workshop
Labels: app.kubernetes.io/managed-by=Helm
Annotations: meta.helm.sh/release-name: service
meta.helm.sh/release-namespace: keldysh-projects-workshop
Selector: <none>
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.126.23
IPs: 10.43.126.23
Port: <unset> 3306/TCP
TargetPort: 3306/TCP
Endpoints: <none>
Session Affinity: None
Events: <none>
case: Endpoints
kubectl describe endpoints mariadb
Name: mariadb
Namespace: keldysh-projects-workshop
Labels: app.kubernetes.io/managed-by=Helm
Annotations: meta.helm.sh/release-name: service
meta.helm.sh/release-namespace: keldysh-projects-workshop
Subsets:
Addresses: 10.0.0.5
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
mysql 3306 TCP
Events: <none>
kubectl describe service mariadb
Name: mariadb
Namespace: keldysh-projects-workshop
Labels: app.kubernetes.io/managed-by=Helm
Annotations: meta.helm.sh/release-name: service
meta.helm.sh/release-namespace: keldysh-projects-workshop
Selector: <none>
Type: ClusterIP
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.43.126.23
IPs: 10.43.126.23
Port: <unset> 3306/TCP
TargetPort: 3306/TCP
Endpoints:
Session Affinity: None
Events: <none>
Anything else we need to know?
DNS is working in principle:
kubectl exec -i -t dnsutils -- nslookup mariadb
Server: 10.43.0.10
Address: 10.43.0.10#53
Name: mariadb.keldysh-projects-workshop.svc.cluster.local
Address: 10.43.19.67
I already submitted a bug report in the K3s repository. They however claim to not change the core kubernetes functionality: https://github.com/k3s-io/k3s/issues/9725 https://github.com/k3s-io/k3s/discussions/9726
Kubernetes version
K3s Version: k3s version v1.28.7+k3s1 (https://github.com/k3s-io/k3s/commit/051b14b248655896fdfd7ba6c93db6182cde7431) go version go1.21.7
Cloud provider
Self hosted K3s on Hetzner Cloud Servers
OS version
Linux kubernetes-test-server 5.15.0-91-generic https://github.com/k3s-io/k3s/issues/101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (18 by maintainers)
oh, sorry, I just meant to fix
kubectl describe serviceto show EndpointSlices rather than Endpointsinteresting, it seems you are using kube-proxy and kube-proxy does not process those endpoints
I’m in my way to kubecon so no much time until the week after, but this is a good issue for networking contributors to help, it seems pretty simple to reproduce as you are already providing the steps … once reproduced is a matter of understanding why the kube-proxy does not see those EndpointSlices
@aroradaman @uablrek you are quite familiar with the proxy code, maybe you can take a look? /cc @danwinship