mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Switch add-on manager to use lease for leader election
This commit is contained in:
parent
f266f60da9
commit
c7e084eec0
@ -1,3 +1,7 @@
|
|||||||
|
### Version 9.1.4 (Wed February 10 2021 Jordan Liggitt <liggitt@google.com>)
|
||||||
|
- Update kubectl to v1.20.2.
|
||||||
|
- Fix a bug in leader election (https://github.com/kubernetes/kubernetes/issues/98966)
|
||||||
|
|
||||||
### Version 9.1.3 (Mon November 30 2020 Spencer Peterson <spencerjp@google.com>)
|
### Version 9.1.3 (Mon November 30 2020 Spencer Peterson <spencerjp@google.com>)
|
||||||
- Update kubectl to v1.19.3.
|
- Update kubectl to v1.19.3.
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
IMAGE=gcr.io/k8s-staging-addon-manager/kube-addon-manager
|
IMAGE=gcr.io/k8s-staging-addon-manager/kube-addon-manager
|
||||||
ARCH?=amd64
|
ARCH?=amd64
|
||||||
TEMP_DIR:=$(shell mktemp -d)
|
TEMP_DIR:=$(shell mktemp -d)
|
||||||
VERSION=v9.1.3
|
VERSION=v9.1.4
|
||||||
KUBECTL_VERSION?=v1.19.3
|
KUBECTL_VERSION?=v1.20.2
|
||||||
|
|
||||||
BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):v1.0.0
|
BASEIMAGE=k8s.gcr.io/debian-base-$(ARCH):v1.0.0
|
||||||
|
|
||||||
|
@ -273,15 +273,22 @@ function is_leader() {
|
|||||||
fi
|
fi
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
# Disabling because "${KUBECTL_OPTS}" needs to allow for expansion here
|
# Disabling because "${KUBECTL_OPTS}" needs to allow for expansion here
|
||||||
KUBE_CONTROLLER_MANAGER_LEADER=$(${KUBECTL} ${KUBECTL_OPTS} -n kube-system get ep kube-controller-manager \
|
KUBE_CONTROLLER_MANAGER_LEADER=$(${KUBECTL} ${KUBECTL_OPTS} -n kube-system get leases.v1.coordination.k8s.io kube-controller-manager -o "jsonpath={.spec.holderIdentity}")
|
||||||
-o go-template=$'{{index .metadata.annotations "control-plane.alpha.kubernetes.io/leader"}}' \
|
|
||||||
| sed 's/^.*"holderIdentity":"\([^"]*\)".*/\1/')
|
case "${KUBE_CONTROLLER_MANAGER_LEADER}" in
|
||||||
# If there was any problem with getting the leader election results, var will
|
"")
|
||||||
# be empty. Since it's better to have multiple addon managers than no addon
|
log ERR "No leader election info found."
|
||||||
# managers at all, we're going to assume that we're the leader in such case.
|
return 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
"${HOSTNAME}"_*)
|
||||||
log INFO "Leader is $KUBE_CONTROLLER_MANAGER_LEADER"
|
log INFO "Leader is $KUBE_CONTROLLER_MANAGER_LEADER"
|
||||||
# KUBE_CONTROLLER_MANAGER_LEADER value is in the form "${HOSTNAME}_*"
|
return 0
|
||||||
# Here we verify that the value is either empty or is in the expected form for the leader
|
;;
|
||||||
KUBE_CONTROLLER_MANAGER_LEADER="${KUBE_CONTROLLER_MANAGER_LEADER##${HOSTNAME}_*}"
|
|
||||||
[[ "$KUBE_CONTROLLER_MANAGER_LEADER" == "" ]]
|
*)
|
||||||
|
log INFO "Leader is $KUBE_CONTROLLER_MANAGER_LEADER, not ${HOSTNAME}_*"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user