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 d0c4c2a
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.admissionController.certManager.enabled -}}
{{- if and (not .Values.recommenderOnly) .Values.admissionController.certManager.enabled -}}
{{- if not .Values.admissionController.certManager.issuerName }}
apiVersion: cert-manager.io/v1
kind: Issuer
Expand Down
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,4 +1,4 @@
{{- if .Values.admissionController.podDisruptionBudget.enabled -}}
{{- if and (not .Values.recommenderOnly) .Values.admissionController.podDisruptionBudget.enabled -}}
apiVersion: {{ include "vertical-pod-autoscaler.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
Expand Down
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,4 +1,4 @@
{{- if .Values.admissionController.serviceAccount.create -}}
{{- if and (not .Values.recommenderOnly) .Values.admissionController.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.serviceMonitor.enabled -}}
{{- if and (not .Values.recommenderOnly) .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
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: 1 addition & 1 deletion charts/vertical-pod-autoscaler/templates/updater/pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.updater.podDisruptionBudget.enabled -}}
{{- if and (not .Values.recommenderOnly) .Values.updater.podDisruptionBudget.enabled -}}
apiVersion: {{ include "vertical-pod-autoscaler.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.serviceMonitor.enabled -}}
{{- if and (not .Values.recommenderOnly) .Values.serviceMonitor.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.updater.serviceAccount.create -}}
{{- if and (not .Values.recommenderOnly) .Values.updater.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.serviceMonitor.enabled -}}
{{- if and (not .Values.recommenderOnly) .Values.serviceMonitor.enabled -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
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 d0c4c2a

Please sign in to comment.