Kubernetes contexts in Aptakube

This article explains how Aptakube loads Kubernetes contexts and how you can fix issues with loading contexts.

Aptakube uses the same rules as Kubectl when it comes to loading contexts. In most cases, if you're already using Kubectl, Aptakube will load your Kubernetes contexts automatically and it'll just work. But if you have a slightly different setup, you might need some extra configuration to load your contexts.

Don't have a Kubeconfig yet? Follow these guides on how to download one for popular managed services: GKE, EKS and AKS.

Where Aptakube finds Kubeconfig files

These are the rules and order in which Aptakube loads contexts:

1. $APTAKUBECONFIG environment variable

This is a custom environment variable used by Aptakube to load contexts. If this variable is set, Aptakube will load contexts from the file specified in this variable. The content of this variable follows the same rules as the standard KUBECONFIG environment variable, which means that multiple files are supported.

We recommend using this setting only if you want to automatically load different contexts for aptakube and kubectl, otherwise use the standard KUBECONFIG environment variable.

Examples:

  • Single config file: APTAKUBECONFIG=~/workspace/config1
  • Multiple config files: APTAKUBECONFIG=~/workspace/config1:~/path/to/config2

2. $KUBECONFIG environment variable

This is the standard environment variable used by both Aptakube and Kubectl to load contexts. Multiple files are also supported.

Examples:

  • Single config file: KUBECONFIG=~/workspace/config1
  • Multiple config files: KUBECONFIG=~/workspace/config1:~/path/to/config2

3. ~/.kube/config default path

This is the standard default path used by both Aptakube and Kubectl to load contexts. If none of the variables above are set, Aptakube will try to load contexts from this file.

Load Kubeconfig files from other locations

Keep Kubeconfig files somewhere else, like a folder per customer or files generated by a script? You can also add them in the app, without setting an environment variable. In Aptakube, open Preferences, go to Kubeconfig, and under Kubeconfig Sources choose:

  • Add Files to pick one or more Kubeconfig files
  • Add Folder to load the Kubeconfig files in a whole folder
  • Enter Path to type a path instead of browsing for it

If your files aren't complete on their own, for example when one file has the contexts and another has the clusters and users, turn on Merge Files under Kubeconfig Settings. Aptakube never modifies your Kubeconfig files, whichever way it loads them.

Aptakube's Kubeconfig preferences: the Kubeconfig Sources list with ~/.kube/config and the Add Files, Add Folder and Enter Path buttons, and the Merge Files setting
Add Kubeconfig files and folders in Preferences → Kubeconfig

Customize your contexts

Once your contexts are loaded, you can give each one an alias to show instead of its name, an icon and a color to tell your clusters apart at a glance, tags to group related contexts and connect to all of them in one click, and Change Protection to make a cluster protected or read-only in Aptakube. Right-click a context and choose Customize to set them on your machine.

To share them with your team, set them in your Kubeconfig file with a Context Extension instead: everyone who uses that file gets the same aliases, icons, colors, tags and Change Protection, and you can also set the order the contexts are listed in.


If you need help with your setup, contact us at GitHub or hello@aptakube.com.