![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/DevSecOps_Projects-18.png?resize=1024%2C1024&ssl=1)
We can create config map in two ways
- Imperative way
- Declarative way
vim my-cm1.txt
port=3000
token=hello
You Can set alies as k=kubectl
In imperative way creating the config map
# kubectl create cm my-cm1 –from-file=my-cm1.txt –from-literal=first_name=srinath –from_literal==last_name=kaithoju
To see the all configmaps
# kubectl get cm
To see the contents inside the configmaps
# kubectl describe cm my-cm1
Second option is to create the config map is by using the manifest file
# vi my-cm2.yaml
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/image-1.png?resize=253%2C345&ssl=1)
kubectl apply -f app1.yaml
kubectl get pod
kubectl exec -it app1 bash
env
Here we can see the FIRST_NAME AND LAST_NAME
# vi app2.yaml
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/image-2.png?resize=258%2C345&ssl=1)
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/Configmaps-kubelet-diagram-1.png?resize=1024%2C616&ssl=1)
# kubectl apply -f app2.yaml
# kubectl get pods
# kubectl exec -it app2 bash
In the first and second we passed the environment variable directly
In the third passing the variables as a file system
# vi app3.yaml
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/image-3.png?resize=274%2C502&ssl=1)
Now, Create the pod
# kubectl apply -f app3.yaml
# kubectl kubectl get pod
# kubectl exec -it app3 bash
# cd /etc
# ls
# cd config_details
# ls
# cat first_name
# cat last_name
# cat my_cm1.txt
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/20210816_184521_0000-6-edited.png?resize=500%2C281&ssl=1)
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/join_myfuturehub.com_-4.png?resize=591%2C591&ssl=1)