Day 35: Mastering ConfigMaps and Secrets in Kubernetes🔒🔑🛡️
Task 1:
Create a ConfigMap for your Deployment
Create a ConfigMap for your Deployment using a file or the command line
Update the deployment.yml file to include the ConfigMap
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.
solution:
create a configuration file using
vim sample.conf
my map - object name
(you can write any name according to you)
kubectl create configmap mymap --from-file=sample.conf
kubectl get configmap
kubectl describe configmap mymap
vim deployconfig.yaml
kubectl apply -f deployconfig.yaml
kubectl get pods
kubectl exec myvolconfig -it -- /bin/bash
cd tmp
ls
cd config/
exit
Task 2:
Create a Secret for your Deployment
Create a Secret for your Deployment using a file or the command line
Update the deployment.yml file to include the Secret
Apply the updated deployment using the command:
kubectl apply -f deployment.yml -n <namespace-name>
Verify that the Secret has been created by checking the status of the Secrets in your Namespace.
Solution:
create a two-file username.txt & password.txt
echo "root" > username.txt; echo "password" > password.txt
ls
kubectl create secret generic mysecret --from-file=username.txt --from-file=password.txt
kubectl get secret
kubectl describe secret mysecret
vi deploysecret.yaml
kubectl apply -f deploysecret.yaml
kubectl get pods
kubectl exec myvolsecret -it -- /bin/bash
cd /tmp
ls
cat password.txt
cat username.txt
Thank you for reading this blog. Hope it helps.
— Safia Khatoon
Happy Learning :)