Day 35: Mastering ConfigMaps and Secrets in Kubernetes???????

Day 35: Mastering ConfigMaps and Secrets in Kubernetes???????

Day 35: Mastering ConfigMaps and Secrets in Kubernetes???????

???? Congratulations on conquering Namespaces and Services yesterday! ????????

What are ConfigMaps and Secrets in Kubernetes? In Kubernetes, ConfigMaps and Secrets are used to store configuration data and sensitive information, respectively. ConfigMaps store configuration data as key-value pairs, while Secrets store sensitive data in an encrypted form.

Example: Imagine you're in charge of a big spaceship (Kubernetes cluster) with lots of different parts (containers) that need information to function properly. ConfigMaps are like a file cabinet where you store all the information each part needs in simple, labeled folders (key-value pairs). Secrets, on the other hand, are like a safe where you keep the important, sensitive information that shouldn't be accessible to just anyone (encrypted data). So, using ConfigMaps and Secrets, you can ensure each part of your spaceship (Kubernetes cluster) has the information it needs to work properly and keep sensitive information secure! ??

Today's task:

Task 1: Create a ConfigMap for your Deployment

  1. Create a ConfigMap:

Create a ConfigMap for your Deployment using a file or the command line.

Example ConfigMap YAML file (configmap.yml):

apiVersion: v1
kind: ConfigMap
metadata:
  name: todo-app-configmap
data:
  key1: value1
  key2: value2
        

2. Update the deployment.yml file:

  • Update the deployment.yml file to include the ConfigMap.

Example deployment.yml snippet:

spec:
  containers:
    - name: todo
      image: rishikeshops/todo-app
      envFrom:
        - configMapRef:
            name: todo-app-configmap
        

3. Apply the updated deployment:

  • Apply the updated deployment using the command:

kubectl apply -f deployment.yml -n <namespace-name>
        

4. Verify the ConfigMap:

Verify that the ConfigMap has been created by checking the status of the ConfigMaps in your Namespace.

Task 2: Create a Secret for your Deployment

  1. Create a Secret:

  • Create a Secret for your Deployment using a file or the command line.

Example Secret YAML file (secret.yml):

apiVersion: v1
kind: Secret
metadata:
  name: todo-app-secret
type: Opaque
data:
  username: <base64-encoded-username>
  password: <base64-encoded-password>
        

2. Update the deployment.yml file:

  • Update the deployment.yml file to include the Secret.

Example deployment.yml snippet:

spec:
  containers:
    - name: todo
      image: rishikeshops/todo-app
      envFrom:
        - secretRef:
            name: todo-app-secret
        

3. Apply the updated deployment:

  • Apply the updated deployment using the command:

kubectl apply -f deployment.yml -n <namespace-name>        

4. Verify the Secret:

  • Verify that the Secret has been created by checking the status of the Secrets in your Namespace.

Keep learning and expanding your knowledge of Kubernetes! ????

Utsav Bayaskar

DevOps Engineer at Capgemini

10 个月

Happy Learning! ??????

回复

要查看或添加评论,请登录

Utsav Bayaskar的更多文章

社区洞察

其他会员也浏览了