Skip to content

Commit b6e4ea9

Browse files
authored
Add VPA for the operator deployment (#284)
2 parents d059eb3 + 73dbac9 commit b6e4ea9

File tree

5 files changed

+145
-0
lines changed

5 files changed

+145
-0
lines changed

charts/etcd-operator/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
| etcdOperator.securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}` | ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |
2727
| etcdOperator.service.port | int | `9443` | Service port |
2828
| etcdOperator.service.type | string | `"ClusterIP"` | Service type |
29+
| etcdOperator.vpa.enabled | bool | `true` | |
30+
| etcdOperator.vpa.maxAllowed.cpu | string | `"1000m"` | |
31+
| etcdOperator.vpa.maxAllowed.memory | string | `"1Gi"` | |
32+
| etcdOperator.vpa.minAllowed.cpu | string | `"100m"` | |
33+
| etcdOperator.vpa.minAllowed.memory | string | `"128Mi"` | |
2934
| fullnameOverride | string | `""` | Override a full name of helm release |
3035
| imagePullSecrets | list | `[]` | |
3136
| kubeRbacProxy.args[0] | string | `"--secure-listen-address=0.0.0.0:8443"` | |
@@ -41,6 +46,11 @@
4146
| kubeRbacProxy.securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]}}` | ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |
4247
| kubeRbacProxy.service.port | int | `8443` | Service port |
4348
| kubeRbacProxy.service.type | string | `"ClusterIP"` | Service type |
49+
| kubeRbacProxy.vpa.enabled | bool | `true` | |
50+
| kubeRbacProxy.vpa.maxAllowed.cpu | string | `"500m"` | |
51+
| kubeRbacProxy.vpa.maxAllowed.memory | string | `"256Mi"` | |
52+
| kubeRbacProxy.vpa.minAllowed.cpu | string | `"50m"` | |
53+
| kubeRbacProxy.vpa.minAllowed.memory | string | `"64Mi"` | |
4454
| kubernetesClusterDomain | string | `"cluster.local"` | Kubernetes cluster domain prefix |
4555
| nameOverride | string | `""` | Override a name of helm release |
4656
| nodeSelector | object | `{}` | ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/ |
@@ -51,4 +61,5 @@
5161
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
5262
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
5363
| tolerations | list | `[]` | ref: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ |
64+
| vpa.updatePolicy | string | `"Auto"` | |
5465

charts/etcd-operator/templates/workload/deployment.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ spec:
4545
readinessProbe:
4646
{{- toYaml . | nindent 12 }}
4747
{{- end }}
48+
{{- if not .Values.etcdOperator.vpa.enabled }}
4849
{{- with .Values.etcdOperator.resources }}
4950
resources:
5051
{{- toYaml . | nindent 12 }}
5152
{{- end }}
53+
{{- end }}
5254
{{- with .Values.etcdOperator.securityContext }}
5355
securityContext:
5456
{{- toYaml . | nindent 12 }}
@@ -87,10 +89,12 @@ spec:
8789
readinessProbe:
8890
{{- toYaml . | nindent 12 }}
8991
{{- end }}
92+
{{- if not .Values.kubeRbacProxy.vpa.enabled }}
9093
{{- with .Values.kubeRbacProxy.resources }}
9194
resources:
9295
{{- toYaml . | nindent 12 }}
9396
{{- end }}
97+
{{- end }}
9498
{{- with .Values.kubeRbacProxy.securityContext }}
9599
securityContext:
96100
{{- toYaml . | nindent 12 }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if or .Values.etcdOperator.vpa.enabled .Values.kubeRbacProxy.vpa.enabled }}
2+
apiVersion: autoscaling.k8s.io/v1
3+
kind: VerticalPodAutoscaler
4+
metadata:
5+
name: {{ include "etcd-operator.fullname" . }}-controller-manager
6+
labels:
7+
{{- include "etcd-operator.labels" . | nindent 4 }}
8+
spec:
9+
targetRef:
10+
apiVersion: "apps/v1"
11+
kind: Deployment
12+
name: {{ include "etcd-operator.fullname" . }}-controller-manager
13+
updatePolicy:
14+
updateMode: {{ .Values.vpa.updatePolicy | default "Auto" | quote }}
15+
resourcePolicy:
16+
containerPolicies:
17+
{{- if .Values.etcdOperator.vpa.enabled }}
18+
- containerName: etcd-operator
19+
{{- with .Values.etcdOperator.vpa.minAllowed }}
20+
minAllowed:
21+
{{- toYaml . | nindent 10 }}
22+
{{- end }}
23+
{{- with .Values.etcdOperator.vpa.maxAllowed }}
24+
maxAllowed:
25+
{{- toYaml . | nindent 10 }}
26+
{{- end }}
27+
controlledResources: ["cpu", "memory"]
28+
{{- end }}
29+
{{- if .Values.kubeRbacProxy.vpa.enabled }}
30+
- containerName: kube-rbac-proxy
31+
{{- with .Values.kubeRbacProxy.vpa.minAllowed }}
32+
minAllowed:
33+
{{- toYaml . | nindent 10 }}
34+
{{- end }}
35+
{{- with .Values.kubeRbacProxy.vpa.maxAllowed }}
36+
maxAllowed:
37+
{{- toYaml . | nindent 10 }}
38+
{{- end }}
39+
controlledResources: ["cpu", "memory"]
40+
{{- end }}
41+
{{- end }}

