webmail: secrets as mounted files, and check the read-only root #20
No files matched your search
+5
-2
@@ -38,7 +38,10 @@ runs, pinned by digest.
|
||||
webmail keeps sessions in sealed cookies, so any replica serves any
|
||||
request, and signs in through the server's page. Its app and OAuth client
|
||||
secrets are a Secret the chart makes (kept across upgrades) or
|
||||
`webmail.existingSecret`. Every server pod is told both addresses, so it
|
||||
registers them as OAuth clients.
|
||||
`webmail.existingSecret`, mounted as files rather than set in its
|
||||
environment; `webmail.previousAppSecret` reads the old app secret during a
|
||||
rotation. The webmail checks its read-only root at start (`IMMUTABLE`).
|
||||
Every server pod is told both addresses, so it registers them as OAuth
|
||||
clients.
|
||||
- `routes`: the server's, the webmail's and the console's public addresses,
|
||||
each by host name, as Gateway API HTTPRoutes or one Ingress.
|
||||
@@ -16,6 +16,9 @@ the server inside the cluster, through the HTTP Service.
|
||||
{{- end }}
|
||||
{{- $name := printf "%s-webmail" (include "inbuxa.fullname" $root) }}
|
||||
{{- $secretName := default $name $wm.existingSecret }}
|
||||
{{- if and $wm.previousAppSecret (not $wm.existingSecret) }}
|
||||
{{- fail "webmail.previousAppSecret needs webmail.existingSecret: the chart's own Secret keeps only the two keys it makes" }}
|
||||
{{- end }}
|
||||
{{- if not $wm.existingSecret }}
|
||||
{{- /* Random once, then kept: a new APP_SECRET would sign everybody out */}}
|
||||
{{- $existing := (lookup "v1" "Secret" $root.Release.Namespace $name).data | default dict }}
|
||||
@@ -42,10 +45,7 @@ metadata:
|
||||
{{- include "inbuxa.labels" $root | nindent 4 }}
|
||||
app.kubernetes.io/component: webmail
|
||||
annotations:
|
||||
ignore-check.kube-linter.io/read-secret-from-env-var: "TODO(K-W4): the webmail reads its secrets from the environment until it takes *_FILE"
|
||||
{{- if $wm.existingSecret }}
|
||||
ignore-check.kube-linter.io/env-value-from: "existingSecret is the operator's, made outside the chart"
|
||||
{{- end }}
|
||||
ignore-check.kube-linter.io/env-var-secret: "the *_SECRET_FILE variables hold paths to the mounted Secret, not secrets"
|
||||
spec:
|
||||
{{- if not $wm.autoscaling.enabled }}
|
||||
replicas: {{ $wm.replicas }}
|
||||
@@ -82,6 +82,8 @@ spec:
|
||||
# node, in the image
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
# Owns the mounted secret files (mode 0440)
|
||||
fsGroup: 1000
|
||||
seccompProfile:
|
||||
type: RuntimeDefault
|
||||
terminationGracePeriodSeconds: 30
|
||||
@@ -133,22 +135,18 @@ spec:
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: APP_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $secretName }}
|
||||
key: app-secret
|
||||
- name: APP_SECRET_PREVIOUS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $secretName }}
|
||||
key: app-secret-previous
|
||||
optional: true
|
||||
- name: OAUTH_CLIENT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ $secretName }}
|
||||
key: oauth-client-secret
|
||||
# Checked at start: a read-only root, nothing kept on disk
|
||||
- name: IMMUTABLE
|
||||
value: "1"
|
||||
# Secrets as files, never in the environment
|
||||
- name: APP_SECRET_FILE
|
||||
value: /etc/inbuxa-webmail/app-secret
|
||||
{{- if $wm.previousAppSecret }}
|
||||
- name: APP_SECRET_PREVIOUS_FILE
|
||||
value: /etc/inbuxa-webmail/app-secret-previous
|
||||
{{- end }}
|
||||
- name: OAUTH_CLIENT_SECRET_FILE
|
||||
value: /etc/inbuxa-webmail/oauth-client-secret
|
||||
{{- with $wm.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
@@ -179,10 +177,17 @@ spec:
|
||||
volumeMounts:
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
- name: secrets
|
||||
mountPath: /etc/inbuxa-webmail
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: tmp
|
||||
emptyDir:
|
||||
sizeLimit: 64Mi
|
||||
- name: secrets
|
||||
secret:
|
||||
secretName: {{ $secretName }}
|
||||
defaultMode: 0440
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
|
||||
@@ -50,11 +50,6 @@ tests:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: ADMIN_URL, value: "https://admin.example.org"}
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content:
|
||||
name: OAUTH_CLIENT_SECRET
|
||||
valueFrom: {secretKeyRef: {name: mail-inbuxa-webmail, key: oauth-client-secret}}
|
||||
- equal:
|
||||
path: spec.replicas
|
||||
value: 2
|
||||
@@ -62,6 +57,34 @@ tests:
|
||||
path: spec.template.spec.containers[0].securityContext.readOnlyRootFilesystem
|
||||
value: true
|
||||
|
||||
- it: gives the webmail its secrets as files, and has it check its read-only root
|
||||
template: webmail.yaml
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Deployment
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: APP_SECRET_FILE, value: /etc/inbuxa-webmail/app-secret}
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: OAUTH_CLIENT_SECRET_FILE, value: /etc/inbuxa-webmail/oauth-client-secret}
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: IMMUTABLE, value: "1"}
|
||||
- notContains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: APP_SECRET_PREVIOUS_FILE, value: /etc/inbuxa-webmail/app-secret-previous}
|
||||
- contains:
|
||||
path: spec.template.spec.volumes
|
||||
content: {name: secrets, secret: {secretName: mail-inbuxa-webmail, defaultMode: 0440}}
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].volumeMounts
|
||||
content: {name: secrets, mountPath: /etc/inbuxa-webmail, readOnly: true}
|
||||
- equal:
|
||||
path: spec.template.spec.securityContext.fsGroup
|
||||
value: 1000
|
||||
|
||||
- it: makes the webmail's secrets when none is given
|
||||
template: webmail.yaml
|
||||
documentSelector:
|
||||
@@ -81,14 +104,33 @@ tests:
|
||||
- hasDocuments:
|
||||
count: 3
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content:
|
||||
name: APP_SECRET
|
||||
valueFrom: {secretKeyRef: {name: my-webmail, key: app-secret}}
|
||||
path: spec.template.spec.volumes
|
||||
content: {name: secrets, secret: {secretName: my-webmail, defaultMode: 0440}}
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Deployment
|
||||
|
||||
- it: reads the old app secret while rotating, from the operator's Secret only
|
||||
template: webmail.yaml
|
||||
set:
|
||||
webmail.existingSecret: my-webmail
|
||||
webmail.previousAppSecret: true
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Deployment
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.template.spec.containers[0].env
|
||||
content: {name: APP_SECRET_PREVIOUS_FILE, value: /etc/inbuxa-webmail/app-secret-previous}
|
||||
|
||||
- it: refuses previousAppSecret on the chart's own Secret
|
||||
template: webmail.yaml
|
||||
set:
|
||||
webmail.previousAppSecret: true
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "previousAppSecret needs webmail.existingSecret"
|
||||
|
||||
- it: tells every server pod about the webmail and the console, so it registers them
|
||||
template: server/deployment.yaml
|
||||
asserts:
|
||||
|
||||
@@ -538,6 +538,9 @@
|
||||
"existingSecret": {
|
||||
"type": "string"
|
||||
},
|
||||
"previousAppSecret": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"trustedProxies": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -201,11 +201,14 @@ webmail:
|
||||
publicUrl: ""
|
||||
replicas: 2
|
||||
# A Secret with app-secret (seals sessions; the same on every replica) and
|
||||
# oauth-client-secret (the server holds it too), and optionally
|
||||
# app-secret-previous (comma-separated secrets that still open sessions
|
||||
# after a rotation). Empty: the chart makes one with random values and
|
||||
# keeps them across upgrades.
|
||||
# oauth-client-secret (the server holds it too). Empty: the chart makes one
|
||||
# with random values and keeps them across upgrades. The webmail reads both
|
||||
# as files, never from its environment.
|
||||
existingSecret: ""
|
||||
# While rotating app-secret: true, with the old value(s), comma-separated,
|
||||
# under app-secret-previous in existingSecret. Sessions sealed with them
|
||||
# still open. Set it back to false once they have expired.
|
||||
previousAppSecret: false
|
||||
# Addresses whose X-Forwarded-For the webmail believes, as CIDRs. Empty:
|
||||
# the private ranges, which covers an ingress inside the cluster.
|
||||
trustedProxies: []
|
||||
|
||||
Reference in new issue
Block a user