@@ -13,37 +13,37 @@ Reason for this:
13
13
14
14
## Usage
15
15
16
+ Copy ` keg ` to ` /usr/local/bin ` .
17
+
16
18
Execute the following to generate both configmap command and environment snippet:
17
19
18
- ` ./ keg.sh configmap-name env-file [env-file ...]`
20
+ ` keg configmap-name env-file [env-file ...] `
19
21
20
22
Keys repeated in subsequent files will overwrite previous key values.
21
23
22
24
### Example
23
25
24
26
``` sh
25
27
$ cat env/core.env
28
+ NAME=Product Name
26
29
DB_DRIVER=com.mysql.jdbc.Driver
27
30
DB_POOL_MAXSIZE=15
28
31
DB_POOL_MINSIZE=10
29
- ```
30
32
31
- ``` sh
32
33
$ cat env/prod.env
33
34
DB_POOL_MAXSIZE=20
34
35
DB_URL=jdbc:mysql://db.example.com/mydb? characterEncoding=UTF-8
35
- ```
36
36
37
- ``` sh
38
- $ ./keg.sh my-config env/core.env env/prod.env
39
- ```
37
+ $ keg my-config env/core.env env/prod.env
40
38
41
- ``` sh
42
- kubectl create configmap my-config --from-literal=db-driver=com.mysql.jdbc.Driver --from-literal=db-pool-minsize=10 --from-literal=db-pool-maxsize=20 --from-literal=db-url=jdbc:mysql://db.example.com/mydb? characterEncoding=UTF-8
43
- ```
39
+ kubectl create configmap my-config --from-literal=name=" Product Name" --from-literal=db-driver=" com.mysql.jdbc.Driver" --from-literal=db-pool-minsize=" 10" --from-literal=db-pool-maxsize=" 20" --from-literal=db-url=" jdbc:mysql://db.example.com/mydb?characterEncoding=UTF-8"
44
40
45
- ``` yaml
46
41
env:
42
+ - name: NAME
43
+ valueFrom:
44
+ configMapKeyRef:
45
+ name: my-config
46
+ key: name
47
47
- name: DB_DRIVER
48
48
valueFrom:
49
49
configMapKeyRef:
@@ -69,7 +69,7 @@ kubectl create configmap my-config --from-literal=db-driver=com.mysql.jdbc.Drive
69
69
#### Create configmap:
70
70
71
71
``` sh
72
- $ kubectl create configmap my-config --from-literal=db-driver=com.mysql.jdbc.Driver --from-literal=db-pool-minsize=10 --from-literal=db-pool-maxsize=20 --from-literal=db-url=jdbc:mysql://db.example.com/mydb?characterEncoding=UTF-8
72
+ $ kubectl create configmap my-config --from-literal=name= " Product Name " --from-literal= db-driver=" com.mysql.jdbc.Driver" --from-literal=db-pool-minsize=" 10 " --from-literal=db-pool-maxsize=" 20 " --from-literal=db-url=" jdbc:mysql://db.example.com/mydb?characterEncoding=UTF-8"
73
73
```
74
74
75
75
#### Verify configmap:
@@ -85,14 +85,15 @@ data:
85
85
db-pool-maxsize : " 20"
86
86
db-pool-minsize : " 10"
87
87
db-url : jdbc:mysql://db.example.com/mydb?characterEncoding=UTF-8
88
+ name : Product Name
88
89
kind : ConfigMap
89
90
metadata :
90
- creationTimestamp : 2016-11-19T23:23:30Z
91
+ creationTimestamp : 2016-11-20T01:59:33Z
91
92
name : my-config
92
93
namespace : my-app
93
- resourceVersion : " 9098351 "
94
- selfLink : /api/v1/namespaces/my-app/configmaps/my-conf
95
- uid : 4bea0444-adeb -11e6-8c60-065eece225bf
94
+ resourceVersion : " 9281367 "
95
+ selfLink : /api/v1/namespaces/my-app/configmaps/my-config
96
+ uid : fb9eedcb-aec4 -11e6-8c60-065eece225bf
96
97
` ` `
97
98
98
99
#### Paste snippet into deployment yaml
@@ -116,6 +117,11 @@ spec:
116
117
image : quay.io/example/my-app:LATEST
117
118
imagePullPolicy : Always
118
119
env :
120
+ - name : NAME
121
+ valueFrom :
122
+ configMapKeyRef :
123
+ name : my-config
124
+ key : name
119
125
- name : DB_DRIVER
120
126
valueFrom :
121
127
configMapKeyRef :
0 commit comments