Skip to content

Commit a2980b8

Browse files
committed
fetch cert from OB and store them in k8 secrets
Signed-off-by: MJarmo <michal.jarmolkiewicz@sap.com>
1 parent 14fefad commit a2980b8

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

showroom/kubectl/tier-1.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ data:
5555
processors: [batch]
5656
exporters: [otlphttp, debug]
5757
---
58+
apiVersion: v1
59+
kind: ServiceAccount
60+
metadata:
61+
name: dice-java-cert-sync
62+
---
63+
apiVersion: rbac.authorization.k8s.io/v1
64+
kind: Role
65+
metadata:
66+
name: dice-java-cert-sync
67+
rules:
68+
- apiGroups: [""]
69+
resources: ["secrets"]
70+
verbs: ["get", "create", "update", "patch"]
71+
---
72+
apiVersion: rbac.authorization.k8s.io/v1
73+
kind: RoleBinding
74+
metadata:
75+
name: dice-java-cert-sync
76+
subjects:
77+
- kind: ServiceAccount
78+
name: dice-java-cert-sync
79+
roleRef:
80+
apiGroup: rbac.authorization.k8s.io
81+
kind: Role
82+
name: dice-java-cert-sync
83+
---
5884
apiVersion: apps/v1
5985
kind: Deployment
6086
metadata:
@@ -71,6 +97,48 @@ spec:
7197
labels:
7298
app: dice-java
7399
spec:
100+
serviceAccountName: dice-java-cert-sync
101+
initContainers:
102+
- name: fetch-openbao-certs
103+
image: alpine:3.21
104+
imagePullPolicy: IfNotPresent
105+
command: ["/bin/sh", "-ec"]
106+
args:
107+
- |
108+
apk add --no-cache curl jq
109+
RESPONSE="$(curl -sS --fail --show-error --insecure \
110+
-H "X-Vault-Token: ${OPENBAO_TOKEN}" \
111+
-H "X-Vault-Namespace: ${OPENBAO_NAMESPACE}" \
112+
-H "X-Vault-Request: true" \
113+
"${OPENBAO_ADDR}/v1/${OPENBAO_CERT_PATH}")"
114+
echo "${RESPONSE}" | jq -er '.data.data.cert' > /etc/dice-java/certs/cert
115+
echo "${RESPONSE}" | jq -er '.data.data.key' > /etc/dice-java/certs/key
116+
env:
117+
- name: OPENBAO_ADDR
118+
value: "https://openbao.cc-d2.showroom.apeirora.eu"
119+
- name: OPENBAO_NAMESPACE
120+
value: "otel/"
121+
- name: OPENBAO_CERT_PATH
122+
value: "kv/data/secret"
123+
- name: OPENBAO_TOKEN
124+
value: "###"
125+
volumeMounts:
126+
- name: dice-java-certs
127+
mountPath: /etc/dice-java/certs
128+
- name: sync-k8s-tls-secret
129+
image: bitnami/kubectl:latest
130+
imagePullPolicy: IfNotPresent
131+
command: ["/bin/sh", "-ec"]
132+
args:
133+
- |
134+
kubectl create secret generic dice-java-openbao-tls \
135+
--from-file=cert=/etc/dice-java/certs/cert \
136+
--from-file=key=/etc/dice-java/certs/key \
137+
--dry-run=client -o yaml \
138+
| kubectl apply -f -
139+
volumeMounts:
140+
- name: dice-java-certs
141+
mountPath: /etc/dice-java/certs
74142
containers:
75143
- name: dice-java
76144
image: ghcr.io/apeirora/audit-log-poc-for-otel/dice-java:latest
@@ -87,6 +155,9 @@ spec:
87155
value: "true"
88156
ports:
89157
- containerPort: 8082
158+
volumeMounts:
159+
- name: dice-java-certs
160+
mountPath: /etc/dice-java/certs
90161
resources:
91162
limits:
92163
memory: 256Mi
@@ -110,13 +181,18 @@ spec:
110181
- name: otelcol-config
111182
mountPath: /etc/otelcol-contrib
112183
readOnly: true
184+
- name: dice-java-certs
185+
mountPath: /etc/dice-java/certs
186+
readOnly: true
113187
volumes:
114188
- name: otelcol-config
115189
configMap:
116190
name: dice-java-otelcol-config
117191
items:
118192
- key: config.yaml
119193
path: config.yaml
194+
- name: dice-java-certs
195+
emptyDir: {}
120196
---
121197
apiVersion: v1
122198
kind: Service

0 commit comments

Comments
 (0)