Bird
0
0

You have a Secret YAML with data keys encoded in Base64. You want to update the password key with a new plain text value using kubectl. What is the best approach?

hard📝 Workflow Q9 of 15
Kubernetes - Secrets
You have a Secret YAML with data keys encoded in Base64. You want to update the password key with a new plain text value using kubectl. What is the best approach?
ADelete the Secret and recreate it with new Base64 encoded password
BManually Base64 encode the new password and update the data field in YAML
CUse kubectl patch with stringData field containing the new plain text password
DEdit the Secret YAML and put the plain text password in data field
Step-by-Step Solution
Solution:
  1. Step 1: Understand kubectl patch with stringData

    kubectl patch allows updating Secrets using plain text in stringData, which Kubernetes encodes automatically.
  2. Step 2: Avoid manual Base64 encoding or deleting Secret

    Manual encoding or deleting is error-prone and less efficient.
  3. Final Answer:

    Use kubectl patch with stringData field containing the new plain text password -> Option C
  4. Quick Check:

    Update Secret with plain text = kubectl patch + stringData [OK]
Quick Trick: Use stringData in patch to update Secrets with plain text [OK]
Common Mistakes:
  • Editing data field with plain text
  • Manually encoding Base64 when not needed
  • Deleting and recreating Secrets unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes