Merge pull request #47226 from windsonsea/configy
[zh] Add updating-configuration-via-a-configmap.mdpull/47252/head
commit
10dff0b860
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,7 @@
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
company_name: "ACME, Inc." # 虚构的公司名称
|
||||||
|
kind: ConfigMap
|
||||||
|
immutable: true
|
||||||
|
metadata:
|
||||||
|
name: company-name-20150801
|
|
@ -0,0 +1,7 @@
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
company_name: "Fiktivesunternehmen GmbH" # 虚构的公司名称
|
||||||
|
kind: ConfigMap
|
||||||
|
immutable: true
|
||||||
|
metadata:
|
||||||
|
name: company-name-20240312
|
|
@ -0,0 +1,42 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: configmap-sidecar-container
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-sidecar-container
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: configmap-sidecar-container
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-sidecar-container
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: shared-data
|
||||||
|
emptyDir: {}
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: color
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- name: shared-data
|
||||||
|
mountPath: /usr/share/nginx/html
|
||||||
|
initContainers:
|
||||||
|
- name: alpine
|
||||||
|
image: alpine:3
|
||||||
|
restartPolicy: Always
|
||||||
|
volumeMounts:
|
||||||
|
- name: shared-data
|
||||||
|
mountPath: /pod-data
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /etc/config
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true; do echo "$(date) My preferred color is $(cat /etc/config/color)" > /pod-data/index.html;
|
||||||
|
sleep 10; done;
|
|
@ -0,0 +1,32 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: configmap-env-var
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-env-var
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: configmap-env-var
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-env-var
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: alpine
|
||||||
|
image: alpine:3
|
||||||
|
env:
|
||||||
|
- name: FRUITS
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
key: fruits
|
||||||
|
name: fruits
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true; do echo "$(date) The basket is full of $FRUITS";
|
||||||
|
sleep 10; done;
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
|
@ -0,0 +1,33 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: configmap-volume
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-volume
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: configmap-volume
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-volume
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: alpine
|
||||||
|
image: alpine:3
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true; do echo "$(date) My preferred sport is $(cat /etc/config/sport)";
|
||||||
|
sleep 10; done;
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /etc/config
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: sport
|
|
@ -0,0 +1,40 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: configmap-two-containers
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-two-containers
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: configmap-two-containers
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: configmap-two-containers
|
||||||
|
spec:
|
||||||
|
volumes:
|
||||||
|
- name: shared-data
|
||||||
|
emptyDir: {}
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: color
|
||||||
|
containers:
|
||||||
|
- name: nginx
|
||||||
|
image: nginx
|
||||||
|
volumeMounts:
|
||||||
|
- name: shared-data
|
||||||
|
mountPath: /usr/share/nginx/html
|
||||||
|
- name: alpine
|
||||||
|
image: alpine:3
|
||||||
|
volumeMounts:
|
||||||
|
- name: shared-data
|
||||||
|
mountPath: /pod-data
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /etc/config
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true; do echo "$(date) My preferred color is $(cat /etc/config/color)" > /pod-data/index.html;
|
||||||
|
sleep 10; done;
|
|
@ -0,0 +1,33 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: immutable-configmap-volume
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: immutable-configmap-volume
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: immutable-configmap-volume
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: immutable-configmap-volume
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: alpine
|
||||||
|
image: alpine:3
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true; do echo "$(date) The name of the company is $(cat /etc/config/company_name)";
|
||||||
|
sleep 10; done;
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
volumeMounts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /etc/config
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: company-name-20150801
|
Loading…
Reference in New Issue