It’s easy to get going with Lens on virtually any computer with a graphical desktop environment (Linux, Mac, or Windows). The only real requirement is that you need one or more pre-existing Kubernetes clusters for Lens to look at. (Otherwise, what’s the point?) Specifically, Lens talks to the Kubernetes API via kubectl, so you’ll need connectivity to your cluster(s) from the computer on which you want to install Lens to port 6443 of the cluster controller using https. As long as you have the kubeconfig for your cluster stored locally (and Lens can help you find that), you should be good to go. The cluster itself can be pretty-much anywhere and derive from any source. You can use Lens to control local clusters (such as Docker Kubernetes Service clusters running on your laptop), or remote clusters on bare metal, private, or public clouds. Lens adapts automatically to manage different recent versions of Kubernetes, so dealing with multiple generations of Kubernetes cluster is no problem. Don’t have a cluster yet? Happily, that’s easy too, because you can install a Mirantis Container Cloud (formerly Docker Enterprise) cluster quickly, using Launchpad. In fact, Launchpad and Lens companion very well, since Launchpad is available for Linux, Mac, and Windows, too.
Installing LensBasic docs can be found at the Lens repository on GitHub. Downloadables are available on the releases page. Installation on Windows (via .exe) and Mac (via .dmg) is easy; just download those files to the local machine and run them. On Mac, you can also:
brew cask install lensto get the latest version. For Linux, Lens is available via snap or packaged as an AppImage, which we recommend for its convenience. If you haven’t encountered AppImages before (plenty of frequent Linux users haven’t – don’t feel bad), AppImage tech provides a way of packaging application dependencies together in executable binaries that will run on pretty much any Linux machine. To use the AppImage, just download the release binary to a safe place on your system, make it executable, and run it from the command line or your desktop’s application browser. Because Lens is a desktop application, you don’t even need to be particularly concerned about making sure to save the Lens binary somewhere on your CLI execution path, because the first time it runs, it inserts an icon in your ‘Favorites’ bar that you can pin there to make subsequent execution easy. Using a standard browser, this is pretty simple, but you can also do it from the command line. To do so, right-click on the link to the AppImage on the Releases page and select Copy link address, then:
- Make a lens directory
- cd into it
- download the binary there using wget, curl, or another tool
- make the binary executable, and
- run it, prefixing the file name with ./ to tell bash that it needs to look in the local directory instead of elsewhere on your execution path.
mkdir lens cd lens wget https://github.com/lensapp/lens/releases/download/v3.5.2/Lens-3.5.2.AppImage chmod +x Lens-3.5.2.AppImage ./Lens-3.5.2.AppImageLens checks for updates, then opens on your desktop. Right-click on its icon in your Favorites bar and click Add to Favorites to make it more easily accessible. When launching Lens from a Favorites icon, be sure to just click once for each instance of Lens you want to run. Especially on slowish virtual machines, Lens takes a few moments to start up (check for updates, load contexts, and so on), so it’s easy to get half a dozen instances launching at once if you get impatient and click multiple times.
Configuring Lens to work with your cluster(s)Lens makes configuration very simple. Click Add Cluster in the File menu, and Lens pops up a list of all the kubeconfigs it’s found on your local system. Pick one, and Lens self-configures — creating a context for that cluster so it can manage (for example) the particular version of Kubernetes API it uses, and other details. If you can’t find your desired kubeconfig in the list, it may be that you haven’t yet downloaded an authentication bundle for that cluster. (Perhaps it was recently deployed, or you deployed it on a public cloud service). For Mirantis Container Cloud clusters, just browse the Mirantis Kubernetes Engine webUI, click on Admin>My Profile>Client Bundles, generate and download a new client bundle, unzip it, and find the kube.yml file; that’s the one Lens needs. Before manually adding the cluster, it makes sense to use kubectl to make sure the config is working and you can reach the cluster. For Mirantis Container Cloud, this is easy — just source the env.sh from the client bundle, to authenticate:
source env.shThen run any kubectl command, such as:
kubectl get pods --all-namespacesYou can then list and copy the kube.yml. In Lens, click on Custom in the kubeconfig pick list, then just paste the YAML into the window and click Add Cluster. In moments, Lens will populate its context, add your cluster, and show its details in the main window. The only thing you won’t see, at first, is cluster metrics, which is the next thing we’ll set up.