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: make privilege levels selectable in values file #1007

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,21 @@ Image Name
{{- define "canary-checker.imageString" -}}
{{ .Values.image.repository }}{{- if eq (lower .Values.image.type) "full" }}-full{{- end }}:{{ .Values.image.tag }}
{{- end }}

{{/*
Container Security Context
*/}}
{{- define "canary-checker.containerSecurityContext" -}}
allowPrivilegeEscalation: {{- if eq ( lower .Values.privilegeMode ) "privileged" }}true{{- else }}false{{- end }}
{{- if has ( lower .Values.privilegeMode) ( list "privileged" "root" ) }}
runAsUser: 0
runAsGroup: 0
fsGroup: 0
{{- if eq ( lower .Values.privilegeMode ) "privileged" }}
capabilities:
add:
- CAP_NET_RAW
{{- end }}
{{- end }}
{{- end }}

25 changes: 7 additions & 18 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ kind: Deployment
{{- end }}
metadata:
name: {{ include "canary-checker.name" . }}
labels:
{{- include "canary-checker.labels" . | nindent 4 }}
labels: {{- include "canary-checker.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
{{- include "canary-checker.selectorLabels" . | nindent 6 }}
matchLabels: {{- include "canary-checker.selectorLabels" . | nindent 6 }}
{{- if eq .Values.db.external.enabled false }}
{{- if eq .Values.db.embedded.persist true }}
serviceName: {{ include "canary-checker.fullname" . }}
volumeClaimTemplates:
- metadata:
name: canarychecker-database
labels:
{{- include "canary-checker.labels" . | nindent 10 }}
labels: {{- include "canary-checker.labels" . | nindent 10 }}
spec:
storageClassName: {{ .Values.db.embedded.storageClass }}
accessModes: ["ReadWriteOnce"]
Expand All @@ -31,8 +28,7 @@ spec:
{{- end }}
template:
metadata:
labels:
{{- include "canary-checker.selectorLabels" . | nindent 8 }}
labels: {{- include "canary-checker.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "canary-checker.fullname" . }}-sa
volumes:
Expand All @@ -58,15 +54,9 @@ spec:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
securityContext:
fsGroup: 1000
containers:
- name: {{ include "canary-checker.name" . }}
securityContext:
allowPrivilegeEscalation: {{.Values.allowPrivilegeEscalation}}
capabilities:
add:
- CAP_NET_RAW
securityContext: {{- include "canary-checker.containerSecurityContext" . | nindent 12 }}
image: {{ include "canary-checker.imageString" . }}
imagePullPolicy: "{{ .Values.image.pullPolicy }}"
env:
Expand Down Expand Up @@ -109,8 +99,7 @@ spec:
- "8080"
- --disable-postgrest={{ .Values.disablePostgrest }}
- --db-migrations={{ .Values.db.runMigrations }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
resources: {{- toYaml .Values.resources | nindent 12 }}
livenessProbe:
httpGet:
path: /health
Expand All @@ -120,5 +109,5 @@ spec:
path: /health
port: 8080
{{- with .Values.extra }}
{{- toYaml . | nindent 6 }}
{{- toYaml . | indent 6 }}
{{- end }}
6 changes: 6 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ disablePostgrest: false
debug: false
logLevel: "-v"

## Options: unprivileged | root | privileged
## unprivileged: runs as noot root user, cannot escalate permissions
## root: runs as root user, cannot escalate permissions. Required to run ping checks
## privileged: runs as root user, may escalate CAP_NET_RAW. Required to run docker and container checks
privilegeMode: unprivileged

db:
runMigrations: false
embedded:
Expand Down