Skip to content

Commit d0c4c2a

Browse files
committed
feat(vertical-pod-autoscaler): Support recommender only deployment
Supports a mode of deployment where only the recommender is deployed and the updater and admission controller and not. This provides for a cleaner deployment as opposed to the current state where you can only scale these deployments down to 0. E.g. In the case that alerting has been setup, special casing isn't needed to account for a deployment that's meant to have replicas set at 0. Signed-off-by: Andrew Gershman <[email protected]>
1 parent f1a9d14 commit d0c4c2a

File tree

14 files changed

+31
-8
lines changed

14 files changed

+31
-8
lines changed

charts/vertical-pod-autoscaler/templates/admission-controller/certificate.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.admissionController.certManager.enabled -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.admissionController.certManager.enabled -}}
22
{{- if not .Values.admissionController.certManager.issuerName }}
33
apiVersion: cert-manager.io/v1
44
kind: Issuer

charts/vertical-pod-autoscaler/templates/admission-controller/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.recommenderOnly -}}
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
@@ -109,3 +110,4 @@ spec:
109110
tolerations:
110111
{{- toYaml . | nindent 8 }}
111112
{{- end }}
113+
{{- end -}}

charts/vertical-pod-autoscaler/templates/admission-controller/pdb.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.admissionController.podDisruptionBudget.enabled -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.admissionController.podDisruptionBudget.enabled -}}
22
apiVersion: {{ include "vertical-pod-autoscaler.pdb.apiVersion" . }}
33
kind: PodDisruptionBudget
44
metadata:

charts/vertical-pod-autoscaler/templates/admission-controller/service.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.recommenderOnly -}}
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -20,3 +21,4 @@ spec:
2021
targetPort: http-metrics
2122
selector:
2223
{{- include "vertical-pod-autoscaler.admissionController.selectorLabels" . | nindent 4 }}
24+
{{- end -}}

charts/vertical-pod-autoscaler/templates/admission-controller/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.admissionController.serviceAccount.create -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.admissionController.serviceAccount.create -}}
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:

charts/vertical-pod-autoscaler/templates/admission-controller/servicemonitor.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.serviceMonitor.enabled -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.serviceMonitor.enabled -}}
22
apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:

charts/vertical-pod-autoscaler/templates/admission-controller/webhook.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.recommenderOnly -}}
12
{{- $tls := fromYaml (include "vertical-pod-autoscaler.admissionController.webhookCert" .) -}}
23
{{- if not .Values.admissionController.certManager.enabled }}
34
apiVersion: v1
@@ -46,3 +47,4 @@ webhooks:
4647
apiGroups: ["autoscaling.k8s.io"]
4748
apiVersions: ["*"]
4849
resources: ["verticalpodautoscalers"]
50+
{{- end -}}

charts/vertical-pod-autoscaler/templates/rbac.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ rules:
173173
- get
174174
- list
175175
- watch
176+
{{ if not .Values.recommenderOnly }}
176177
---
177178
apiVersion: rbac.authorization.k8s.io/v1
178179
kind: ClusterRole
@@ -227,6 +228,7 @@ rules:
227228
- get
228229
- list
229230
- watch
231+
{{ end }}
230232
---
231233
apiVersion: rbac.authorization.k8s.io/v1
232234
kind: ClusterRole
@@ -273,9 +275,11 @@ subjects:
273275
- kind: ServiceAccount
274276
name: {{ include "vertical-pod-autoscaler.recommender.serviceAccountName" . }}
275277
namespace: {{ .Release.Namespace }}
278+
{{- if not .Values.recommenderOnly }}
276279
- kind: ServiceAccount
277280
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
278281
namespace: {{ .Release.Namespace }}
282+
{{ end }}
279283
---
280284
apiVersion: rbac.authorization.k8s.io/v1
281285
kind: ClusterRoleBinding
@@ -321,12 +325,15 @@ subjects:
321325
- kind: ServiceAccount
322326
name: {{ include "vertical-pod-autoscaler.recommender.serviceAccountName" . }}
323327
namespace: {{ .Release.Namespace }}
328+
{{- if not .Values.recommenderOnly }}
324329
- kind: ServiceAccount
325330
name: {{ include "vertical-pod-autoscaler.admissionController.serviceAccountName" . }}
326331
namespace: {{ .Release.Namespace }}
327332
- kind: ServiceAccount
328333
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
329334
namespace: {{ .Release.Namespace }}
335+
{{ end }}
336+
{{ if not .Values.recommenderOnly }}
330337
---
331338
apiVersion: rbac.authorization.k8s.io/v1
332339
kind: ClusterRoleBinding
@@ -342,6 +349,8 @@ subjects:
342349
- kind: ServiceAccount
343350
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
344351
namespace: {{ .Release.Namespace }}
352+
{{ end }}
353+
{{ if not .Values.recommenderOnly }}
345354
---
346355
apiVersion: rbac.authorization.k8s.io/v1
347356
kind: ClusterRoleBinding
@@ -357,6 +366,8 @@ subjects:
357366
- kind: ServiceAccount
358367
name: {{ include "vertical-pod-autoscaler.admissionController.serviceAccountName" . }}
359368
namespace: {{ .Release.Namespace }}
369+
{{ end }}
370+
{{ if not .Values.recommenderOnly }}
360371
---
361372
apiVersion: rbac.authorization.k8s.io/v1
362373
kind: ClusterRoleBinding
@@ -372,4 +383,5 @@ subjects:
372383
- kind: ServiceAccount
373384
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
374385
namespace: {{ .Release.Namespace }}
386+
{{ end }}
375387
{{- end -}}

charts/vertical-pod-autoscaler/templates/updater/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.recommenderOnly -}}
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:
@@ -93,3 +94,4 @@ spec:
9394
tolerations:
9495
{{- toYaml . | nindent 8 }}
9596
{{- end }}
97+
{{- end -}}

charts/vertical-pod-autoscaler/templates/updater/pdb.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.updater.podDisruptionBudget.enabled -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.updater.podDisruptionBudget.enabled -}}
22
apiVersion: {{ include "vertical-pod-autoscaler.pdb.apiVersion" . }}
33
kind: PodDisruptionBudget
44
metadata:

charts/vertical-pod-autoscaler/templates/updater/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.serviceMonitor.enabled -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.serviceMonitor.enabled -}}
22
apiVersion: v1
33
kind: Service
44
metadata:

charts/vertical-pod-autoscaler/templates/updater/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.updater.serviceAccount.create -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.updater.serviceAccount.create -}}
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:

charts/vertical-pod-autoscaler/templates/updater/servicemonitor.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.serviceMonitor.enabled -}}
1+
{{- if and (not .Values.recommenderOnly) .Values.serviceMonitor.enabled -}}
22
apiVersion: monitoring.coreos.com/v1
33
kind: ServiceMonitor
44
metadata:

charts/vertical-pod-autoscaler/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ serviceMonitor:
1919

2020
logLevel: 4
2121

22+
# Only deploy the recommender
23+
recommenderOnly: false
24+
2225
admissionController:
2326
image:
2427
repository: registry.k8s.io/autoscaling/vpa-admission-controller

0 commit comments

Comments
 (0)