Show current Kubernetes context in the menu bar

kubernetes context macos tray icon

2 min read | by Jordi Prats

Some commands might be safe to execute while connected to some environments, but can definitely break stuff is applied to the wrong Kubernetes cluster. However, having to execute kubectl config current-context too ofter to make sure we are connected to the right cluster is no fun either.

With kubectx tray we can have a small icon on the tray bar to help us identify what's the current cluster.

This application is currently only available for MacOS, once installed it will start watching for changes on the ~/.kube/config file to update the icon it is displaying

tray icon kubernetes context

Clicking to it, it will display the full name of the current context and the current namespace.

With the ~/.kube/kct-config file we can configure the icon we want to use and an optional text we want to show next to it:

contexts:
- match: preprod.k8s
  title: preprod
  icon: yellow
- match: devel.k8s
  title: dev
  icon: green
- match: kind-
  title: kind

Any PR to add icons, add Linux support or add functionality is more than welcome.


Posted on 30/11/2022