This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-vault-kubernetes.yml
107 lines (102 loc) · 2.76 KB
/
example-vault-kubernetes.yml
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: example-vault-kubernetes
name: example-vault-kubernetes
spec:
replicas: 1
selector:
matchLabels:
run: example-vault-kubernetes
template:
metadata:
labels:
run: example-vault-kubernetes
spec:
restartPolicy: Always
volumes:
- name: secrets
secret:
secretName: mycustomsecret
containers:
- name: legacy-app
image: legacy-app:latest
imagePullPolicy: Never
#secrets in env are not getting updated automatically
envFrom:
- secretRef:
name: mycustomsecret
volumeMounts:
- name: secrets
mountPath: /etc/secrets
---
# Envconsul container (watchdog to update Kubernetes secrets)
apiVersion: batch/v1beta1
kind: CronJob
metadata:
labels:
run: envconsul-job
name: envconsul-job
spec:
concurrencyPolicy: Allow
schedule: '* * * * *'
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
run: envconsul-job
spec:
serviceAccountName: vault-auth
restartPolicy: Never
volumes:
- name: vault-token
emptyDir:
medium: Memory
- name: scripts
configMap:
name: scripts
defaultMode: 0744
- name: config
configMap:
name: hcl-config
containers:
- name: envconsul
image: envconsul:latest
imagePullPolicy: Never
volumeMounts:
- name: vault-token
mountPath: /home/vault
- name: config
mountPath: /etc/envconsul
- name: scripts
mountPath: /scripts
env:
- name: HOME
value: /home/vault
- name: VAULT_ADDR
value: https://vault.cloud.org
initContainers:
# Vault container
- name: vault-agent-auth
image: vault
volumeMounts:
- name: config
mountPath: /etc/vault
- name: vault-token
mountPath: /home/vault
# This assumes Vault running on local host and K8s running in Minikube using VirtualBox
env:
- name: VAULT_ADDR
value: https://vault.cloud.org
# Run the Vault agent
args:
[
"agent",
"-config=/etc/vault/vault-agent-config.hcl",
"-log-level=debug",
]