Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Flexible security contexts #206

Merged
merged 8 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/retool/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: retool
description: A Helm chart for Kubernetes
type: application
version: 6.3.1
version: 6.3.2
maintainers:
- name: Retool Engineering
email: [email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ replicaCount: 1

persistentVolumeClaim:
size: '3Gi'

securityContext:
enabled: true
runAsUser: 1000
fsGroup: 2000
extraContainerLevelSecurityContext:
allowPrivilegeEscalation: false
# ================================================

# === New telemetry stuff ===
Expand Down
9 changes: 9 additions & 0 deletions charts/retool/ci/test-extra-security-context-option.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# default security context
securityContext:
enabled: true
runAsUser: 10
fsGroup: 20
extraSecurityContext:
runAsNonRoot: true
extraContainerLevelSecurityContext:
allowPrivilegeEscalation: false
7 changes: 7 additions & 0 deletions charts/retool/templates/deployment_backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ spec:
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- if .Values.securityContext.extraContainerSecurityContext }}
securityContext:
{{ toYaml .Values.securityContext.extraContainerSecurityContext | indent 10 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
Expand All @@ -327,6 +331,9 @@ spec:
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- if .Values.securityContext.extraSecurityContext }}
{{ toYaml .Values.securityContext.extraSecurityContext | indent 8 }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.extraConfigMapMounts }}
Expand Down
13 changes: 10 additions & 3 deletions charts/retool/templates/deployment_jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ spec:
envFrom:
- secretRef:
name: {{ .Values.externalSecrets.name }}
{{- range .Values.externalSecrets.secrets }}
- secretRef:
name: {{ .name }}
{{- range .Values.externalSecrets.secrets }}
- secretRef:
name: {{ .name }}
{{- end }}
{{- end }}
{{- if .Values.externalSecrets.externalSecretsOperator.enabled }}
Expand Down Expand Up @@ -222,6 +222,10 @@ spec:
- name: {{ .name }}
mountPath: {{ .mountPath }}
subPath: {{ .subPath }}
{{- end }}
{{- if .Values.securityContext.extraContainerSecurityContext }}
securityContext:
{{ toYaml .Values.securityContext.extraContainerSecurityContext | indent 10 }}
{{- end }}
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
Expand All @@ -241,6 +245,9 @@ spec:
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- if .Values.securityContext.extraSecurityContext }}
{{ toYaml .Values.securityContext.extraSecurityContext | indent 8 }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.extraConfigMapMounts }}
Expand Down
7 changes: 7 additions & 0 deletions charts/retool/templates/deployment_multiplayer_ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ spec:
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if .Values.securityContext.extraContainerSecurityContext }}
securityContext:
{{ toYaml .Values.securityContext.extraContainerSecurityContext | indent 10 }}
{{- end }}
{{- with .Values.extraContainers }}
{{ tpl . $ | indent 6 }}
{{- end }}
Expand All @@ -186,6 +190,9 @@ spec:
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- if .Values.securityContext.extraSecurityContext }}
{{ toYaml .Values.securityContext.extraSecurityContext | indent 8 }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.extraConfigMapMounts }}
Expand Down
7 changes: 7 additions & 0 deletions charts/retool/templates/deployment_workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ spec:
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if .Values.securityContext.extraContainerSecurityContext }}
securityContext:
{{ toYaml .Values.securityContext.extraContainerSecurityContext | indent 10 }}
{{- end }}
{{- with .Values.extraContainers }}
{{ tpl . $ | indent 6 }}
{{- end }}
Expand All @@ -292,6 +296,9 @@ spec:
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- if .Values.securityContext.extraSecurityContext }}
{{ toYaml .Values.securityContext.extraSecurityContext | indent 8 }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.extraConfigMapMounts }}
Expand Down
7 changes: 7 additions & 0 deletions charts/retool/templates/deployment_workflows_worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ spec:
{{- if .Values.extraVolumeMounts }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if .Values.securityContext.extraContainerSecurityContext }}
securityContext:
{{ toYaml .Values.securityContext.extraContainerSecurityContext | indent 10 }}
{{- end }}
{{- with .Values.extraContainers }}
{{ tpl . $ | indent 6 }}
{{- end }}
Expand All @@ -304,6 +308,9 @@ spec:
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- if .Values.securityContext.extraSecurityContext }}
{{ toYaml .Values.securityContext.extraSecurityContext | indent 8 }}
{{- end }}
{{- end }}
volumes:
{{- range .Values.extraConfigMapMounts }}
Expand Down
7 changes: 6 additions & 1 deletion charts/retool/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,14 @@ persistentVolumeClaim:
# default security context
securityContext:
enabled: false
allowPrivilegeEscalation: false
runAsUser: 1000
fsGroup: 2000
# Use this section to define additional pod security context values for primary Retool pods not provided by default.
# See this doc for options allowed here (ensure the Kubernetes version matches the version of the Kubernetes cluster you are deploying to): https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#podsecuritycontext-v1-core
extraSecurityContext: {}
# Use this section to define additional container security context values for primary Retool pods not provided by default.
# See this doc for options allowed here (ensure the Kubernetes version matches the version of the Kubernetes cluster you are deploying to): https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#securitycontext-v1-core
extraContainerSecurityContext: {}

extraConfigMapMounts: []

Expand Down
7 changes: 6 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,14 @@ persistentVolumeClaim:
# default security context
securityContext:
enabled: false
allowPrivilegeEscalation: false
runAsUser: 1000
fsGroup: 2000
# Use this section to define additional pod security context values for primary Retool pods not provided by default.
# See this doc for options allowed here (ensure the Kubernetes version matches the version of the Kubernetes cluster you are deploying to): https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#podsecuritycontext-v1-core
extraSecurityContext: {}
# Use this section to define additional container security context values for primary Retool pods not provided by default.
# See this doc for options allowed here (ensure the Kubernetes version matches the version of the Kubernetes cluster you are deploying to): https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#securitycontext-v1-core
extraContainerSecurityContext: {}

extraConfigMapMounts: []

Expand Down
Loading