diff --git a/charts/tidb-operator/templates/advanced-statefulset-deployment.yaml b/charts/tidb-operator/templates/advanced-statefulset-deployment.yaml index b0d182f526..3f6674590a 100644 --- a/charts/tidb-operator/templates/advanced-statefulset-deployment.yaml +++ b/charts/tidb-operator/templates/advanced-statefulset-deployment.yaml @@ -38,6 +38,9 @@ spec: - --leader-elect - --leader-elect-resource-name=advanced-statefulset-controller - --leader-elect-resource-namespace=$(POD_NAMESPACE) + {{- if .Values.advancedStatefulset.resourceLock }} + - --leader-elect-resource-lock={{ .Values.advancedStatefulset.resourceLock }} + {{- end }} env: - name: POD_NAMESPACE valueFrom: diff --git a/charts/tidb-operator/templates/advanced-statefulset-rbac.yaml b/charts/tidb-operator/templates/advanced-statefulset-rbac.yaml index 3f8db12dea..1d6b67738e 100644 --- a/charts/tidb-operator/templates/advanced-statefulset-rbac.yaml +++ b/charts/tidb-operator/templates/advanced-statefulset-rbac.yaml @@ -81,6 +81,12 @@ rules: - 'endpoints' verbs: - '*' +- apiGroups: + - 'coordination.k8s.io' + resources: + - 'leases' + verbs: + - '*' --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding diff --git a/charts/tidb-operator/values.yaml b/charts/tidb-operator/values.yaml index 3854807542..75a10ddbc0 100644 --- a/charts/tidb-operator/values.yaml +++ b/charts/tidb-operator/values.yaml @@ -202,6 +202,9 @@ scheduler: # kubectl apply -f manifests/advanced-statefulset-crd.v1.yaml advancedStatefulset: create: false + ## resourceLock indicates the type of resource object that will be used for locking during leader election. + ## If using "endpoints" before and want to migrate to "leases", you should migrate to "endpointsleases" first. + # resourceLock: "leases" image: pingcap/advanced-statefulset:v0.4.0 imagePullPolicy: IfNotPresent serviceAccount: advanced-statefulset-controller