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 @@ -97,9 +97,15 @@ The Vertical Pod Autoscaler (VPA) automatically adjusts the CPU and memory resou
9797| updater.image.pullPolicy | string | ` "IfNotPresent" ` | |
9898| updater.image.repository | string | ` "registry.k8s.io/autoscaling/vpa-updater" ` | |
9999| updater.image.tag | string | ` nil ` | |
100+ | updater.leaderElection.enabled | string | ` nil ` | |
101+ | updater.leaderElection.leaseDuration | string | ` "15s" ` | |
102+ | updater.leaderElection.renewDeadline | string | ` "10s" ` | |
103+ | updater.leaderElection.resourceName | string | ` "vpa-updater-lease" ` | |
104+ | updater.leaderElection.resourceNamespace | string | ` "" ` | |
105+ | updater.leaderElection.retryPeriod | string | ` "2s" ` | |
100106| updater.podAnnotations | object | ` {} ` | |
101107| updater.podLabels | object | ` {} ` | |
102- | updater.replicas | int | ` 1 ` | |
108+ | updater.replicas | int | ` 2 ` | |
103109| updater.serviceAccount.annotations | object | ` {} ` | |
104110| updater.serviceAccount.create | bool | ` true ` | |
105111| 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 4040 valueFrom :
4141 fieldRef :
4242 fieldPath : metadata.namespace
43+ args :
44+ - --v=4
45+ - --stderrthreshold=info
46+ {{- if eq (include "vertical-pod-autoscaler.updater.leaderElectionEnabled" .) "true" }}
47+ - --leader-elect=true
48+ - --leader-elect-resource-namespace={{ .Values.updater.leaderElection.resourceNamespace | default .Release.Namespace }}
49+ - --leader-elect-resource-name={{ .Values.updater.leaderElection.resourceName }}
50+ - --leader-elect-lease-duration={{ .Values.updater.leaderElection.leaseDuration }}
51+ - --leader-elect-renew-deadline={{ .Values.updater.leaderElection.renewDeadline }}
52+ - --leader-elect-retry-period={{ .Values.updater.leaderElection.retryPeriod }}
53+ {{- end }}
4354 ports :
4455 - name : prometheus
4556 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 @@ -191,7 +191,7 @@ updater:
191191 pullPolicy : IfNotPresent
192192
193193 # Number of Updater replicas to create.
194- replicas : 1
194+ replicas : 2
195195
196196 # Labels to add to the Updater pod.
197197 podLabels : {}
@@ -205,3 +205,19 @@ updater:
205205 labels : {}
206206 # Annotations to add to the Updater service account.
207207 annotations : {}
208+
209+ # Leader election configuration for the Updater.
210+ # When running multiple replicas, leader election ensures only one instance is actively processing.
211+ leaderElection :
212+ # Enable leader election. If not set (null), automatically enabled when replicas > 1
213+ enabled :
214+ # Namespace for the lease resource. Defaults to Release.Namespace if not set.
215+ resourceNamespace : " "
216+ # Name of the lease resource.
217+ resourceName : vpa-updater-lease
218+ # Duration that non-leader candidates will wait after observing a leadership renewal.
219+ leaseDuration : 15s
220+ # Interval between attempts by the acting master to renew a leadership slot.
221+ renewDeadline : 10s
222+ # Duration the clients should wait between attempting acquisition and renewal of a leadership.
223+ retryPeriod : 2s
You can’t perform that action at this time.
0 commit comments