Dear Engineers, in today's article, we will learn ConfigMaps and Secrets in Kuberentes with the help of Definitions and Tasks.
What are ConfigMaps and Secrets in K8s?
In Kubernetes, ConfigMaps and secrets are used to store configuration data and secrets,respectively. ConfigMaps store configuration data as key-value pairs,while Secrets store sensitive data in encrypted form.
Let' discuss with the help of task
Today's Task:
Task 1:
Create a directory with the help of mkdir
create configmap.yaml file.
Enter all the code and save with the help of CTRL+s command.
Tfile check with the help of cat commands Diagram.
you can create the ConfigMap by running the following command:
Syntax:- kubectl apply -f configmap.yaml
Now update the deployment.yaml file to include the ConfigMap
cat deployment.yaml file Diagram.
here, the pod definition includes an environment variable application whose value is taken from the ConfigMap. The valueFrom field specifies the source of the value, which is the ConfigMap my-config-map and the key application.
Apply the updated deployment using the command: kubectl apply -f deployment.yml -n <namespace-name>
Verify that the ConfigMap has been created by checking the status of the ConFigMaps in your Namespace.
To verify that the ConfigMap has been created,you can use the following commands.
This command will display a list of all ConfigMaps in your namespace, along with their status information.
Syntax: kubectl get configmaps -n <namespace-name>
You can also use the following command to view the details of a specific ConfigMap:
This command will display information bout the Configmap,including its metadata,data and status.
Syntax:- kubectl describe configmap <configmap-name> -n <namespace-name>
Syntax:- kubectl describe configmap <configmap-name> -n <namespace-name> Diagram.
Hope I helped you in understanding the concept in a better way.