File tree Expand file tree Collapse file tree 10 files changed +223
-0
lines changed Expand file tree Collapse file tree 10 files changed +223
-0
lines changed Original file line number Diff line number Diff line change
1
+ .idea /
Original file line number Diff line number Diff line change
1
+ # Pod using this configmap: pod-cmd.yaml in same directory
2
+
3
+ apiVersion : v1
4
+ kind : ConfigMap
5
+ metadata :
6
+ name : log-config
7
+ namespace : default
8
+ data :
9
+ log.level : WARNING
10
+ log.location : LOCAL
Original file line number Diff line number Diff line change
1
+ # Deploy the ConfigMap
2
+ kubectl create -f configmap.yaml
3
+
4
+ # Create the Pod with Env Var
5
+ kubectl create -f pod-cmd.yaml
6
+
7
+ # Check the logs
8
+ kubectl logs test-pod-cmd
9
+
10
+ # Create the pod with Env Var
11
+ kubectl create -f pod-env.yaml
12
+
13
+ # Check the env vars
14
+ kubectl exec -it test-pod-env /bin/sh
15
+
16
+ # Create the pod with Env Var
17
+ kubectl create -f pod-vol.yaml
18
+
19
+ # Check the logs
20
+ kubectl logs test-pod-vol
21
+
22
+ # Access the shell
23
+ kubectl exec -it test-pod-vol /bin/sh
24
+
25
+ # Check the files
26
+ cd /etc/config
27
+ cat log.level
28
+ cat log.location
Original file line number Diff line number Diff line change
1
+ # Config Map used: configmap.yaml in same directory
2
+
3
+ apiVersion : v1
4
+ kind : Pod
5
+ metadata :
6
+ name : test-pod-cmd
7
+ spec :
8
+ containers :
9
+ - name : test-container
10
+ image : gcr.io/google_containers/busybox
11
+ command : ["/bin/sh", "-c", "echo Error Level: $(LOG_LEVEL) - Error Location: $(LOG_LOCATION)"]
12
+ env :
13
+ - name : LOG_LEVEL
14
+ valueFrom :
15
+ configMapKeyRef :
16
+ name : log-config
17
+ key : log.level
18
+ - name : LOG_LOCATION
19
+ valueFrom :
20
+ configMapKeyRef :
21
+ name : log-config
22
+ key : log.location
23
+ restartPolicy : Never
Original file line number Diff line number Diff line change
1
+ # Config Map used: configmap.yaml in same directory
2
+
3
+ apiVersion : v1
4
+ kind : Pod
5
+ metadata :
6
+ name : test-pod-env
7
+ spec :
8
+ containers :
9
+ - name : test-container
10
+ image : gcr.io/google_containers/busybox
11
+ command : ["/bin/sh", "-c", "--"]
12
+ args : ["while true; do sleep 30; done;"]
13
+ env :
14
+ - name : LOG_LEVEL
15
+ valueFrom :
16
+ configMapKeyRef :
17
+ name : log-config
18
+ key : log.level
19
+ - name : LOG_LOCATION
20
+ valueFrom :
21
+ configMapKeyRef :
22
+ name : log-config
23
+ key : log.location
24
+ restartPolicy : Never
Original file line number Diff line number Diff line change
1
+ # Config Map used: configmap.yaml in same directory
2
+
3
+ apiVersion : v1
4
+ kind : Pod
5
+ metadata :
6
+ name : test-pod-vol
7
+ spec :
8
+ containers :
9
+ - name : test-container
10
+ image : gcr.io/google_containers/busybox
11
+ command : ["/bin/sh", "-c", "--"]
12
+ args : ["while true; do sleep 30; done;"]
13
+ volumeMounts :
14
+ - name : config-volume
15
+ mountPath : /etc/config
16
+ volumes :
17
+ - name : config-volume
18
+ configMap :
19
+ name : log-config
20
+ restartPolicy : Never
Original file line number Diff line number Diff line change
1
+ # Create the ConfigMap from the configuration file
2
+ kubectl create configmap example-redis-config --from-file=redis-config
3
+
4
+ # Show the ConfigMap in YAML format
5
+ kubectl get configmap example-redis-config -o yaml
6
+
7
+ # Create the Redis pod
8
+ kubectl create -f redis.yaml
9
+
10
+ # Check the pod; wait for the pod to be created
11
+ kubectl get pods
12
+
13
+ # Check the configuration
14
+ kubectl exec -it redis redis-cli
15
+
16
+ # Execute the following commands in Redis shell at 127.0.0.1:6379
17
+ CONFIG GET maxmemory
18
+ CONFIG GET maxmemory-policy
19
+
20
+ # Clean up
21
+ kubectl delete configmap example-redis-config
22
+ kubectl delete pod redis
Original file line number Diff line number Diff line change
1
+ maxmemory 5mb
2
+ maxmemory-policy allkeys-lru
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : Pod
3
+ metadata :
4
+ name : redis
5
+ spec :
6
+ containers :
7
+ - name : redis
8
+ image : kubernetes/redis:v1
9
+ env :
10
+ - name : MASTER
11
+ value : " true"
12
+ ports :
13
+ - containerPort : 6379
14
+ resources :
15
+ limits :
16
+ cpu : " 0.1"
17
+ volumeMounts :
18
+ - mountPath : /redis-master-data
19
+ name : data
20
+ - mountPath : /redis-master
21
+ name : config
22
+ volumes :
23
+ - name : data
24
+ emptyDir : {}
25
+ - name : config
26
+ configMap :
27
+ name : example-redis-config
28
+ items :
29
+ - key : redis-config-kabacanamg
30
+ path : redis.conf
Original file line number Diff line number Diff line change
1
+ kind : ConfigMap
2
+ apiVersion : v1
3
+ metadata :
4
+ creationTimestamp : 2017-12-04T13:55:41+00:00
5
+ name : example-config
6
+ namespace : default
7
+ # Data Section that contains multiple key-value pairs
8
+ data :
9
+ example.property.1 : hello
10
+ example.property.2 : world
11
+ example.property.file : |-
12
+ property.1=value-1
13
+ property.2=value-2
14
+ property.3=value-3
15
+
16
+
17
+
18
+ # We can also create a configMap from an existing file that already contains configuration
19
+
20
+ # Example configMap:
21
+ apiVersion : v1
22
+ kind : ConfigMap
23
+ metadata :
24
+ name : special-config
25
+ namespace : default
26
+ data :
27
+ special.how : very
28
+ special.type : charm
29
+
30
+ # Example pod using the "special-config" ConfigMap
31
+ apiVersion : v1
32
+ kind : Pod
33
+ metadata :
34
+ name : dapi-test-pod
35
+ spec :
36
+ containers :
37
+ - name : test-container
38
+ image : gcr.io/xyz
39
+ command : ["/bin/sh", "-c", "env"]
40
+ env :
41
+ - name : SPECIAL_LEVEL_KEY
42
+ valueFrom :
43
+ configMapKeyRef :
44
+ name : special-config
45
+ key : special.how
46
+ - name : SPECIAL_TYPE_KEY
47
+ valueFrom :
48
+ configMapKeyRef :
49
+ name : special-config
50
+ key : special.type
51
+ restartPolicy : Never
52
+
53
+
54
+ # Configuration data can be consumed in pods in a variety of ways
55
+ #
56
+ # ConfigMap can be used to:
57
+ # 1. Populate the value of environment variable
58
+ # 2. Set command-line arguments in a container
59
+ # 3. Populate the configuration files in a volume
60
+ #
61
+ # Users and system components may store configuration data in a ConfigMap
62
+
63
+
You can’t perform that action at this time.
0 commit comments