Talking about containers, I believe you know the kind of enthusiasm, uproar, focus and attention that it has earned itself in the past like five years or so. Organizations have been literally shaken, re-organized and others ruminating about the opportunities, the risks and the challenges that this paradigm of handling infrastructure and business applications will bring on the table. For now, developers, DevOps engineers, operations teams and the blue teamers are busy getting as much as they can in order to gauge the viability of this glittering new trend of containerizing applications.

At the heart of this discussion and paradigm shift, sits the famous names such as Kubernetes, Docker, Podman, OpenShift, containerd, CRI-O, Rancher and the likes. You have had a fair share of them and we believe you have burned the midnight oil to get a grasp of what they are all about.

Today, we introduce another name and player in this vast field known as Lens that has been dubbed “The Kubernetes IDE“. So what is this Lens?

To keep it simple, Lens is a standalone application for MacOS, Windows and Linux operating systems that helps people have a deeper, better and beautiful look and insight into their Kubernetes clusters. It is the most powerful IDE for people who need to deal with Kubernetes clusters on a daily basis. It helps one ensure that their clusters are properly setup and configured, increase their visibility, get real time statistics, log streams and hands-on troubleshooting capabilities. With Lens, you can work with your clusters more easily and fast, radically improving productivity and the speed of business. The best thing about it is that it is open source and free. And guess what, you can contribute to the this noble project and be part of its beauty.

Features of Lens

Apart from what we have already talked about Lens, here are additional features that it boasts of:

  • Multi Cluster Management: Access and work with your clusters with a confidence from a single unified IDE. Lens works with any number of Kubernetes clusters.
  • Built-In Prometheus Stats: See all relevant graphs and resource utilization charts integrated as part of the dashboard. Lens comes with a built-in and multi-tenant Prometheus setup that will respect RBAC for each user.
  • Context Aware Terminal: The built-in terminal comes with kubectl that is always API compatible with your cluster and in the right context. Lens built-in terminal will ensure the version of Kubernetes cluster API is compatible with the version of kubectl.
  • Multiple Workspaces: Organize clusters into logical groups. Workspaces are used to organize a number of clusters into logical groups.

To test and see the capabilities of Lens, we will install k3s on a Linux virtual machine and then connect Lens to it to view metrics and monitor how it is faring. K3s is a highly available, certified Kubernetes distribution designed for production workloads in unattended, resource-constrained, remote locations or inside IoT appliances. To start off, let us install k3s on Linux.

Install k3s on Linux (Optional – if you don’t have Kubernetes Cluster)

Run the command below to get k3s downloaded and installed:

$ curl -sfL https://get.k3s.io | sudo sh -

