Skip to content

Commit 10dff0b

Browse files
authored
Merge pull request #47226 from windsonsea/configy
[zh] Add updating-configuration-via-a-configmap.md
2 parents 09a40c5 + d2de6bf commit 10dff0b

8 files changed

+1385
-0
lines changed

content/zh-cn/docs/tutorials/configuration/updating-configuration-via-a-configmap.md

Lines changed: 1191 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
data:
3+
company_name: "ACME, Inc." # 虚构的公司名称
4+
kind: ConfigMap
5+
immutable: true
6+
metadata:
7+
name: company-name-20150801
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
data:
3+
company_name: "Fiktivesunternehmen GmbH" # 虚构的公司名称
4+
kind: ConfigMap
5+
immutable: true
6+
metadata:
7+
name: company-name-20240312
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: configmap-sidecar-container
5+
labels:
6+
app.kubernetes.io/name: configmap-sidecar-container
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: configmap-sidecar-container
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: configmap-sidecar-container
16+
spec:
17+
volumes:
18+
- name: shared-data
19+
emptyDir: {}
20+
- name: config-volume
21+
configMap:
22+
name: color
23+
containers:
24+
- name: nginx
25+
image: nginx
26+
volumeMounts:
27+
- name: shared-data
28+
mountPath: /usr/share/nginx/html
29+
initContainers:
30+
- name: alpine
31+
image: alpine:3
32+
restartPolicy: Always
33+
volumeMounts:
34+
- name: shared-data
35+
mountPath: /pod-data
36+
- name: config-volume
37+
mountPath: /etc/config
38+
command:
39+
- /bin/sh
40+
- -c
41+
- while true; do echo "$(date) My preferred color is $(cat /etc/config/color)" > /pod-data/index.html;
42+
sleep 10; done;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: configmap-env-var
5+
labels:
6+
app.kubernetes.io/name: configmap-env-var
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: configmap-env-var
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: configmap-env-var
16+
spec:
17+
containers:
18+
- name: alpine
19+
image: alpine:3
20+
env:
21+
- name: FRUITS
22+
valueFrom:
23+
configMapKeyRef:
24+
key: fruits
25+
name: fruits
26+
command:
27+
- /bin/sh
28+
- -c
29+
- while true; do echo "$(date) The basket is full of $FRUITS";
30+
sleep 10; done;
31+
ports:
32+
- containerPort: 80
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: configmap-volume
5+
labels:
6+
app.kubernetes.io/name: configmap-volume
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: configmap-volume
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: configmap-volume
16+
spec:
17+
containers:
18+
- name: alpine
19+
image: alpine:3
20+
command:
21+
- /bin/sh
22+
- -c
23+
- while true; do echo "$(date) My preferred sport is $(cat /etc/config/sport)";
24+
sleep 10; done;
25+
ports:
26+
- containerPort: 80
27+
volumeMounts:
28+
- name: config-volume
29+
mountPath: /etc/config
30+
volumes:
31+
- name: config-volume
32+
configMap:
33+
name: sport
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: configmap-two-containers
5+
labels:
6+
app.kubernetes.io/name: configmap-two-containers
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: configmap-two-containers
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: configmap-two-containers
16+
spec:
17+
volumes:
18+
- name: shared-data
19+
emptyDir: {}
20+
- name: config-volume
21+
configMap:
22+
name: color
23+
containers:
24+
- name: nginx
25+
image: nginx
26+
volumeMounts:
27+
- name: shared-data
28+
mountPath: /usr/share/nginx/html
29+
- name: alpine
30+
image: alpine:3
31+
volumeMounts:
32+
- name: shared-data
33+
mountPath: /pod-data
34+
- name: config-volume
35+
mountPath: /etc/config
36+
command:
37+
- /bin/sh
38+
- -c
39+
- while true; do echo "$(date) My preferred color is $(cat /etc/config/color)" > /pod-data/index.html;
40+
sleep 10; done;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: immutable-configmap-volume
5+
labels:
6+
app.kubernetes.io/name: immutable-configmap-volume
7+
spec:
8+
replicas: 3
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: immutable-configmap-volume
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: immutable-configmap-volume
16+
spec:
17+
containers:
18+
- name: alpine
19+
image: alpine:3
20+
command:
21+
- /bin/sh
22+
- -c
23+
- while true; do echo "$(date) The name of the company is $(cat /etc/config/company_name)";
24+
sleep 10; done;
25+
ports:
26+
- containerPort: 80
27+
volumeMounts:
28+
- name: config-volume
29+
mountPath: /etc/config
30+
volumes:
31+
- name: config-volume
32+
configMap:
33+
name: company-name-20150801

0 commit comments

Comments
 (0)