Skip to main content

Quiz Module 5 - Configuration and Secrets

Instructions

This quiz contains 30 multiple-choice questions.


Question 1

What is a ConfigMap?

Show explanation

Correct answer: A Kubernetes object that stores non-sensitive configuration data

Explanation: ConfigMaps allow you to separate configuration from application code.


Question 2

What is a Secret in Kubernetes?

Show explanation

Correct answer: A Kubernetes object that stores sensitive data such as passwords, tokens, or keys

Explanation: Secrets are similar to ConfigMaps but are designed to store sensitive data. They are stored in base64 (not encrypted by default).


Question 3

How do you create a ConfigMap from a file?

Show explanation

Correct answer: kubectl create configmap [name] --from-file=[file]

Explanation: The --from-file flag allows you to create a ConfigMap from a file, where the key is the filename and the value is the file content.


Question 4

What is the maximum size of an entry in a ConfigMap?

Show explanation

Correct answer: 1 MiB

Explanation: Each entry in a ConfigMap or Secret is limited to 1 MiB. For larger data, use volumes.


Question 5

How do you inject a ConfigMap as environment variables in a Pod?

Show explanation

Correct answer: envFrom: - configMapRef: name: [configmap-name]

Explanation: envFrom allows you to inject all keys from a ConfigMap as environment variables. For a specific key, use env with valueFrom.configMapKeyRef.


Question 6

How do you mount a ConfigMap as a volume in a Pod?

Show explanation

Correct answer: volumes: - name: config configMap: name: [configmap-name]

Explanation: To mount a ConfigMap as a volume, define it in the Pod's volumes section, then use volumeMounts to mount it in the container.


Question 7

What is the main difference between a ConfigMap and a Secret?

Show explanation

Correct answer: Secrets are designed for sensitive data and stored in base64, ConfigMaps are for non-sensitive data

Explanation: Secrets are intended for sensitive data but are not encrypted by default (just base64-encoded). ConfigMaps are for non-sensitive data.


Question 8

How do you create a Secret from literals?

Show explanation

Correct answer: kubectl create secret generic [name] --from-literal=[key]=[value]

Explanation: --from-literal allows you to create a Secret directly from key-value pairs on the command line.


Question 9

What is the best practice for managing secrets in production?

Show explanation

Correct answer: Use external secret management tools (Vault, AWS Secrets Manager) with External Secrets Operator

Explanation: Secrets should never be committed to Git. Use external tools like Vault or cloud services with External Secrets Operator for secure management.


Question 10

What is encryption at rest for Secrets?

Show explanation

Correct answer: A feature that encrypts Secrets in etcd using an EncryptionConfig

Explanation: Encryption at rest encrypts Secrets in etcd by configuring an EncryptionConfig with encryption providers (AES, KMS, etc.).


Question 11

Which command allows you to see the decoded content of a Secret?

Show explanation

Correct answer: kubectl get secret [name] -o jsonpath='{.data.[key]}' | base64 -d

Explanation: Secrets are stored in base64. To see the decoded content, use jsonpath to extract the value and base64 -d to decode it.


Question 12

What is External Secrets Operator?

Show explanation

Correct answer: A Kubernetes operator that syncs secrets from external systems (AWS Secrets Manager, Vault, etc.) to Kubernetes

Explanation: External Secrets Operator enables centralized secret management in external systems and automatically syncs them to Kubernetes.


Question 13

What is the recommended method for injecting a Secret into a Pod?

Show explanation

Correct answer: Use envFrom with secretRef or env with valueFrom.secretKeyRef

Explanation: Secrets should be injected via envFrom (all keys) or env with valueFrom.secretKeyRef (a specific key), never hardcoded.


Question 14

What is the difference between env and envFrom?

Show explanation

Correct answer: env allows injecting individual variables, envFrom injects all keys from a ConfigMap/Secret

Explanation: env provides precise control over each variable, while envFrom automatically injects all keys as environment variables.


Question 15

What is the best practice for permissions on a Secret volume?

Show explanation

Correct answer: 0400 (read-only for the owner)

Explanation: Secret volumes should be mounted as read-only (readOnly: true) with restrictive permissions (defaultMode: 0400) for security.


Question 16

What is an immutable ConfigMap?

Show explanation