charts/etcd-operator/values.schema.json

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,36 @@
131131
}
132132
},
133133
"type": "object"
134+
},
135+
"vpa": {
136+
"properties": {
137+
"enabled": {
138+
"type": "boolean"
139+
},
140+
"maxAllowed": {
141+
"properties": {
142+
"cpu": {
143+
"type": "string"
144+
},
145+
"memory": {
146+
"type": "string"
147+
}
148+
},
149+
"type": "object"
150+
},
151+
"minAllowed": {
152+
"properties": {
153+
"cpu": {
154+
"type": "string"
155+
},
156+
"memory": {
157+
"type": "string"
158+
}
159+
},
160+
"type": "object"
161+
}
162+
},
163+
"type": "object"
134164
}
135165
},
136166
"type": "object"
@@ -227,6 +257,36 @@
227257
}
228258
},
229259
"type": "object"
260+
},
261+
"vpa": {
262+
"properties": {
263+
"enabled": {
264+
"type": "boolean"
265+
},
266+
"maxAllowed": {
267+
"properties": {
268+
"cpu": {
269+
"type": "string"
270+
},
271+
"memory": {
272+
"type": "string"
273+
}
274+
},
275+
"type": "object"
276+
},
277+
"minAllowed": {
278+
"properties": {
279+
"cpu": {
280+
"type": "string"
281+
},
282+
"memory": {
283+
"type": "string"
284+
}
285+
},
286+
"type": "object"
287+
}
288+
},
289+
"type": "object"
230290
}
231291
},
232292
"type": "object"
@@ -270,6 +330,14 @@
270330
},
271331
"tolerations": {
272332
"type": "array"
333+
},
334+
"vpa": {
335+
"properties": {
336+
"updatePolicy": {
337+
"type": "string"
338+
}
339+
},
340+
"type": "object"
273341
}
274342
},
275343
"type": "object"

charts/etcd-operator/values.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ etcdOperator:
8484
drop:
8585
- ALL
8686

87+
vpa:
88+
enabled: true
89+
minAllowed:
90+
cpu: 100m
91+
memory: 128Mi
92+
maxAllowed:
93+
cpu: 1000m
94+
memory: 1Gi
95+
8796
kubeRbacProxy:
8897

8998
image:
@@ -142,6 +151,15 @@ kubeRbacProxy:
142151
drop:
143152
- ALL
144153

154+
vpa:
155+
enabled: true
156+
minAllowed:
157+
cpu: 50m
158+
memory: 64Mi
159+
maxAllowed:
160+
cpu: 500m
161+
memory: 256Mi
162+
145163
# -- Kubernetes cluster domain prefix
146164
kubernetesClusterDomain: cluster.local
147165

@@ -182,3 +200,6 @@ tolerations: []
182200

183201
# -- ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity
184202
affinity: {}
203+
204+
vpa:
205+
updatePolicy: "Auto"

0 commit comments

Comments
 (0)