An Opaque secret is the default secret type in Kubernetes. It stores arbitrary user-defined data as key-value pairs, such as passwords or tokens, in base64 encoded form.
Click to reveal answer
beginner
What is the purpose of a docker-registry secret in Kubernetes?
A docker-registry secret stores credentials for accessing private container registries. It allows Kubernetes to pull private images securely using stored username, password, email, and server URL.
Click to reveal answer
beginner
What does a TLS secret contain in Kubernetes?
A TLS secret contains a private key and a certificate used for TLS encryption. It is commonly used to secure communication between clients and servers inside Kubernetes.
Click to reveal answer
intermediate
How do you create an Opaque secret using kubectl?
Use the command: kubectl create secret generic my-secret --from-literal=key1=value1 --from-literal=key2=value2 This creates an Opaque secret named 'my-secret' with two key-value pairs.
Click to reveal answer
beginner
Which secret type would you use to store a TLS certificate and key?
You would use the TLS secret type because it is designed to hold a certificate and private key for secure communication.
Click to reveal answer
What is the default secret type in Kubernetes?
AServiceAccountToken
Bdocker-registry
CTLS
DOpaque
✗ Incorrect
Opaque is the default secret type used to store arbitrary key-value pairs.
Which secret type is used to store Docker registry credentials?
Adocker-registry
BTLS
COpaque
DBasicAuth
✗ Incorrect
The docker-registry secret stores credentials for private container registries.
What data does a TLS secret contain?
ACertificate and private key
BUsername and password
CAPI tokens
DConfig maps
✗ Incorrect
TLS secrets hold a certificate and private key for encrypted communication.
How do you create an Opaque secret with literal values?
Akubectl create secret docker-registry
Bkubectl create secret generic --from-literal
Ckubectl create secret tls
Dkubectl create configmap
✗ Incorrect
Use 'kubectl create secret generic' with --from-literal to create an Opaque secret.
Which secret type is best for storing a private key and certificate for HTTPS?
AOpaque
Bdocker-registry
CTLS
DBasicAuth
✗ Incorrect
TLS secret type is designed for storing certificates and private keys.
Explain the differences between Opaque, docker-registry, and TLS secret types in Kubernetes.
Think about what kind of data each secret type holds and why.
You got /3 concepts.
Describe how you would create and use a docker-registry secret to pull a private image.
Focus on the command and how Kubernetes uses the secret.
You got /3 concepts.
Practice
(1/5)
1. Which Kubernetes secret type is best suited for storing general sensitive data like passwords or tokens?
easy
A. Opaque
B. docker-registry
C. TLS
D. ConfigMap
Solution
Step 1: Understand secret types
Opaque secrets are designed to store arbitrary user-defined data such as passwords or tokens.
Step 2: Compare with other types
docker-registry is for Docker credentials, TLS is for certificates, and ConfigMap is not a secret type.
2. Which kubectl command correctly creates a docker-registry secret named myregistrykey with username user1 and password pass123?
easy
A. kubectl create secret docker-registry myregistrykey --docker-server=https://myregistry.com --docker-username=user1 --docker-password=pass123
B. kubectl create secret generic myregistrykey --docker-username=user1 --docker-password=pass123
C. kubectl create secret tls myregistrykey --docker-username=user1 --docker-password=pass123
D. kubectl create secret docker-registry myregistrykey --username=user1 --password=pass123
Solution
Step 1: Identify correct secret type and flags
docker-registry secrets require the type 'docker-registry' and flags --docker-server, --docker-username and --docker-password.
Step 2: Check command syntax
kubectl create secret docker-registry myregistrykey --docker-server=https://myregistry.com --docker-username=user1 --docker-password=pass123 uses correct type and flags; others use wrong types or flag names.
Hint: Use --docker-server, --docker-username and --docker-password with docker-registry type [OK]
Common Mistakes:
Using generic secret type for docker-registry secrets
Wrong flag names like --username instead of --docker-username
Using TLS secret type for docker credentials
3. Given the command kubectl create secret tls mytlssecret --cert=cert.pem --key=key.pem, what will be the type of the created secret?
medium
A. Opaque
B. docker-registry
C. TLS
D. generic
Solution
Step 1: Analyze the command
The command uses 'create secret tls' with certificate and key files specified.
Step 2: Match secret type
Secrets created with 'tls' type store TLS certificates and keys, so the type is TLS.
Final Answer:
TLS -> Option C
Quick Check:
kubectl create secret tls = TLS type secret [OK]
Hint: TLS secrets use 'kubectl create secret tls' with cert and key [OK]
Common Mistakes:
Assuming TLS secrets are Opaque
Confusing generic secret type with TLS
Not specifying cert and key files properly
4. You run kubectl create secret tls mytlssecret --cert=cert.pem but get an error. What is the likely cause?
medium
A. Using wrong secret type, should be opaque
B. Missing --key flag with private key file
C. Certificate file is empty
D. Secret name contains invalid characters
Solution
Step 1: Check required flags for TLS secret
Creating TLS secrets requires both --cert and --key flags to specify certificate and private key files.
Step 2: Identify missing flag
The command only has --cert but lacks --key, causing the error.
Final Answer:
Missing --key flag with private key file -> Option B
Quick Check:
Both --cert and --key required for TLS secret [OK]
Hint: TLS secrets need both --cert and --key flags [OK]
Common Mistakes:
Omitting the --key flag when creating TLS secrets
Using opaque type instead of TLS for certs
Assuming secret name format causes error
5. You want to pull images from a private Docker registry in your Kubernetes cluster. Which secret type should you create and how should you use it in a Pod spec?
hard
A. Create a TLS secret and add it to the Pod's environment variables
B. Create an opaque secret and mount it as a volume in the Pod
C. Create a generic secret and specify it in the Pod's volumes section
D. Create a docker-registry secret and reference it in imagePullSecrets of the Pod
Solution
Step 1: Identify secret type for private Docker registry
docker-registry secret stores Docker credentials for private registries.
Step 2: Use secret in Pod spec
To allow image pull, reference the secret in the Pod's imagePullSecrets field.
Final Answer:
Create a docker-registry secret and reference it in imagePullSecrets of the Pod -> Option D