Skip to content

Commit 3eddc53

Browse files
lexfreiclaude
andcommitted
feat(openbao): add TLS with cert-manager self-signed certificates
Enable TLS for OpenBAO using per-instance cert-manager Issuer and Certificate resources. The upstream chart auto-switches to HTTPS when global.tlsDisable is false, affecting BAO_ADDR, readiness probes, and port names. Changes: - Add cert-manager Issuer + Certificate template with DNS SANs covering service, headless service, and pod addresses - Set global.tlsDisable: false and mount TLS secret via server.volumes/volumeMounts - Update HCL listener configs with tls_cert_file/tls_key_file - Update HA retry_join to use HTTPS with leader_ca_cert_file - Update E2E test with BAO_SKIP_VERIFY=true and certificate wait Co-Authored-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 7393ec0 commit 3eddc53

3 files changed

Lines changed: 45 additions & 6 deletions

File tree

‎hack/e2e-apps/openbao.bats‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,26 @@ spec:
1818
ui: true
1919
EOF
2020
sleep 5
21+
kubectl -n tenant-test wait certificate openbao-$name-tls --timeout=60s --for=condition=ready
2122
kubectl -n tenant-test wait hr openbao-$name --timeout=60s --for=condition=ready
2223
kubectl -n tenant-test wait hr openbao-$name-system --timeout=120s --for=condition=ready
2324

2425
# Wait for pod to be running (OpenBAO starts sealed, so pod is Running but not Ready)
2526
kubectl -n tenant-test wait pod openbao-$name-0 --timeout=90s --for=jsonpath='{.status.phase}'=Running
2627

2728
# Wait for OpenBAO API to accept connections (exit code 2 = sealed but responsive, 1 = not ready)
28-
timeout 30 sh -ec "until kubectl -n tenant-test exec openbao-$name-0 -- sh -c 'bao status >/dev/null 2>&1; test \$? -ne 1'; do sleep 3; done"
29+
timeout 30 sh -ec "until kubectl -n tenant-test exec openbao-$name-0 -- sh -c 'BAO_SKIP_VERIFY=true bao status >/dev/null 2>&1; test \$? -ne 1'; do sleep 3; done"
2930

3031
# Initialize OpenBAO (single key share for testing simplicity)
31-
init_output=$(kubectl -n tenant-test exec openbao-$name-0 -- bao operator init -key-shares=1 -key-threshold=1 -format=json)
32+
init_output=$(kubectl -n tenant-test exec openbao-$name-0 -- sh -c 'BAO_SKIP_VERIFY=true bao operator init -key-shares=1 -key-threshold=1 -format=json')
3233
unseal_key=$(echo "$init_output" | jq -r '.unseal_keys_b64[0]')
3334
if [ -z "$unseal_key" ] || [ "$unseal_key" = "null" ]; then
3435
echo "Failed to extract unseal key. Init output: $init_output" >&2
3536
return 1
3637
fi
3738

3839
# Unseal OpenBAO
39-
kubectl -n tenant-test exec openbao-$name-0 -- bao operator unseal "$unseal_key"
40+
kubectl -n tenant-test exec openbao-$name-0 -- sh -c "BAO_SKIP_VERIFY=true bao operator unseal '$unseal_key'"
4041

4142
# Now wait for pod to become ready (readiness probe checks seal status)
4243
kubectl -n tenant-test wait sts openbao-$name --timeout=90s --for=jsonpath='{.status.readyReplicas}'=1
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Issuer
3+
metadata:
4+
name: {{ .Release.Name }}-selfsigned
5+
spec:
6+
selfSigned: {}
7+
---
8+
apiVersion: cert-manager.io/v1
9+
kind: Certificate
10+
metadata:
11+
name: {{ .Release.Name }}-tls
12+
spec:
13+
secretName: {{ .Release.Name }}-tls
14+
issuerRef:
15+
name: {{ .Release.Name }}-selfsigned
16+
kind: Issuer
17+
dnsNames:
18+
- "{{ .Release.Name }}"
19+
- "{{ .Release.Name }}-internal"
20+
- "*.{{ .Release.Name }}-internal"
21+
- "{{ .Release.Name }}.{{ .Release.Namespace }}.svc"
22+
- "{{ .Release.Name }}-internal.{{ .Release.Namespace }}.svc"
23+
- "*.{{ .Release.Name }}-internal.{{ .Release.Namespace }}.svc.cluster.local"
24+
duration: 87600h
25+
renewBefore: 720h

‎packages/apps/openbao/templates/openbao.yaml‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ spec:
2424
values:
2525
openbao:
2626
fullnameOverride: {{ .Release.Name }}
27+
global:
28+
tlsDisable: false
2729
server:
2830
resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.resourcesPreset .Values.resources $) | nindent 10 }}
31+
volumes:
32+
- name: tls
33+
secret:
34+
secretName: {{ .Release.Name }}-tls
35+
volumeMounts:
36+
- name: tls
37+
mountPath: /openbao/tls
38+
readOnly: true
2939
dataStorage:
3040
enabled: true
3141
size: {{ .Values.size }}
@@ -45,16 +55,18 @@ spec:
4555
ui = {{ .Values.ui }}
4656
4757
listener "tcp" {
48-
tls_disable = 1
4958
address = "[::]:8200"
5059
cluster_address = "[::]:8201"
60+
tls_cert_file = "/openbao/tls/tls.crt"
61+
tls_key_file = "/openbao/tls/tls.key"
5162
}
5263
5364
storage "raft" {
5465
path = "/openbao/data"
5566
{{- range $i := until (int $.Values.replicas) }}
5667
retry_join {
57-
leader_api_addr = "http://{{ $.Release.Name }}-{{ $i }}.{{ $.Release.Name }}-internal:8200"
68+
leader_api_addr = "https://{{ $.Release.Name }}-{{ $i }}.{{ $.Release.Name }}-internal:8200"
69+
leader_ca_cert_file = "/openbao/tls/ca.crt"
5870
}
5971
{{- end }}
6072
}
@@ -67,9 +79,10 @@ spec:
6779
ui = {{ .Values.ui }}
6880
6981
listener "tcp" {
70-
tls_disable = 1
7182
address = "[::]:8200"
7283
cluster_address = "[::]:8201"
84+
tls_cert_file = "/openbao/tls/tls.crt"
85+
tls_key_file = "/openbao/tls/tls.key"
7386
}
7487
7588
storage "file" {

0 commit comments

Comments
 (0)