Complete the code to define an environment variable from a secret in a Pod spec.
env:
- name: PASSWORD
valueFrom:
secretKeyRef:
name: mysecret
key: [1]The key field specifies which key from the secret to use as the environment variable value. Here, password is the correct key.
Complete the code to mount a secret as an environment variable in a container spec.
containers:
- name: app
image: myapp:latest
env:
- name: API_KEY
valueFrom:
secretKeyRef:
name: [1]
key: api_keyThe name field under secretKeyRef must match the secret resource name. Here, mysecret is the correct secret name.
Fix the error in the environment variable definition from a secret.
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: dbsecret
key: [1]The key password is the standard key used in the secret for the database password. Other keys may cause the environment variable to be empty.
Fill both blanks to correctly define environment variables from two different secrets.
env:
- name: USERNAME
valueFrom:
secretKeyRef:
name: [1]
key: username
- name: TOKEN
valueFrom:
secretKeyRef:
name: [2]
key: tokenThe first secret name is usersecret for the username, and the second is tokensecret for the token.
Fill all three blanks to create environment variables from a secret with keys 'username', 'password', and 'token'.
env:
- name: USER
valueFrom:
secretKeyRef:
name: [1]
key: [2]
- name: PASS
valueFrom:
secretKeyRef:
name: [1]
key: password
- name: TOKEN
valueFrom:
secretKeyRef:
name: [1]
key: tokenThe secret name is mysecret. The key for the USER environment variable is username. The other keys are password and token.