Correct answer: A ConfigMap that cannot be modified after creation, improving performance and security

Explanation: Immutable ConfigMaps (immutable: true) cannot be modified, reducing the load on the API Server and improving security.


Question 17

How do you update a ConfigMap used by a running Pod?

Show explanation

Correct answer: If mounted as a volume, you need to restart the Pod. If injected as env, you need to recreate the Pod

Explanation: ConfigMaps mounted as volumes are updated periodically, but injected environment variables do not change without recreating the Pod.


Question 18

What is the command to create a Secret from a file?

Show explanation

Correct answer: kubectl create secret generic [name] --from-file=[key]=[file]

Explanation: --from-file allows you to create a Secret from a file, where you can specify the key and the source file.


Question 19

What is secret rotation?

Show explanation

Correct answer: The process of periodically replacing secrets with new values for security

Explanation: Secret rotation is a security best practice that involves regularly changing passwords, tokens, and keys to limit the impact of a compromise.


Question 20

What is the difference between an Opaque Secret and a TLS Secret?

Show explanation

Correct answer: Opaque is for arbitrary data, TLS is specifically for TLS certificates

Explanation: TLS Secrets have specific keys (tls.crt, tls.key) and are used by tools like cert-manager for SSL/TLS certificates.


Question 21

How do you organize ConfigMaps by environment?

Show explanation

Correct answer: Create separate ConfigMaps for each environment (dev, staging, prod) with different names

Explanation: The best practice is to create distinct ConfigMaps for each environment, allowing clear management and avoiding configuration errors.


Question 22

What is the total size limit of a ConfigMap or Secret?

Show explanation

Correct answer: Limited by etcd (typically 1.5 MiB per object)

Explanation: While each entry is limited to 1 MiB, the total size of a ConfigMap or Secret is limited by etcd, typically around 1.5 MiB.


Question 23

What is a Secret volume type?

Show explanation

Correct answer: A volume that mounts Secret data as files in a Pod

Explanation: Secrets can be mounted as volumes, where each key becomes a file with the decoded value as content.


Question 24

What is the best practice for secrets in YAML files?

Show explanation

Correct answer: Never put secrets in plain text, use references (secretKeyRef) or external tools

Explanation: Secrets should never be in plain text in YAML files, even in base64. Use references or secret management tools.


Question 25

How do you use a ConfigMap in a Deployment?

Show explanation

Correct answer: In the Pod template of the Deployment, via env, envFrom, or volumes

Explanation: ConfigMaps are referenced in the Pod template (spec.template.spec) of a Deployment, via env/envFrom for environment variables or volumes for files.


Question 26

What is a Service Account in the context of Secrets?

Show explanation

Correct answer: An identity for Pods that can be associated with Secrets for API Server access

Explanation: Service Accounts can have imagePullSecrets to access private registries, but are not directly related to application Secrets.


Question 27

What is the command to delete a ConfigMap?

Show explanation

Correct answer: kubectl delete configmap [name]

Explanation: kubectl delete is the standard command for deleting any Kubernetes resource, including ConfigMaps.


Question 28

What is a docker-registry Secret?

Show explanation

Correct answer: A Secret that stores credentials for accessing a private Docker registry

Explanation: docker-registry Secrets are used as imagePullSecrets to allow Pods to pull images from private registries.


Question 29

What is the best practice for versioning ConfigMaps?

Show explanation

Correct answer: Use labels with version numbers and create new ConfigMaps for each version

Explanation: Versioning ConfigMaps with labels allows you to track changes and facilitates rollbacks by referencing different versions.


Question 30

What is the difference between valueFrom.configMapKeyRef and valueFrom.secretKeyRef?

Show explanation

Correct answer: configMapKeyRef references a key in a ConfigMap, secretKeyRef references a key in a Secret

Explanation: These two references work the same way but point to different resource types: ConfigMap for non-sensitive data, Secret for sensitive data.


Quiz Results

Congratulations on completing the Module 5 quiz!

Score:

  • 25-30 correct answers: Excellent! You have mastered configuration and secrets.
  • 20-24 correct answers: Very good! Review concepts where you had difficulty.
  • 15-19 correct answers: Good! Review the chapters on ConfigMaps and Secrets.
  • Less than 15: Recommended to review the module before continuing.

Quiz created: December 2024