-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathdeployment-use-secret.yaml
41 lines (41 loc) · 1.14 KB
/
deployment-use-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
apiVersion: apps/v1
kind: Deployment
metadata:
name: hellok8s-go-http
spec:
strategy:
type: Recreate # 因为下面使用hostPort进行测试,所以更新时只能先销毁再创建
replicas: 1
selector:
matchLabels:
app: hellok8s
template:
metadata:
labels:
app: hellok8s
spec:
containers:
- image: leigg/hellok8s:v4_secret
name: hellok8s
ports:
- containerPort: 3000
hostPort: 3000
env:
- name: DB_PASSWD
valueFrom:
secretKeyRef:
name: hellok8s-secret
key: DB_PASSWD
- name: LOG_LEVEL
valueFrom:
secretKeyRef:
name: hellok8s-secret # name必须是有效且存在的
key: not_found_key
optional: true # 允许key不存在,这样在key找不到时不会影响Pod启动
volumeMounts:
- name: secret-volume
mountPath: "/etc/secret_vol"
volumes:
- name: secret-volume
secret:
secretName: hellok8s-secret