TABLE OF CONTENTS
ConfigMaps
The ConfigMap API resource holds key-value pairs of configuration data that can be consumed in pods or used to store configuration data for system components such as controllers.
ConfigMaps are intended for non-sensitive data—configuration data—like config files and environment variables and are a great way to create customized running services from generic container images.
Secrets
Secrets are Kubernetes objects intended for storing a small amount of sensitive data. It is worth noting that Secrets are stored base64-encoded within Kubernetes, so they are not wildly secure.
To create the Secret, choose a password and convert it to base64 as shown in below example:
Task-1: Create ConfigMap for your Deployment
Create a configmap.yml file to include all the configurations required.
Run the file using kubectl command.
Change the deployment.yml file to include the configMap properties in the deployment.
Run the deployment file and check for the deployment and config map are running.
Use the describe command for a detailed view of the config map.
Navigate inside the Pod and check the environment variable and the application for detailed status.
Task-2 : Secrets in K8s
Create a secret.yml file which includes the base64 encoded password.
To add the password in the above file you need to generate the base64 encoded password.
Now you can save and run the secret.yml file.
Now, change the deployment.yml file to include the configuration of the secret in the deployment.
Now run the deployment file and check the status of the deployment and the secret.
Check the detailed view of secretly created in K8s using describe command.
Now check the running pods and navigate to a POD to view the environment variable.
Thanks for reading my article. Have a nice day
WRITTEN BY Biswaraj Sahoo --AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | Kubernetes
Empowering communities via open source and education. Connect with me over linktree: linktr.ee/biswaraj333