Solution Secrets
- How to create a
secretimperatively:kubectl create secret generic db-secret --from-literal=DB_Host=sql01 --from-literal=DB_User=root --from-literal=DB_Password=password123 - Example of a pod loading
secretsusingenvFrom: ``` — apiVersion: v1 kind: Pod metadata: labels: name: webapp-pod name: webapp-pod namespace: default spec: containers:- image: kodekloud/simple-webapp-mysql
imagePullPolicy: Always
name: webapp
envFrom:
- secretRef: name: db-secret ```
- image: kodekloud/simple-webapp-mysql
imagePullPolicy: Always
name: webapp
envFrom:
- Then run
kubectl edit pod <pod_name>to get the location of the temporary file where the changes are at. - Then to recreate and delete the pod, run
kubectl replace --force -f /tmp/kubectl-edit-<numbers>.yaml - How many
secretsexist in the default namespace?kubectl get secrets - How many secrets are defined?
- Check under
kubectl describe secrets <secret_name>and look for everything underData
- Check under
- Check the services
kubectl get svc - Create a
secret–>kubectl create secret generic <name_of_secret> --from-literal=DB_Host=sql01 --from-literal DB_User=root --from-litereal DB_Password=password123- Then check with
kubectl get secretandkubectl describe secret <secret>
- Then check with
- To add a
secretto an already running