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 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, labelled folders (key-value pairs). Secrets, on the other hand, are like a safe where you keep 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!
Step 1: Create a ConfigMap
kubectl create configmap my-config --from-literal=key1=value1 --from-literal=key2=value2 -n <namespace-name>
Step 2: Update the Deployment YAML
Step 3: Apply the Updated Deployment
kubectl apply -f deployment.yml -n <namespace-name>
Step 4: Verify the ConfigMap
kubectl get configmap my-config -n <namespace-name>
Step 1: Create a Secret
kubectl create secret generic my-secret --from-literal=secret-key=secret-value -n <namespace-name>
Step 2: Update the Deployment YAML
Step 3: Apply the Updated Deployment
kubectl apply -f deployment.yml -n <namespace-name>
Step 4: Verify the Secret
kubectl get secret my-secret -n <namespace-name>
Thank you so much for reading
Follow me on LinkedIn to see interesting posts like this : )