0
0
Microservicessystem_design~10 mins

ConfigMaps and Secrets in Microservices - Interactive Code Practice

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

Complete the code to create a ConfigMap in Kubernetes.

Microservices
kubectl create configmap [1] --from-literal=app_mode=production
Drag options to blanks, or click blank then click option'
Amy-config
Bsecret-config
Capp-secret
Dconfig-secret
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name that suggests a Secret instead of a ConfigMap.
Confusing ConfigMap creation with Secret creation commands.
2fill in blank
medium

Complete the code to create a Secret with a password in Kubernetes.

Microservices
kubectl create secret generic [1] --from-literal=password=Pa$$w0rd
Drag options to blanks, or click blank then click option'
Aapp-config
Bconfigmap
Cdb-secret
Dapp-configmap
Attempts:
3 left
💡 Hint
Common Mistakes
Using ConfigMap names when creating Secrets.
Not using the correct command for Secrets.
3fill in blank
hard

Fix the error in the command to mount a Secret as a volume in a Pod spec.

Microservices
volumes:
  - name: secret-volume
    secret:
      secretName: [1]
Drag options to blanks, or click blank then click option'
Amy-config
Bapp-configmap
Cconfigmap-secret
Ddb-secret
Attempts:
3 left
💡 Hint
Common Mistakes
Using ConfigMap names in the secretName field.
Misspelling the Secret name.
4fill in blank
hard

Fill both blanks to define environment variables from a ConfigMap and a Secret in a Pod spec.

Microservices
env:
  - name: APP_MODE
    valueFrom:
      configMapKeyRef:
        name: [1]
        key: app_mode
  - name: DB_PASSWORD
    valueFrom:
      secretKeyRef:
        name: [2]
        key: password
Drag options to blanks, or click blank then click option'
Amy-config
Bapp-config
Cdb-secret
Dapp-secret
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up ConfigMap and Secret names.
Using incorrect keys for the environment variables.
5fill in blank
hard

Fill all three blanks to create a Pod spec snippet that mounts a ConfigMap and a Secret as volumes and uses environment variables from both.

Microservices
volumes:
  - name: config-volume
    configMap:
      name: [1]
  - name: secret-volume
    secret:
      secretName: [2]
containers:
  - name: app-container
    image: myapp:latest
    volumeMounts:
      - name: config-volume
        mountPath: /etc/config
      - name: secret-volume
        mountPath: /etc/secret
    env:
      - name: APP_MODE
        valueFrom:
          configMapKeyRef:
            name: [3]
            key: app_mode
Drag options to blanks, or click blank then click option'
Amy-config
Bdb-secret
Capp-config
Dapp-secret
Attempts:
3 left
💡 Hint
Common Mistakes
Using Secret names where ConfigMap names are needed.
Mismatching volume names and mount paths.