DevOps(Day-35) : Mastering ConfigMaps and Secrets in Kubernetes

DevOps(Day-35) : Mastering ConfigMaps and Secrets in Kubernetes

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

  1. Create a configmap.yml file to include all the configurations required.

  2. Run the file using kubectl command.

  3. Change the deployment.yml file to include the configMap properties in the deployment.

  4. Run the deployment file and check for the deployment and config map are running.

  5. Use the describe command for a detailed view of the config map.

  6. Navigate inside the Pod and check the environment variable and the application for detailed status.

    Task-2 : Secrets in K8s

    1. Create a secret.yml file which includes the base64 encoded password.

    2. To add the password in the above file you need to generate the base64 encoded password.

    3. Now you can save and run the secret.yml file.

    4. Now, change the deployment.yml file to include the configuration of the secret in the deployment.

    5. Now run the deployment file and check the status of the deployment and the secret.

    6. Check the detailed view of secretly created in K8s using describe command.

    7. 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