Home DevOps Azure Merge Kube Config in PowerShell

Merge Kube Config in PowerShell

0
Merge Kube Config in PowerShell

Merge Kube Config in PowerShell

Merging Kubernetes Config files is a rather cumbersome process. You can manually copy in the values but sometimes that doesn’t always go as planned. I was looking for a way to merge Kube Config files when I ran across a great post that wasn’t geared for PowerShell users.

Key Takeaways

  • Must use full path. Relative paths did not work.
  • $ENV:KUBECONFIG was an empty value before I set it.
  • –flatten – is used to flatten the kubeconfig file into a self-contained output.

For this demo, my newly created Kubernetes Config file will be called config-devbox.

I have to thank Jacob Tomlinson for his post on Medium “How to merge Kubernetes kubectl config files”, however, his post was not based on Windows PowerShell users. If you’re looking for the Bash equivalent I suggest you visit his post!

PowerShell

Clean Up

To remove old clusters by name see the commands below.

Further Reading

https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands