-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpod-secret.yaml
72 lines (72 loc) · 1.81 KB
/
pod-secret.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Create Namespace
apiVersion: v1
kind: Namespace
metadata:
name: pod-secret-namespace
---
# Create Source API Secret
apiVersion: v1
kind: Secret
metadata:
name: source-api-secret
namespace: pod-secret-namespace
type: Opaque
data:
API_KEY: bWVnYV9zZWNyZXRfa2V5Cg==
API_SECRET: cmVhbGx5X3NlY3JldF92YWx1ZTEK
immutable: false
---
# Create DB Login Secret
apiVersion: v1
kind: Secret
metadata:
name: db-login-secret
namespace: pod-secret-namespace
type: Opaque
data:
USERNAME: bWVnYV9zZWXXXXDfa2V5Cg==
PASSWORD: cmVhbGx5X3NlY3JldF92YWx1ZTEK
immutable: false
---
# Create Tick App Pod
apiVersion: v1
kind: Pod
metadata:
name: tick-app-pod
namespace: pod-secret-namespace
labels:
name: my-tick-app
spec:
containers:
- name: app
image: alpine
command: ["sleep", "3600"]
# Mount DB login secret as env or envFrom
# Use "env" when you want to mount few keys only as env from secret
env:
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: db-login-secret # Secret name
key: USERNAME # key name from secret to fetch value from
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: db-login-secret
key: PASSWORD
# Use "envFrom" when you want to mount whole secret as Env
envFrom:
- secretRef:
name: db-login-secret
# Mount source api secret as volume
volumeMounts:
- name: tick-data-app-volume
mountPath: "/secret"
readOnly: true
restartPolicy: Never
volumes:
# You create volumes at the Pod level then mount them into containers inside that Pod
- name: tick-data-app-volume
secret:
# Provide the name of the Secret you want to mount
secretName: source-api-secret