Configmaps

Scenario 1

Step 1: Configure configmapas environment variable

kubectl apply -f configmapAsEnv.yaml

Step 2: View the configmap

kubectl get configmap
kubectl describe configmap

Step 3: Perform a Deployment

kubectl apply -f deployConfigAsEnv.yaml

Step 4: View the Deployments

kubectl get deployments

Step 5: Verify the Environment Variable

Don't Forget to replace the pod actual name in the below command

kubectl exec <<POD-NAME>> -c nginx -- env

Scenario 2

Step 1: Configure configmapas file

kubectl apply -f configmapAsFile.yaml

Step 2: View the configmap

kubectl get configmap
kubectl describe configmap

Step 3: Deployment

kubectl apply -f deployConfigAsFile.yaml

Step 4: View the Deployments

kubectl get deployments
kubectl get pods

Step 5: Verify the Variables

Don't Forget to replace the pod actual name in the below command

kubectl exec <<POD-NAME>> -c nginx -- cat /usr/config/config.yaml

Clear Everything in the current namespace

kubectl delete all --all -n default
kubectl delete --all configmaps --namespace=default

Last updated

Was this helpful?