Repository navigation
Expand file tree
/
Copy path80-bootstrap-domain.yaml
More file actions
78 lines (78 loc) · 2.72 KB
/
Copy path80-bootstrap-domain.yaml
File metadata and controls
78 lines (78 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# One-shot bootstrap Job: seeds a single Direct domain into config-service.
#
# Why this is needed: direct-sta-sboot refuses to start if config-service returns
# zero domains (it throws ERROR=MissingDomains). This Job registers a placeholder
# domain so the STA (and the rest of the mail pipeline) can come up. It is
# idempotent — a 409 (domain already exists) is treated as success — so it is safe
# to leave in `kubectl apply -f .`.
#
# Change DOMAIN_NAME / edit via the config-ui for a real deployment; a running HISP
# still needs trust anchors, certificates and settings configured beyond this.
apiVersion: batch/v1
kind: Job
metadata:
name: bootstrap-domain
namespace: direct-project
spec:
backoffLimit: 10
ttlSecondsAfterFinished: 600
template:
metadata:
labels:
app: bootstrap-domain
spec:
restartPolicy: OnFailure
containers:
- name: seed
image: curlimages/curl:8.11.1
env:
- name: CONFIG_URL
value: "http://config-service:8080"
- name: CONFIG_USER
valueFrom:
secretKeyRef:
name: bootstrap-domain-config
key: user
- name: CONFIG_PASS
valueFrom:
secretKeyRef:
name: bootstrap-domain-config
key: password
- name: DOMAIN_NAME
valueFrom:
secretKeyRef:
name: bootstrap-domain-config
key: domain
command:
- /bin/sh
- -c
- |
set -eu
echo "Waiting for config-service to be healthy..."
until curl -sf "${CONFIG_URL}/actuator/health" >/dev/null; do
sleep 3
done
echo "config-service is up. Registering domain ${DOMAIN_NAME}..."
code=$(curl -s -o /tmp/body -w '%{http_code}' -X PUT \
-u "${CONFIG_USER}:${CONFIG_PASS}" \
-H 'Content-Type: application/json' \
--data "{\"domainName\":\"${DOMAIN_NAME}\",\"status\":\"ENABLED\",\"postmasterAddress\":{\"emailAddress\":\"postmaster@${DOMAIN_NAME}\",\"displayName\":\"postmaster\",\"type\":\"postmaster\"}}" \
"${CONFIG_URL}/domain")
echo "HTTP ${code}"
cat /tmp/body || true
echo
case "${code}" in
2*|409) echo "Domain present. Done."; exit 0 ;;
*) echo "Failed to register domain"; exit 1 ;;
esac
---
apiVersion: v1
kind: Secret
metadata:
name: bootstrap-domain-config
namespace: direct-project
type: Opaque
stringData:
user: admin
password: "d1r3ct;"
domain: direct.example.com