CKAD Practice Question: Application Environment, Configuration and Security
Which kubectl command creates a Secret from literal username and password values?
⚠ Common exam trap
Candidates often confuse `--from-literal` with the non-existent `--literal` flag, or assume that multiple key-value pairs can be passed in a single `--from-literal` argument, leading them to choose Option A.
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 generic my-secret --from-literal=username=admin --from-literal=password=secret123
`kubectl create secret generic` with `--from-literal` is the proper syntax for specifying literal key-value pairs directly in the command. Each literal must be prefixed with `--from-literal=key=value`, and multiple literals can be provided to create a Secret containing both the username and password keys.
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 generic my-secret --literal username=admin password=secret123
Why it's wrong here
The correct flag is --from-literal, not --literal.
- ✓
kubectl create secret generic my-secret --from-literal=username=admin --from-literal=password=secret123
Why this is correct
This creates a Secret from literal key=value pairs.
- ✗
kubectl create secret generic my-secret --from-file=username --from-file=password
Why it's wrong here
--from-file expects file paths, not literal values.
- ✗
kubectl create secret generic my-secret --from-env-file=creds.txt
Why it's wrong here
--from-env-file reads from a file, not command line literals.
Go deeper
Related to this question
About these practice questions
This CKAD question is part of Courseiva's 160-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.