Bird
0
0

You have multiple kubeconfig files and want to merge them so kubectl can use all contexts. Which command helps merge configs correctly?

hard📝 Application Q9 of 15
Kubernetes - Fundamentals
You have multiple kubeconfig files and want to merge them so kubectl can use all contexts. Which command helps merge configs correctly?
Akubectl merge config1 config2 -o merged-config
BKUBECONFIG=config1:config2 kubectl config view --merge --flatten > merged-config
Ckubectl config combine config1 config2 > merged-config
Dkubectl config merge --files=config1,config2 --output=merged-config
Step-by-Step Solution
Solution:
  1. Step 1: Understand merging kubeconfigs

    Setting KUBECONFIG env var with colon-separated files and running kubectl config view --merge --flatten merges them.
  2. Step 2: Check command correctness

    KUBECONFIG=config1:config2 kubectl config view --merge --flatten > merged-config uses correct syntax and official method. Other options are invalid commands.
  3. Final Answer:

    KUBECONFIG=config1:config2 kubectl config view --merge --flatten > merged-config -> Option B
  4. Quick Check:

    Merge kubeconfigs with KUBECONFIG and config view [OK]
Quick Trick: Use KUBECONFIG env var and config view to merge [OK]
Common Mistakes:
  • Trying non-existent kubectl merge commands
  • Not using colon separator in KUBECONFIG
  • Forgetting --flatten flag

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes