Kubernetes Dashboards: Lens
Tags: kubernetes, containers
Published: 2021-06-29 17:38:27

---
title: Kubernetes Dashboards: Lens
published: true
description: A look at Lens, one of the dashboards for Kubernetes.
tags: kubernetes, containers 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6dlhz1mu55gqqpa63qu8.png
canonical_url: https://loft.sh/blog/kubernetes-dashboards-lens/
---
Command-line tools like kubectl are a great way to interact with Kubernetes clusters for some of us, but many people prefer a graphical interface. Kubernetes has a [built-in dashboard](https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/), but some people are looking for features that it doesn’t support. In this series, we’ll look at some of the other dashboards that are available for Kubernetes and what they have to offer.

We’ll begin with one of the most popular alternatives out there, Lens. The Lens team describes their tool as  “The Kubernetes IDE for Development,” and it is a very powerful tool. Lens was originally proprietary, but [Mirantis acquired it](https://techcrunch.com/2020/08/13/mirantis-acquires-lens-an-ide-for-kubernetes/) in August of 2020 and open sourced [the code](https://github.com/lensapp/lens). It’s an [Electron-based](https://www.electronjs.org/) app that you run locally on your computer. It allows read and write access to your Kubernetes clusters.

## Adding a Cluster

Connecting to a Kubernetes cluster with Lens is easy. If you have a local Kubeconfig file that points to the cluster, you can import that into Lens to connect.

![Screenshot showing how to add a cluster to Lens from a Kubeconfig](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk7e31j89luo3s93x4q9.png)

Lens allows you to configure multiple clusters to manage, and switch between them easily.

## Metrics

The metrics in Lens are very handy.

![Screenshot showing the metrics dashboard in Lens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iah5p6aebfwqr151ya6z.png)

Lens won’t be able to display metrics until you [configure it to work with Prometheus](https://docs.k8slens.dev/main/clusters/settings/#prometheus), though. If you don’t have a Prometheus instance in your cluster you can add one easily directly from Lens. Right-click on the cluster icon in the upper left corner of the UI, and then choose Settings. There you can install a Prometheus instance that is already set up to work with Lens. You can also preview the Kubernetes manifests for Prometheus before you apply them.

If you already have Prometheus running you can [configure it](https://github.com/lensapp/lens/blob/master/troubleshooting/custom-prometheus.md) to work with Lens.

## Managing Objects

You can view the state of the objects in your cluster, including pods, deployments, namespaces, network, storage, and even custom resources. Lens is a great way to quickly identify pods that aren’t operating correctly, and get an idea why.

![Screenshot showing the pod listing in lens. One pod has a yellow yield sign icon indicating an error. Mousing over it shows that the problem is insufficient CPU.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/unyvjng0aym5ppnk3331.png)

As you can see, in this view I’ve selected multiple namespaces to view the pods for. I’m able to just mouse over a pod that’s stuck in a pending state to see why. These are all things you can surface with kubectl, but some people do prefer a more graphical view.

Lens will allow you to make changes in the cluster if your user has the correct access. This could be very good or very bad depending on the context. If you’re a shop using GitOps, you may not want individual developers or platform engineers to make changes to the state outside of your code workflow. If you’re working with a development cluster, though, that may be fine. It all depends on how your team works.

One thing you can do with Lens is install applications from Helm charts. Click the Apps icon in the left menu, and then you can search for the chart you want to install. This is a lot handier than going to [Artifact Hub](https://artifacthub.io/) and tracking down a chart there and it could be very useful for evaluating new Helm charts. 

![Screenshot showing how to deploy NGINX from a Helm chart in Lens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bp2n9skhuqq3zcozygl2.png)

After clicking the Install button you’re presented with a screen where you can edit the YAML directly to make changes. In this example, I’ve changed the number of NGINX replicas from one to three.

![Screenshot showing how to edit the number of replicas in the Helm chart deploy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bw4is44kysz1pm2pg0x1.png)

You can also edit running objects in the cluster like you would with [kubectl edit](https://jamesdefabia.github.io/docs/user-guide/kubectl/kubectl_edit/).

![Screenshot showing how to edit a running deployment in Lens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bnfp1sdx5p11h1w4rx0.png)

Again, this is not likely something that most teams would want to do in a production environment, but it could be great for people who aren’t comfortable with kubectl yet, or for people working in isolated development environments. It’s also important to note that the changes a user can make in Lens would also be possible with kubectl, so the real way to prevent changes from being made outside of your GitOps workflow is with [Role-based access control (RBAC)](https://kubernetes.io/docs/reference/access-authn-authz/rbac/) permissions.

## Extensions

Extensions is a newer feature in Lens that allows you to write custom code to extend Lens, or to re-use extensions that other people have built. Right now there are a few extensions [shared on GitHub](https://github.com/lensapp/lens-extensions). Hopefully more will emerge. [Kubecost just released an extension](https://blog.kubecost.com/blog/lens-kubecost-extension/) for tracking your cost metrics in Lens.

If you’d like to get your feet wet building your own Lens extensions, there is a [development guide in the docs](https://api-docs.k8slens.dev/v4.2.5/extensions/get-started/overview/). Typescript is recommended, and you can also [write tests](https://api-docs.k8slens.dev/v4.2.5/extensions/testing-and-publishing/testing/) for your extensions. If you enjoy using Lens and are comfortable with JavaScript/Typescript, this may be worth looking into.

## Conclusion

Lens has a lot of great features, and it’s a standalone app as opposed to the built-in Kubernetes Dashboard. We all use tools differently, which is why it’s great that there’s such a variety of graphical user interfaces for Kubernetes. 

If you use Kubernetes, it’s worth taking a look at Lens.

In my next post in the series I’ll be looking at [Headlamp](https://github.com/kinvolk/headlamp), another popular UI for Kubernetes, and later we’ll look at the official [Kubernetes Dashboard](https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/). Stay tuned.