forked from Sonal0409/DevOps_ClassNotes
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigMapsNotes
More file actions
84 lines (66 loc) · 1.51 KB
/
Copy pathconfigMapsNotes
File metadata and controls
84 lines (66 loc) · 1.51 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# kubectl get configmap
# kubectl create configmap dev-config --from-literal=app.mem=2048m
# kubectl get configmap
# kubectl get configmap dev-config -o yaml
# vim dev.properties
app.env:dev
app.mem=2048m
app.properties=dev.env.url
:wq!
we use configMap command(yml file) to store environment varibale and configuation file in k8.
# kubectl create configmap dev-config1 --from-file=dev.properties
# kubectl get configmap
# kubectl get configmap dev-config1 -o yaml
Use configmap for a pod
vim pod-configmap.yml
kind: Pod
apiVersion: v1
metadata:
name: pod-configmap
spec:
containers:
- image: nginx
name: c1
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: dev-config1
restartPolicy: Never
:wq!
replicaset
---
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myrsconfig
spec:
replicas: 3
selector:
matchLabels:
type: webserver
template:
metadata:
name: mypodconfig
labels:
type: webserver
spec:
containers:
- image: nginx
name: c1
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
configMap:
name: config1
# kubectl apply -f pod-configmap.yml
# kubectl exec -it pod-configmap bash
# cd /etc/config
you will find the dev.properties file and configurations
to edit the config map always use this command.
>> kubectl edit configmap config1 -o yaml