Skip to content

Commit

Permalink
feat(vertical-pod-autoscaler): Support recommender only deployment
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
agershman committed Jan 5, 2024
1 parent f1a9d14 commit 8d00ef9
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.admissionController.certManager.enabled -}}
{{- if not .Values.admissionController.certManager.issuerName }}
apiVersion: cert-manager.io/v1
Expand Down Expand Up @@ -28,3 +29,4 @@ spec:
name: {{ include "vertical-pod-autoscaler.admissionController.webhookCertIssuerName" . }}
secretName: {{ include "vertical-pod-autoscaler.admissionController.webhookCertSecret" . }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -109,3 +110,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.admissionController.podDisruptionBudget.enabled -}}
apiVersion: {{ include "vertical-pod-autoscaler.pdb.apiVersion" . }}
kind: PodDisruptionBudget
Expand All @@ -17,3 +18,4 @@ spec:
maxUnavailable: {{ .Values.admissionController.podDisruptionBudget.maxUnavailable }}
{{- end }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -20,3 +21,4 @@ spec:
targetPort: http-metrics
selector:
{{- include "vertical-pod-autoscaler.admissionController.selectorLabels" . | nindent 4 }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.admissionController.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
Expand All @@ -14,3 +15,4 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
Expand Down Expand Up @@ -28,3 +29,4 @@ spec:
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- $tls := fromYaml (include "vertical-pod-autoscaler.admissionController.webhookCert" .) -}}
{{- if not .Values.admissionController.certManager.enabled }}
apiVersion: v1
Expand Down Expand Up @@ -46,3 +47,4 @@ webhooks:
apiGroups: ["autoscaling.k8s.io"]
apiVersions: ["*"]
resources: ["verticalpodautoscalers"]
{{- end -}}
12 changes: 12 additions & 0 deletions charts/vertical-pod-autoscaler/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ rules:
- get
- list
- watch
{{ if not .Values.recommenderOnly }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -227,6 +228,7 @@ rules:
- get
- list
- watch
{{ end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -273,9 +275,11 @@ subjects:
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.recommender.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- if not .Values.recommenderOnly }}
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand Down Expand Up @@ -321,12 +325,15 @@ subjects:
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.recommender.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- if not .Values.recommenderOnly }}
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.admissionController.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
{{ if not .Values.recommenderOnly }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -342,6 +349,8 @@ subjects:
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
{{ if not .Values.recommenderOnly }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -357,6 +366,8 @@ subjects:
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.admissionController.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
{{ if not .Values.recommenderOnly }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -372,4 +383,5 @@ subjects:
- kind: ServiceAccount
name: {{ include "vertical-pod-autoscaler.updater.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{ end }}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -93,3 +94,4 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}
2 changes: 2 additions & 0 deletions charts/vertical-pod-autoscaler/templates/updater/pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.updater.podDisruptionBudget.enabled -}}
apiVersion: {{ include "vertical-pod-autoscaler.pdb.apiVersion" . }}
kind: PodDisruptionBudget
Expand All @@ -17,3 +18,4 @@ spec:
maxUnavailable: {{ .Values.updater.podDisruptionBudget.maxUnavailable }}
{{- end }}
{{- end -}}
{{- end -}}
2 changes: 2 additions & 0 deletions charts/vertical-pod-autoscaler/templates/updater/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.serviceMonitor.enabled -}}
apiVersion: v1
kind: Service
Expand All @@ -19,3 +20,4 @@ spec:
selector:
{{- include "vertical-pod-autoscaler.updater.selectorLabels" . | nindent 4 }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.updater.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
Expand All @@ -14,3 +15,4 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.recommenderOnly -}}
{{- if .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
Expand Down Expand Up @@ -28,3 +29,4 @@ spec:
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
3 changes: 3 additions & 0 deletions charts/vertical-pod-autoscaler/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ serviceMonitor:

logLevel: 4

# Only deploy the recommender
recommenderOnly: false

admissionController:
image:
repository: registry.k8s.io/autoscaling/vpa-admission-controller
Expand Down

0 comments on commit 8d00ef9

Please sign in to comment.