January 2019
Intermediate to advanced
484 pages
11h 48m
English
Alternatively, we could use environment variables to retrieve secrets, which is more flexible for short credentials, such as a password. Applications are able to use environment variables to retrieve database passwords without tackling files and volumes:
// example to use environment variable to retrieve the secret# cat 3-2-3_pod_ev_secret.yamlapiVersion: v1kind: Podmetadata: name: secret-access-evspec: containers: - name: centos image: centos command: ["/bin/sh", "-c", "while : ;do echo $MY_PASSWORD; sleep 10; done"] env: - name: MY_PASSWORD valueFrom: secretKeyRef: name: mypassword key: mypassword // create the pod # kubectl create -f 3-2-3_pod_ev_secret.yamlpod "secret-access-ev" created
Read now
Unlock full access