Pre-flight check before each server pod starts (K-C5) #23
No files matched your search
@@ -65,6 +65,13 @@ runs, pinned by digest.
|
||||
address from the PROXY header, believed only from `trustedNetworks`, the
|
||||
load balancer's own addresses. It needs `externalTrafficPolicy: Local`, and
|
||||
server 27.1-rc.32.
|
||||
- A pre-flight check before each server pod starts (`server.check`, on by
|
||||
default): an init container runs `inbuxa --check`, which opens the data
|
||||
store, writes, reads and deletes a small object in the blob store, and
|
||||
connects to NATS. A pod that can't use one stays in `Init:Error`, and its
|
||||
status names the part and why. The server container keeps its last log
|
||||
lines as its termination message too. Needs server 27.1-rc.33: an older
|
||||
server doesn't know `--check`.
|
||||
- `networkPolicy`, on by default: every pod starts from deny all, in and
|
||||
out, and gets only what it needs. The server takes mail on its listeners
|
||||
from anywhere and connects anywhere; `networkPolicy.httpFrom` and
|
||||
|
||||
@@ -126,11 +126,51 @@ spec:
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $server.check.enabled }}
|
||||
initContainers:
|
||||
# The data layer can be used, or the pod's status says which part
|
||||
# can't, and why (server --check: exit 78 bad configuration,
|
||||
# 69 unreachable, 77 credentials refused, 76 TLS failed)
|
||||
- name: check
|
||||
image: {{ include "inbuxa.server.image" $root }}
|
||||
imagePullPolicy: {{ $server.image.pullPolicy }}
|
||||
args: ["--config", "/etc/inbuxa/config.json", "--check"]
|
||||
terminationMessagePolicy: FallbackToLogsOnError
|
||||
env:
|
||||
- name: INBUXA_HOSTNAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
{{- with $g.extraEnv }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml $server.check.resources | nindent 12 }}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities:
|
||||
drop: [ALL]
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/inbuxa/config.json
|
||||
subPath: config.json
|
||||
readOnly: true
|
||||
{{- if $server.secretMounts }}
|
||||
- name: secrets
|
||||
mountPath: /etc/inbuxa/secrets
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: server
|
||||
image: {{ include "inbuxa.server.image" $root }}
|
||||
imagePullPolicy: {{ $server.image.pullPolicy }}
|
||||
args: ["--config", "/etc/inbuxa/config.json"]
|
||||
# A start that can't open the data store says why on its last lines
|
||||
terminationMessagePolicy: FallbackToLogsOnError
|
||||
env:
|
||||
- name: INBUXA_HOSTNAME
|
||||
valueFrom:
|
||||
|
||||
@@ -309,3 +309,33 @@ tests:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: needs externalTrafficPolicy Local
|
||||
|
||||
- it: checks the data layer before each server pod starts
|
||||
template: server/deployment.yaml
|
||||
documentIndex: 0
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.template.spec.initContainers[0].name
|
||||
value: check
|
||||
- equal:
|
||||
path: spec.template.spec.initContainers[0].args
|
||||
value: ["--config", "/etc/inbuxa/config.json", "--check"]
|
||||
- equal:
|
||||
path: spec.template.spec.initContainers[0].terminationMessagePolicy
|
||||
value: FallbackToLogsOnError
|
||||
- equal:
|
||||
path: spec.template.spec.initContainers[0].securityContext.readOnlyRootFilesystem
|
||||
value: true
|
||||
- equal:
|
||||
path: spec.template.spec.containers[0].terminationMessagePolicy
|
||||
value: FallbackToLogsOnError
|
||||
|
||||
- it: leaves the check out when it's turned off
|
||||
template: server/deployment.yaml
|
||||
documentIndex: 0
|
||||
set:
|
||||
server.check.enabled: false
|
||||
asserts:
|
||||
- notExists:
|
||||
path: spec.template.spec.initContainers
|
||||
|
||||
@@ -287,6 +287,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"check": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"resources": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"publicUrl": {
|
||||
"type": "string",
|
||||
"pattern": "^(https?://[^/\\s]+)?$"
|
||||
|
||||
@@ -76,6 +76,20 @@ server:
|
||||
timeoutSeconds: 1800
|
||||
resources: {}
|
||||
|
||||
# Before each server pod starts, an init container checks the data layer
|
||||
# (`inbuxa --check`): it opens the data store, writes, reads and deletes a
|
||||
# small object in the blob store, and connects to NATS. A pod that can't
|
||||
# use one stays in Init:Error, and its status names the part and why
|
||||
# (kubectl describe pod). Needs server 27.1-rc.33 or later.
|
||||
check:
|
||||
enabled: true
|
||||
resources:
|
||||
requests:
|
||||
cpu: 50m
|
||||
memory: 64Mi
|
||||
limits:
|
||||
memory: 256Mi
|
||||
|
||||
# Where browsers and clients reach the server, as https://host. Sign-in
|
||||
# pages and OAuth metadata name it.
|
||||
publicUrl: ""
|
||||
|
||||
Reference in new issue
Block a user