kube-controller-manager service 与 leader election 有冲突
Created by: zryfish
Monitor组件会在 kube-system 下创建 kube-controller-manager 和 kube-scheduler service ,创建 service 意味着产生对应的 endpoint 对象。在 HA 环境下, kube-controller-manager 和 kube-scheduler 会开启 leader-election,并会创建对应的 resource lock 对象,目前配置是 endpoint 对象。
endpoint controller 和 leader election 会同时去更新 endpoint 对象,导致更新失败。
I1106 09:18:28.968433 1 event.go:258] Event(v1.ObjectReference{Kind:"Endpoints", Namespace:"kube-system", Name:"kube-scheduler", UID:"8fb0952e-2907-497e-bb65-6f7c23563c51", APIVersion:"v1", ResourceVersion:"17976", FieldPath:""}): type: 'Warning' reason: 'FailedToUpdateEndpoint' Failed to update endpoint kube-system/kube-scheduler: Operation cannot be fulfilled on endpoints "kube-scheduler": the object has been modified; please apply your changes to the latest version and try again
为避免这种情况发生,将 kube-controller-manager service 和 kube-scheduler service 名称加上 -headless 以区分,例如
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: kube-scheduler
name: kube-scheduler-headless
namespace: kube-system