kubernetes: Endpoint / Endpointslice objects become stuck in state where IP condition differs (not ready vs ready)
What happened?
We recently upgraded kubernetes from 1.20.12 to 1.24.10 . We now periodically experience an issue where services will “disconnect” from their endpoint, even though there were no changes to the status of the pod it references, or the node the pod is on. The issue can occur with one or more services and it always starts at the same time for all services it affects. Usually all these services have the same selector. However, it doesn’t always affect all the services with that selector. For example, we could have 5 services with the same selector and only 3 of them stop working.
After this “disconnect”, the endpoint object for the service shows the pod ip in NotReadyAddresses while the endpointslice object shows the ip with condition being ready. It gets stuck in this state until we either delete the pod or endpoint or restart controller manager.
service:
Name: postgres-psql-0
Namespace: default
Labels: agent-modtime=2020_07_15T13D34D53Z
agent-size=354
Annotations: <none>
Selector: statefulset.kubernetes.io/pod-name=postgres-0
Type: NodePort
IP Family Policy: SingleStack
IP Families: IPv4
IP: 10.105.223.13
IPs: 10.105.223.13
Port: psql 5432/TCP
TargetPort: 5432/TCP
NodePort: psql 30432/TCP
Endpoints:
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
endpoint
Name: postgres-psql-0
Namespace: default
Labels: agent-modtime=2020_07_15T13D34D53Z
agent-size=354
Annotations: endpoints.kubernetes.io/last-change-trigger-time: 2023-04-08T22:11:15Z
Subsets:
Addresses: <none>
NotReadyAddresses: 10.244.2.32
Ports:
Name Port Protocol
---- ---- --------
psql 5432 TCP
Events: <none>
endpointslice
Name: postgres-psql-0-6r7jm
Namespace: default
Labels: endpointslice.kubernetes.io/managed-by=endpointslice-controller.k8s.io
kubernetes.io/service-name=postgres-psql-0
agent-modtime=2020_07_15T13D34D53Z
agent-size=354
Annotations: <none>
AddressType: IPv4
Ports:
Name Port Protocol
---- ---- --------
psql 5432 TCP
Endpoints:
- Addresses: 10.244.2.32
Conditions:
Ready: true
Hostname: <unset>
TargetRef: Pod/postgres-0
NodeName: node0002
Zone: <unset>
Events: <none>
Controller manager logs
08 02:58:24.319863 1 shared_informer.go:262] Caches are synced for certificate-csrsigning-kubelet-client
I0408 02:58:24.319934 1 shared_informer.go:262] Caches are synced for certificate-csrsigning-kubelet-serving
I0408 02:58:24.321346 1 shared_informer.go:262] Caches are synced for certificate-csrsigning-legacy-unknown
I0408 02:58:24.321445 1 shared_informer.go:262] Caches are synced for certificate-csrsigning-kube-apiserver-client
I0408 02:58:24.323917 1 shared_informer.go:262] Caches are synced for resource quota
I0408 02:58:24.328084 1 shared_informer.go:262] Caches are synced for daemon sets
I0408 02:58:24.364238 1 shared_informer.go:262] Caches are synced for resource quota
I0408 02:58:24.748179 1 shared_informer.go:262] Caches are synced for garbage collector
I0408 02:58:24.748232 1 garbagecollector.go:158] Garbage collector: all resource monitors have synced. Proceeding to collect garbage
I0408 02:58:24.767101 1 shared_informer.go:262] Caches are synced for garbage collector
W0408 03:56:01.896633 1 reflector.go:442] vendor/k8s.io/client-go/informers/factory.go:134: watch of *v1.Event ended with: Internal error occurred: etcdserver: no leader
W0408 04:34:25.271161 1 endpointslice_controller.go:302] Error syncing endpoint slices for service "default/postgres-psql-0", retrying. Error: EndpointSlice informer cache is out of date
W0408 06:08:02.422550 1 reflector.go:442] vendor/k8s.io/client-go/informers/factory.go:134: watch of *v1.Event ended with: Internal error occurred: etcdserver: no leader
W0408 06:09:02.005170 1 reflector.go:442] vendor/k8s.io/client-go/informers/factory.go:134: watch of *v1.Event ended with: Internal error occurred: etcdserver: no leader
W0408 08:23:02.357299 1 reflector.go:442] vendor/k8s.io/client-go/informers/factory.go:134: watch of *v1.Event ended with: Internal error occurred: etcdserver: no leader
Despite the repeated etcdserver: no leader messages in the logs above, there is no indication that etcd cluster lost it’s leader. We do, however, experience a high number of leader changes due to the nature of our clusters. But this has always been the case.
What did you expect to happen?
Given a pod that is running and healthy and that is on a node that is ready, I’d expect all services with selector matching labels defined for the pod to remain “connected” to it’s endpoints.
How can we reproduce it (as minimally and precisely as possible)?
We are unable to reproduce.
Anything else we need to know?
We run many 3 node clusters. We only see this on a random subset of them at random times. Not on all of them. We notice this most after server maintenance where a server is rebooted. But this has occurred during periods of stability.
We understand that we may have skipped too many versions. We’ve upgraded this way for several years without issue and will look at reducing the jump in future upgrades. But this issue doesn’t occur immediately after the upgrade and doesn’t occur in all of our clusters.
During the upgrade, we perform a rolling upgrade of each VM in a cluster by replacing it with a VM baked with the upgraded control plane and related components. The complete cluster upgrade is completed in a few hours. Data in etcd, however, is persisted through the upgrade.
At this time it’s seems to be limited to services related to our postgres cluster running in each k8s cluster. We use spilio for HA and recently noticed that this makes patch requests to endpoint objects. Nothing has changed with these postgres clusters for at least the last 6 months and we didn’t experience an issue prior to upgrading k8s.
Kubernetes version
$ kubectl version
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.10", GitCommit:"5c1d2d4295f9b4eb12bfbf6429fdf989f2ca8a02", GitTreeState:"clean", BuildDate:"2023-01-18T19:08:10Z", GoVersion:"go1.19.5", Compiler:"gc", Platform:"linux/amd64"}
Cloud provider
OS version
# On Linux:
$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
$ uname -a
Linux <hostname>.stores.target.com 3.10.0-1160.83.1.el7.x86_64 #1 SMP Wed Jan 25 16:41:43 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
Install tools
Container runtime (CRI) and version (if applicable)
Related plugins (CNI, CSI, …) and versions (if applicable)
- kube-apiserver-amd64:v1.24.10
- kube-scheduler-amd64:v1.24.10
- kube-controller-manager-amd64:v1.24.10
- kube-proxy-amd64:v1.24.10
- flannel:v0.19.0-amd64
- etcd:v3.4.22
- flannel-cni-plugin:v1.1.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (21 by maintainers)
/close
no answer for several months
/sig network /cc @szuecs @aojea
updating from the slack thread