File tree Expand file tree Collapse file tree 6 files changed +52
-12
lines changed
vertical-pod-autoscaler/charts/vertical-pod-autoscaler Expand file tree Collapse file tree 6 files changed +52
-12
lines changed Original file line number Diff line number Diff line change @@ -100,9 +100,15 @@ The Vertical Pod Autoscaler (VPA) automatically adjusts the CPU and memory resou
100100| updater.image.pullPolicy | string | ` "IfNotPresent" ` | |
101101| updater.image.repository | string | ` "registry.k8s.io/autoscaling/vpa-updater" ` | |
102102| updater.image.tag | string | ` nil ` | |
103+ | updater.leaderElection.enabled | string | ` nil ` | |
104+ | updater.leaderElection.leaseDuration | string | ` "15s" ` | |
105+ | updater.leaderElection.renewDeadline | string | ` "10s" ` | |
106+ | updater.leaderElection.resourceName | string | ` "vpa-updater-lease" ` | |
107+ | updater.leaderElection.resourceNamespace | string | ` "" ` | |
108+ | updater.leaderElection.retryPeriod | string | ` "2s" ` | |
103109| updater.podAnnotations | object | ` {} ` | |
104110| updater.podLabels | object | ` {} ` | |
105- | updater.replicas | int | ` 1 ` | |
111+ | updater.replicas | int | ` 2 ` | |
106112| updater.serviceAccount.annotations | object | ` {} ` | |
107113| updater.serviceAccount.create | bool | ` true ` | |
108114| updater.serviceAccount.labels | object | ` {} ` | |
Original file line number Diff line number Diff line change @@ -96,6 +96,16 @@ app.kubernetes.io/component: updater
9696{ {- printf " %s:%s" .Values.updater.image.repository (default .Chart.AppVersion .Values.updater.image.tag) } }
9797{ {- end } }
9898
99+ { {- define " vertical-pod-autoscaler.updater.leaderElectionEnabled" -} }
100+ { {- if and (eq .Values.updater.leaderElection.enabled nil) (gt (int .Values.updater.replicas) 1) -} }
101+ true
102+ { {- else if .Values.updater.leaderElection.enabled -} }
103+ true
104+ { {- else -} }
105+ false
106+ { {- end -} }
107+ { {- end -} }
108+
99109
100110{ {/*
101111Create the name of the namespace to use
Original file line number Diff line number Diff line change 4141 valueFrom :
4242 fieldRef :
4343 fieldPath : metadata.namespace
44+ args :
45+ - --v=4
46+ - --stderrthreshold=info
47+ {{- if eq (include "vertical-pod-autoscaler.updater.leaderElectionEnabled" .) "true" }}
48+ - --leader-elect=true
49+ - --leader-elect-resource-namespace={{ .Values.updater.leaderElection.resourceNamespace | default .Release.Namespace }}
50+ - --leader-elect-resource-name={{ .Values.updater.leaderElection.resourceName }}
51+ - --leader-elect-lease-duration={{ .Values.updater.leaderElection.leaseDuration }}
52+ - --leader-elect-renew-deadline={{ .Values.updater.leaderElection.renewDeadline }}
53+ - --leader-elect-retry-period={{ .Values.updater.leaderElection.retryPeriod }}
54+ {{- end }}
4455 ports :
4556 - name : prometheus
4657 containerPort : 8943
Original file line number Diff line number Diff line change 1- {{- if and (.Values.updater.enabled) .Values.updater.serviceAccount.create -}}
1+ {{- if and .Values.updater.enabled .Values.rbac.create -}}
2+ {{- if eq (include "vertical-pod-autoscaler.updater.leaderElectionEnabled" .) "true" }}
23apiVersion : rbac.authorization.k8s.io/v1
34kind : Role
45metadata :
56 name : {{ include "vertical-pod-autoscaler.updater.fullname" . }}-leader-locking
67 namespace : {{ .Release.Namespace }}
78 labels :
89 {{- include "vertical-pod-autoscaler.updater.labels" . | nindent 4 }}
9- {{- with .Values.updater.serviceAccount.labels }}
10- {{- toYaml . | nindent 4 }}
11- {{- end }}
12- {{- with .Values.updater.serviceAccount.annotations }}
13- annotations :
14- {{- toYaml . | nindent 4 }}
15- {{- end }}
1610rules :
1711 - apiGroups :
1812 - " coordination.k8s.io"
@@ -23,11 +17,12 @@ rules:
2317 - apiGroups :
2418 - " coordination.k8s.io"
2519 resourceNames :
26- - vpa- updater
20+ - {{ .Values. updater.leaderElection.resourceName }}
2721 resources :
2822 - leases
2923 verbs :
3024 - get
3125 - watch
3226 - update
3327{{- end -}}
28+ {{- end -}}
Original file line number Diff line number Diff line change 1- {{- if and (.Values.updater.enabled) .Values.rbac.create -}}
1+ {{- if and .Values.updater.enabled .Values.rbac.create -}}
2+ {{- if eq (include "vertical-pod-autoscaler.updater.leaderElectionEnabled" .) "true" }}
23apiVersion : rbac.authorization.k8s.io/v1
34kind : RoleBinding
45metadata :
@@ -13,3 +14,4 @@ subjects:
1314 name : {{ include "vertical-pod-autoscaler.updater.fullname" . }}
1415 namespace : {{ .Release.Namespace }}
1516{{- end -}}
17+ {{- end -}}
Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ updater:
197197 pullPolicy : IfNotPresent
198198
199199 # Number of Updater replicas to create.
200- replicas : 1
200+ replicas : 2
201201
202202 # Labels to add to the Updater pod.
203203 podLabels : {}
@@ -211,3 +211,19 @@ updater:
211211 labels : {}
212212 # Annotations to add to the Updater service account.
213213 annotations : {}
214+
215+ # Leader election configuration for the Updater.
216+ # When running multiple replicas, leader election ensures only one instance is actively processing.
217+ leaderElection :
218+ # Enable leader election. If not set (null), automatically enabled when replicas > 1
219+ enabled :
220+ # Namespace for the lease resource. Defaults to Release.Namespace if not set.
221+ resourceNamespace : " "
222+ # Name of the lease resource.
223+ resourceName : vpa-updater-lease
224+ # Duration that non-leader candidates will wait after observing a leadership renewal.
225+ leaseDuration : 15s
226+ # Interval between attempts by the acting master to renew a leadership slot.
227+ renewDeadline : 10s
228+ # Duration the clients should wait between attempting acquisition and renewal of a leadership.
229+ retryPeriod : 2s
You can’t perform that action at this time.
0 commit comments