Skip to main content

OpenLens

This tool is built for Kubernetes. Some basic knowledge of Kubernetes terminology will be useful. Else consult:

OpenLens vs Lens IDE

There can be some confusion between the open source version 'OpenLens' and the commercial 'Lens IDE', since they have the same origin. With the words from the 'OpenLens Build Repo':

  • The OpenLens repository, is where Team Lens (Mirantis) develops the Lens IDE product together with the community. It is backed by a number of Kubernetes and cloud native ecosystem pioneers. This source code is available to everyone under the MIT license.
  • The Kubernetes management tool Lens IDE is a distribution of the OpenLens repository with Team Lens specific customizations released under a traditional EULA.

AMCS does not have any Lens IDE licenses, hence we will use only OpenLens.

Prerequisites: kubectl and kubeconfig

When working with Kubernetes clusters, one typically uses kubeconfig files to organize information about clusters, users, namespaces, and authentication mechanisms. The kubectl command-line tool uses kubeconfig files to find the information it needs to choose a cluster and communicate with the API server of a cluster. See the official doc for more info on these files.

OpenLens itself uses the kubectl tool to retrieve information about your clusters from such a file. We therefore need to install it and configure the kubeconfig for the desired AKS (Azure Kubernetes Services) cluster. If you are certain those are set up, you may choose to proceed to the OpenLens installation.

First install the Azure CLI, if missing. Run the command az aks install-cli in PS (PowerShell) which should

  • download and install kubectl - the Kubernetes command-line tool
  • download and install kubelogin - a plugin implementing azure authentication

Restart PS and run Get-Command kubectl and Get-Command kubelogin to verify that those commands can be found. If this fails, add them to your PATH environment variable (by default, they are installed in subdirectories of %USERPROFILE%).

For more info on the available AKS management commands, see the az aks reference.

Finally, to configure access to an AKS cluster 'eu1-aks-devtest-1' from the resource group 'eu1-aks-devtest-1-rg', run the command

az aks get-credentials -n eu1-aks-devtest-1 -g eu1-aks-devtest-1-rg

This should generate a message like 'Merged "eu1-aks-devtest-1" as current context in %USERPROFILE%.kube\config'. You can inspect this kubeconfig.

If above command generates an "AuthorizationFailed" error, retry after resetting your azure login and subscription via

az account clear
az login
az account set -s Development

OpenLens installation

Go to the Releases on the OpenLens Build Repo and download a suitable installer. The Windows installer should have the extension '.exe' (at time of writing, we used v6.4.15 and the installer was named OpenLens-6.4.15.exe). Run the installer for your user. The last step will open OpenLens.

Using OpenLens: First time

Start OpenLens. It will read the kubeconfig from its default location (%USERPROFILE%.kube\config). The first time OpenLens starts, you should see this screen:

img

Click to browse the available Clusters. This should open a table with at least one entry. Pin it for quick access:

img

If the table is empty, then your kubeconfig can not be read or is empty - revisit the prerequisites section above.

Right click the cluster (in the left hand menu, not in the table), choose 'Settings'. Open the 'Namespace' tab and add the namespace for the cluster: At time of writing, this was 'eu1-gdcc-dev' and in a perfect world, DevOps would grant us the rights to list namespaces. Click the circled X to close Settings and select (regular click) the pinned cluster to connect to it (if the table of clusters is not shown navigate to it, by clicking the blue icon in the left hand side). You will likely receive the message "To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate.":

img

Do as asked and hit the reconnect button to connect.

Using OpenLens: Basics

Once you can successfully connect to the cluster, a UI will allow you to explore the cluster. Some windows will not load or show anything, as DevOps has not granted us the required rights (feel free to raise tickets!). This includes the 'main Cluster tab' when connected. Instead, select 'Workloads > Overview' and you should see something similar to:

img

Feel free to explore other tabs/sections via the UI. One useful view is 'Workloads > Pods' where you can select a specific pod, which opens a sidebar with details about the containers in the pod.

img

Using OpenLens: Improvements

Install extension to view pod logs

Functionality to view pod logs was removed from OpenLens but can be added by an extension. Simply follow the install steps from https://github.com/alebcay/openlens-node-pod-menu (the extensions menu can be found by opening the hamburger menu in the upper left hand corner and choosing File > Extensions). Restart OpenLens (it might hang after installing the extension). Finally, you have these extra buttons to open pod logs:

img

Kubelogin via Azure Cli

The 'devicelogin' will keep coming up between restarts. If this is too cumbersome, you may want to authenticate via azure Cli. Simply run the commands az login and then kubelogin convert-kubeconfig -l azurecli in PS. This will adjust your kube config. Finally, (re)start OpenLens. And verify it can still connect.