configmaps in Kubernetes Pods

We can create config map in two ways

  1. Imperative way
  2. 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

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

# 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

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

Leave a Comment

MFH IT Solutions (Regd No -LIN : AP-03-46-003-03147775)

Consultation & project support organization.

Contact

MFH IT Solutions (Regd)
NAD Kotha Road, Opp Bashyam School, Butchurajupalem, Jaya Prakash Nagar Visakhapatnam, Andhra Pradesh – 530027