[INFO]  Finding release for channel stable
[INFO]  Using v1.18.8 k3s1 as release
[INFO]  Downloading hash https://github.com/rancher/k3s/releases/download/v1.18.8 k3s1/sha256sum-amd64.txt
[INFO]  Downloading binary https://github.com/rancher/k3s/releases/download/v1.18.8 k3s1/k3s
[INFO]  Verifying binary download
[INFO]  Installing k3s to /usr/local/bin/k3s
[INFO]  Creating /usr/local/bin/kubectl symlink to k3s
[INFO]  Creating /usr/local/bin/crictl symlink to k3s
[INFO]  Creating /usr/local/bin/ctr symlink to k3s
[INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
[INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
[INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
[INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
[INFO]  systemd: Enabling k3s unit
Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
[INFO]  systemd: Starting k3s

Check if the node(s) are okay

$ sudo k3s kubectl get node

NAME        STATUS   ROLES    AGE   VERSION
localhost   Ready    master   20m   v1.18.8 k3s1

Looking at that, it means we are good to proceed to Lens now. Let us install Lens.

More about K3s can be found at K3s main page and you can extend it to other nodes by following our detailed Deploy Lightweight Kubernetes Cluster in 5 minutes with K3s guide.

Other Kubernetes Installation guides:

Install Production Kubernetes Cluster with Rancher RKE

Install Kubernetes Cluster on Ubuntu with kubeadm

Easily Setup Kubernetes Cluster on AWS with EKS

Installation of Lens Kubernetes Dashboard & IDE

To install Lens, you can either download a pre-built package from the releases page or you can be also install it via snapcraft (Linux only). I am on Manjaro and will use the snapcraft way. If you are on windows, visit the link abpve and download the windows version and since it is already pre-built, it is pretty easy to install.

Enable snapd

--- Arch Linux / Manjaro ---
sudo pacman -S snapd

--- Ubuntu / Debian ---
sudo apt update
sudo apt install snapd

--- CentOS ---
sudo yum install epel-release
sudo yum install snapd

Once installed, the systemd unit that manages the main snap communication socket needs to be enabled as folows:

sudo systemctl enable --now snapd.socket

To enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap:

sudo ln -s /var/lib/snapd/snap /snap

Reboot your machine to ensure all paths are updated accordingly.

Once your pc is back up install Lens by simply running the following command:

sudo snap install kontena-lens --classic

If you are on on Mac, the following command is enough to get Lens installed.

brew cask install lens

You can now start Lens like other graphical applications and you should see an interface as shown below:

Kubernetes Cluster Access with Lens

By default, lens looks for ~/.kube/config file which contains information on how it will connect to a Kubernetes cluster. In our server where K3s is installed, the kubeconfig file stored at /etc/rancher/k3s/k3s.yaml is used to configure access to the Kubernetes cluster.

To access the Cluster from Lens which is installed on your personal computer (Linux, Windows or macOS), copy /etc/rancher/k3s/k3s.yaml on your machine located outside the cluster as ~/.kube/config. So I fetched /etc/rancher/k3s/k3s.yaml from the server, created .kube directory and copied the file into it and renamed it to config.

On server

sudo cp /etc/rancher/k3s/k3s.yaml /home/tech
sudo chown tech:tech /home/tech/k3s.yaml

On your local computer

$ cd ~
$ mkdir .kube
$ cd ~/.kube
$ sftp [email protected]
sftp> get k3s.yaml

Press Ctrl d to exit

$ mv k3s.yaml config

Then I replaced “localhost” with the IP or name of the K3s server. The contents of the file looks like below:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJWekNCL3FBREFnRUNBZ0VBTUFvR0NDcUdTTTQ5QkFNQ01DTXhJVEFmQmdOVkJBTU1HR3N6Y3kxelpYSjIKWlhJdFkyRkFNVFU1T0RZek56Y3dOakFlRncweU1EQTRNamd4T0RBeE5EWmFGdzB6TURBNE1qWXhPREF4TkRaYQpNQ014SVRBZkJnTlZCQU1NR0dzemN5MXpaWEoyWlhJdFkyRkFNVFU1T0RZek56Y3dOakJaTUJNR0J5cUdTTTQ5CkFnRUdDQ3FHU000OUF3RUhBMElBQkdDVXY2WHRoQ2lGRVQySEowNm5ac1d5aFN4UTBvNmZ4NlBhNGJnc21qcmQKNUZzcThvNUt0UEUrTW92UjRhNERIdy9aZDh1TkNlSmNRb2lVRXByYms4V2pJekFoTUE0R0ExVWREd0VCL3dRRQpBd0lDcERBUEJnTlZIUk1CQWY4RUJUQURBUUgvTUFvR0NDcUdTTTQ5QkFNQ0EwZ0FNRVVDSUdaSTBNU3hteXN6ClppbFYwQWY2RzB6Ri8zOW1LWEdQTytYQ3VxK2E2L1FEQWlFQXFtbU93WFlXbWtPVGZONEF3eUg1ZjRaVDR1ZVkKY1dwVFVxQmtSdWMrM1RJPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
    server: https://192.168.121.108:6443
  name: default
contexts:
- context:
    cluster: default
    user: default
  name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
  user:
    password: 1f9472d132670bd38c14c44ae7c8b415
    username: admin

Change server: https://192.168.121.108:6443 to point to the server where K3s is installed. Make sure port 6443 is accessible from outside as well.

Launch Lens

Once all of your configs are looking good, it is time to launch lens and attempt to connect to our K3s cluster. The first page should look like below. Click on the sign to add a cluster.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-1-1024×557.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="557" loading="lazy" src="data:image/svg xml,” width=”1024″>

A page similar to the one illustrated below will be presented. On the drop-down labelled Kubeconfig, click on the arrow and you should see default automatically discovered.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-2-add-cluster-1024×561.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="561" loading="lazy" src="data:image/svg xml,” width=”1024″>
<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-s-add-default-config-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

If it is not discovered by default, choose Custom and paste the contents similar to the one shown above on the text area that will be presented below it. Once done, click on “Add Cluster“. If all goes well, your cluster details will appear as shown below.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-4-cluster-dashboard-1-1024×560.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="560" loading="lazy" src="data:image/svg xml,” width=”1024″>

In case you see the message “Metrics are not available due to missing or invalid Prometheus configuration…” simply right click cluster icon (big ) and click on “settings“.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-5-click-settings-1-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

Once there, install metrics and choose Lens as the Prometheus installation method. That will deploy a prometheus pod to handle metrics.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-6-install-metrics-feature-and-choose-lens-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

The dashboard should be populated with pretty statistics and graphs after some few seconds.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-page-7-metric-available-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

View Nodes

To view your nodes, simply click on your cluster and hit on the “Nodes” Menu provided.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-nodes-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

View Workload

The workloads tab has sub-menu items such as as Pods, Deployments, DaemonSets and others as you can view from the interface.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-workload-overview-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

View Network Resources

Similarly, under “Network” tab, there are exhibited the Endpoints, Ingresses and Network Services. Every configured service will be visible herein as well.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-network-services-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

View Pods and their Logs

Being able to view pods’ logs without logging into the terminal of your cluster makes Lens stand out. Simply click on “Pods” which is under “Workloads.” From there, you should see all of your pods and on the far right of each pod, there are 3 vertical dots. Clicking on each pops out other menu items including “Logs, shell, Edit and delete.”

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-workload-pod-choose-logs-shell-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

Access Node Shell

From Lens interface, you can access node’s shell conveniently. Click on “Nodes” and on the far right of each of your nodes, click on the three vertical dots and choose shell. A terminal should be opened as shown below where you can issue urgent commands without leaving Lens.

<img alt="" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/Lens-open-node-terminal-1024×576.png" data-ez ezimgfmt="rs rscb8 src ng ngcb8 srcset" height="576" loading="lazy" src="data:image/svg xml,” width=”1024″>

Last Remarks

As we have already highlighted, Lens is a standalone application for MacOS, Windows and Linux operating systems. It is like any other application in your favorite Operating System. It can run on your Laptop or PC and then connects to your Kubernetes cluster for visibility, real time statistics, log streams and hands-on troubleshooting as we have briefly seen. As usual, this guide is not exhaustive because Lens offers much more. Other details about Lens can be found at Lens Kubernetes IDE main webpage.

Learning materials:


<img alt="Kubernetes for the Absolute Beginners – Hands-on" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/1602900_f550_8.jpg5f4ce451aaaad.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>

<img data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/icon_udemy-com.png5f4ce451b3333.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>Udemy.com


<img alt="Certified Kubernetes Administrator (CKA) with Practice Tests" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/2301254_26c8_2.jpg5f4ce45239335.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>

<img data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/icon_udemy-com.png5f4ce451b3333.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>Udemy.com


<img alt="Learn DevOps: The Complete Kubernetes Course" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/1007250_9e3c_5.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>

<img data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/icon_udemy-com.png5f4ce451b3333.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>Udemy.com


<img alt="Docker and Kubernetes: The Complete Guide" data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/1793828_7999.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>

<img data-ezsrc="https://kirelos.com/wp-content/uploads/2020/08/echo/icon_udemy-com.png5f4ce451b3333.jpg" ezimgfmt="rs rscb8 src ng ngcb8" src="data:image/svg xml,”>Udemy.com

To conclude, we continue to appreciate your support and we hope this guide was helpful. Check below for much more.

Deploy Lightweight Kubernetes Cluster in 5 minutes with K3s

Install Kubernetes Cluster on Ubuntu 20.04 with kubeadm

Top Minimal Container Operating Systems for running Kubernetes

Install and Use Helm 3 on Kubernetes Cluster

Easily Manage Multiple Kubernetes Clusters with kubectl & kubectx

Deploy Production Ready Kubernetes Cluster with Ansible & Kubespray