CKAD Practice Question: Application Environment, Configuration and Security
You need to create a TLS secret for an ingress with certificate and key. Which command correctly creates the secret?
⚠ Common exam trap
A common mix-up: candidates think `kubectl create secret generic` with `--from-file` can create a TLS secret, but they overlook that the secret type must be `kubernetes.io/tls` for the Ingress controller to use it, and the generic command does not set that type.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
kubectl create secret tls tls-secret --cert=tls.crt --key=tls.key
`kubectl create secret tls` is the dedicated subcommand for creating a TLS secret, which automatically encodes the certificate and key files and stores them under the expected keys (`tls.crt` and `tls.key`). This is the only command that produces a secret of type `kubernetes.io/tls`, which is required by Ingress controllers to serve HTTPS traffic.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
kubectl create secret tls tls-secret --cert=tls.crt --key=tls.key
Why this is correct
This creates a TLS secret of type kubernetes.io/tls.
- ✗
kubectl create secret docker-registry tls-secret --docker-cert=tls.crt --docker-key=tls.key
Why it's wrong here
This creates a docker-registry secret, not a TLS secret.
- ✗
kubectl create secret generic tls-secret --from-file=tls.crt --from-file=tls.key
Why it's wrong here
This creates a generic Opaque secret, not a TLS secret. The type will be Opaque, not kubernetes.io/tls.
- ✗
kubectl create secret certificate tls-secret --cert= --key=
Why it's wrong here
There is no 'certificate' subcommand for kubectl create secret.
Go deeper
Related to this question
About these practice questions
One of 160 original CKAD practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKAD practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKAD exam.