-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo-app-inject-postgres.yaml
54 lines (54 loc) · 1.48 KB
/
demo-app-inject-postgres.yaml
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
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: demo-app-sa
---
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: demo-app-inject-postgres
name: demo-app-inject-postgres
spec:
replicas: 1
selector:
matchLabels:
app: demo-app-inject-postgres
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: demo-app-inject-postgres
annotations:
# https://developer.hashicorp.com/vault/docs/platform/k8s/injector
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "test"
vault.hashicorp.com/agent-inject-secret-db: postgres/creds/testdb-ro
vault.hashicorp.com/agent-inject-template-db: |
{{- with secret "postgres/creds/testdb-ro" }}
for _ in $(seq 1 50); do echo; done
date
set -x
echo "select * from testdb;"|psql postgresql://{{ .Data.username}}:{{ .Data.password }}@postgres:5432/postgres
{{ end }}
spec:
containers:
- image: postgres
imagePullPolicy: IfNotPresent
name: app
resources: {}
command:
- sh
- -c
- |
echo "waiting for script to become available"
while true
do
test -e /vault/secrets/db && chmod +x /vault/secrets/db && /vault/secrets/db
sleep 1
done
serviceAccountName: demo-app-sa
status: {}