Skip to content

Commit 51b6969

Browse files
authored
Merge pull request #8798 from mwiede/feature/securitycontext
feat(vpa-chart): add pod-level and container-level securitycontext
2 parents 7fe519c + a92dfbf commit 51b6969

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

vertical-pod-autoscaler/charts/vertical-pod-autoscaler/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ The Vertical Pod Autoscaler (VPA) automatically adjusts the CPU and memory resou
6161
| admissionController.volumes[0].secret.defaultMode | int | `420` | |
6262
| admissionController.volumes[0].secret.secretName | string | `"vpa-tls-certs"` | |
6363
| commonLabels | object | `{}` | |
64+
| containerSecurityContext | object | `{}` | |
6465
| fullnameOverride | string | `nil` | |
6566
| imagePullSecrets | list | `[]` | |
6667
| nameOverride | string | `nil` | |
68+
| podSecurityContext.runAsNonRoot | bool | `true` | |
69+
| podSecurityContext.runAsUser | int | `65534` | |
6770
| rbac.create | bool | `true` | |
6871
| recommender.affinity | object | `{}` | |
6972
| recommender.enabled | bool | `true` | |

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ spec:
3232
{{- toYaml . | nindent 8 }}
3333
{{- end }}
3434
serviceAccountName: {{ include "vertical-pod-autoscaler.admissionController.fullname" . }}
35+
{{- with .Values.podSecurityContext }}
3536
securityContext:
36-
runAsNonRoot: true
37-
runAsUser: 65534
37+
{{ toYaml . | nindent 8 | trim }}
38+
{{- end }}
3839
{{- with .Values.admissionController.nodeSelector }}
3940
nodeSelector:
4041
{{- toYaml . | nindent 8 }}
@@ -92,6 +93,10 @@ spec:
9293
resources:
9394
{{- toYaml . | nindent 12 }}
9495
{{- end }}
96+
{{- with .Values.containerSecurityContext }}
97+
securityContext:
98+
{{ toYaml . | nindent 12 | trim }}
99+
{{- end }}
95100
volumes:
96101
{{- toYaml .Values.admissionController.volumes | nindent 12 }}
97102
{{- end -}}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ spec:
3232
{{- toYaml . | nindent 8 }}
3333
{{- end }}
3434
serviceAccountName: {{ include "vertical-pod-autoscaler.recommender.fullname" . }}
35+
{{- with .Values.podSecurityContext }}
3536
securityContext:
36-
runAsNonRoot: true
37-
runAsUser: 65534
37+
{{ toYaml . | nindent 8 | trim }}
38+
{{- end }}
3839
containers:
3940
- name: recommender
4041
image: {{ include "vertical-pod-autoscaler.recommender.image" . }}
@@ -89,6 +90,10 @@ spec:
8990
resources:
9091
{{- toYaml . | nindent 10 }}
9192
{{- end }}
93+
{{- with .Values.containerSecurityContext }}
94+
securityContext:
95+
{{ toYaml . | nindent 10 | trim }}
96+
{{- end }}
9297
{{- with .Values.recommender.nodeSelector }}
9398
nodeSelector:
9499
{{- toYaml . | nindent 8 }}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ spec:
2828
{{- toYaml . | nindent 8 }}
2929
{{- end }}
3030
serviceAccountName: {{ include "vertical-pod-autoscaler.updater.fullname" . }}
31+
{{- with .Values.podSecurityContext }}
3132
securityContext:
32-
runAsNonRoot: true
33-
runAsUser: 65534
33+
{{ toYaml . | nindent 8 | trim }}
34+
{{- end }}
3435
containers:
3536
- name: updater
3637
image: {{ include "vertical-pod-autoscaler.updater.image" . }}
@@ -58,4 +59,8 @@ spec:
5859
scheme: HTTP
5960
periodSeconds: 10
6061
failureThreshold: 3
62+
{{- with .Values.containerSecurityContext }}
63+
securityContext:
64+
{{ toYaml . | nindent 12 | trim }}
65+
{{- end }}
6166
{{- end -}}

vertical-pod-autoscaler/charts/vertical-pod-autoscaler/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ rbac:
1414
# If `true`, create `ClusterRole` & `ClusterRoleBinding` resources to enable access to the Kubernetes API.
1515
create: true
1616

17+
podSecurityContext:
18+
runAsNonRoot: true
19+
runAsUser: 65534
20+
21+
containerSecurityContext: {}
22+
1723
admissionController:
1824
enabled: true
1925
image:

0 commit comments

Comments
 (0)