kubectl config use-context cluster1-admin@cluster1
k create ns dev-db
k create secret -n dev-db generic dbpassword --from-literal pwd=my-secret-pwd
k run db-pod --namespace dev-db --labels type=db --image mysql:8.0 --dry-run=client -o yaml >3.yaml
Edit definition file and add env variable to have
# vim 3.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
type: db
name: db-pod
namespace: dev-db
spec:
containers:
- image: mysql:8.0
name: db-pod
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: dbpassword
key: pwd
Apply the changes:
k apply -f 3.yaml