Mise as a DevOps Tool: kubectl Version and Config Management

I absolutely love to use (Mise)[https://mise.jdx.dev] to configure my dev environments. Recently I started to use it for my DevOps work as well. Here’s how it comes handy.

kubectl version management

If you work with multiple Kubernetes clusters and each of them is on a different version, you may end-up needing different version of kubectl.

You can archive that easily using Mise. In your project folder you run mise use kubectl@1.34.

Mise will download kubectl and put mise.toml config file into your project folder:

[tools]
kubectl = "1.34"

Now each time you run kubectl in your project folder, it will be the 1.34 version.

kubectl config management

As a next optional improvement I prefer to put kubeconfig besides the mise.toml file. As a result not only version of the kubectl will be pinned to what project needs, but context will be “switched” as well. In other words if you need to work with different cluster you cd into corresponding project.

[env]
KUBECONFIG = "{{config_root}}/kubeconfig"

[tools]
kubectl = "1.34"

If most of your clusters are on the same version of kubectl you could pin it globally using mise use -g kubectl@1.34. Now you can run kubectl in any folder and switch context using kubectl config use-context {NAME}. For that to work you need to make sure .kube/config configured correctly.

NOTE: Make sure to add kubeconfig to your .gitignore, so you won’t accidentally push it.