Config Map Using Yaml

Creating config map using yaml file

1- From literal

kubectl create cm cm1 --from-literal=database_ip="x.x.x.x" --from-literal=user="user1" --from-literal=paaword="xxxxx" --dry-run=client -o yaml > yaml1.yaml
kubectl apply yaml1.yaml

2- From Single file

kubectl create cm cm3 --dry-run=client -o yaml > yaml2.yaml
kubectl apply yaml2.yaml

3- Using multiple file

kubectl create cm cm5 --from-file=foldername/ --dry-run=client -o yaml > yaml3.yaml
kubectl apply yaml3.yaml

4- Using env file

kubectl create cm cm6 --dry-run=client -o yaml > yaml4.yaml
kubectl apply yaml4.yaml

Note- in the above examples we will get YAML file definition using these commands which later can be used for updating the configuration