0
0
Kubernetesdevops~10 mins

Using Secrets as environment variables in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define an environment variable from a secret in a Pod spec.

Kubernetes
env:
  - name: PASSWORD
    valueFrom:
      secretKeyRef:
        name: mysecret
        key: [1]
Drag options to blanks, or click blank then click option'
Apassword
Btoken
Cusername
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong key name that does not exist in the secret.
Confusing the secret name with the key name.
2fill in blank
medium

Complete the code to mount a secret as an environment variable in a container spec.

Kubernetes
containers:
- name: app
  image: myapp:latest
  env:
  - name: API_KEY
    valueFrom:
      secretKeyRef:
        name: [1]
        key: api_key
Drag options to blanks, or click blank then click option'
Amysecret
Bappsecret
Cconfigmap
Ddefaultsecret
Attempts:
3 left
💡 Hint
Common Mistakes
Using a ConfigMap name instead of a Secret name.
Using a secret name that does not exist in the cluster.
3fill in blank
hard

Fix the error in the environment variable definition from a secret.

Kubernetes
env:
  - name: DB_PASSWORD
    valueFrom:
      secretKeyRef:
        name: dbsecret
        key: [1]
Drag options to blanks, or click blank then click option'
Adb_password
Bdbpassword
Cpassword
Ddbpass
Attempts:
3 left
💡 Hint
Common Mistakes
Using a key name that does not match the secret's data keys.
Assuming the key name is the same as the environment variable name.
4fill in blank
hard

Fill both blanks to correctly define environment variables from two different secrets.

Kubernetes
env:
  - name: USERNAME
    valueFrom:
      secretKeyRef:
        name: [1]
        key: username
  - name: TOKEN
    valueFrom:
      secretKeyRef:
        name: [2]
        key: token
Drag options to blanks, or click blank then click option'
Ausersecret
Btokensecret
Cmysecret
Ddefaultsecret
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same secret name for both environment variables.
Mixing up secret names and keys.
5fill in blank
hard

Fill all three blanks to create environment variables from a secret with keys 'username', 'password', and 'token'.

Kubernetes
env:
  - name: USER
    valueFrom:
      secretKeyRef:
        name: [1]
        key: [2]
  - name: PASS
    valueFrom:
      secretKeyRef:
        name: [1]
        key: password
  - name: TOKEN
    valueFrom:
      secretKeyRef:
        name: [1]
        key: token
Drag options to blanks, or click blank then click option'
Aappsecret
Busername
Cmysecret
Dusersecret
Attempts:
3 left
💡 Hint
Common Mistakes
Using different secret names for each environment variable.
Confusing the key names with environment variable names.