The Kubernetes IDE: K8s Lens

Sandeep Kumar
8 min readSep 23, 2022

Introduction

Kubernetes (also known as k8s) is open-source system for production-grade container orchestration which automates container deployment, scaling and management of containerized application. It was designed by Google but now it is managed by Cloud Native Computing Foundation (CNCF). It orchestrate the containers’ runtime which are compliant with Container Runtime Interface (CRI) like Docker, Containerd and CRI-O. Kubernetes has been delivered for local, on-premise, private cloud and public cloud. The major cloud providers like AWS, GCP, Azure, IBM, Oracle, RetHat, VMware etc. offers Kubernetes-based platforms or Infrastructure as-a Service (IaaS) which allows to deploy Kubernetes.

Kubernetes provides two clients to manage the components deployed on Kubernetes control plane:

  1. Kubectl CLI — Kubectl is a CLI tool available for different OS like Linux, Windows and macOS. It provides a set of commands and switches to manage the K8s components e.g. to enquire running pods run kubectl -n mynamespace get pod
  2. Kubernetes Dashboard UI —It is a web-based user interface which is also installed in K8s only. It provides interactive interface which can be used for information and K8s component management

Although K8s already provides two ways to interact with K8s cluster to manage K8s components. But both are not very user friendly. Since Kubernetes is a complex orchestration platform which provides a huge number of features so it has a large number of commands provided by kubectl which need to remembered by the users. Similarly, the K8s Dashboard UI has limitations.

Most of the Cloud providers provide their own user interface to manage the K8s cluster like Azure provides own web-based interface which can be used to monitor and manage K8s cluster. Similarly, an independent client is also required for those users who want to manage K8s cluster from local machine with a very interactive user interface.

K8s Lens is ‘freeware’ product (Note: now, paid version also available with additional features and support) which provides a desktop application to manage the K8s cluster.

About Lens

K8s Lens is a desktop application available for OS like Windows, Linux, macOS. It has been offered as open-source product by Mirantis and used by hundred thousands of users.

Lens provides user interface to see the cluster and its components and K8s resources.

It provides following features/resource management from GUI:

  1. Cluster management — Add/modify cluster, monitor cluster

2. Node Management - Monitor, modify nodes

3. Workload Management — It provides sub-menus for different workload resources like Pods, Deployments, StatefulsSets, ReplicaSets, Jobs, CronJobs. Each sub-menus provides list and monitoring of resources and can be restarted, modified easily with buttons and editors

4. Config Management —It provides sub-menus for configuration related resources like ConfigMap, Secrets, Resource Quotas, Limit Ranges, HPA etc. These resources can be monitored and modified

5. Network Management —It provides sub-menus for Network related resources like services, Endpoints, Ingress, Network Policies, Port Forwarding etc. It also list, monitoring and modifying user interfaces

6. Storage Management —It provides sub-menus for managing storage related resources like Persistent Volume Claim, Persistent Volume and Storage class. It also provides editing and listing of resources

7. Namespace Management — Namespaces can be listed and edited

8. Event Management — List the events

9. Helm Chart and Release Management — It list the available charts (based on added repositories) which can be installed, uninstalled from the user interface buttons

10. Access Control — It provides sub-menus for access control resources like services accounts, cluster roles, roles, Cluster role binding, role binding, Pod security policies

11. Custom Resource Management — It provides listing and modification of custom resources in K8s

Lens provides a ‘paid’ service called ‘Team Workspace’ which can be used to create team workspace and invite and add team members. Team allows to manage cluster remotely by its members from Internet hosted service.

Additional features also provided by Mirantis as part of Lens supported products like:

Lens Teamwork — Team spaces can be created, invited team members and manage cluster very smoothly.

Lens Security — It provides container image scanning and CVE scanning.

Lens Kubernetes — It provides advance Kubernetes distro fully integrated with Lens

Lens Support — Support for Lens services

Use Case

To use K8s Lens, you must have Kubernetes cluster as prerequisite.

To setup Kubernetes Cluster for testing, you can download ‘Minikube’ or ‘Docker for Desktop’ and setup Kubernetes cluster.

We have setup a Kubernetes Cluster using ‘Docker for Desktop’ for use case purpose. Ensure Kubernetes Cluster is accessible from the machine from where Lens to be used.

Below are the steps for Les setup and use:

  1. Download K8s Lens as per your machine from https://k8slens.dev/index.html. It will download setup e.g. ‘Lens Setup 5.5.4-latest.20220609.2.exe’

2. Install the download setup, Lens will be installed in your machine and you can locate Lens in programs

3. Open Lens on desktop by clicking on it. It will open Lens window

It will ask for ‘Lens ID’, create your Lens ID by clicking on link given at bottom or login with GitHub or Google account.

4. After login with Lens ID, It will open menu to ‘Browse Clusters in Catalog’. It will list the clusters for which configuration is available on machine

Note: To connect with cluster, a configuration file ‘~/kube/config’ is created in current user directory. It contains the cluster configuration like server and key. Although, it is generated by default when ‘Docker for Desktop’ installed on machine. If you are using any other cluster, create file by yourself by providing details like server, client-certificate and client-key. In case of OIDC configuration, provide OIDC details as:

In case cert based authentication:

apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <cert auth data>
server: https://kubernetes.docker.internal:6443
name: docker-desktop
contexts:
- context:
cluster: docker-desktop
user: docker-desktop
name: docker-desktop

current-context: docker-desktop
kind: Config
preferences: {}
users:
- name: docker-desktop
user:
client-certificate-data: <client cert>
client-key-data:<client key>

In case of OIDC based authentication:

apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://<server url>
name: mycluster
contexts:
- context:
cluster: mycluster
namespace: system
user: myuser
name: mycluster

current-context: mycluster
kind: Config
preferences: {}
users:
- name: myuser
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
args:
- get-token
- --oidc-issuer-url=<oidc server url>
- --oidc-client-id=<client id>
- --oidc-client-secret=<client secret>
- --oidc-extra-scope=groups
command: kubelogin
env: null
interactiveMode: IfAvailable
provideClusterInfo: false

5. Once cluster is selected, Lens will show all the components of cluster:

6. Now, click on ‘Nodes’ and click on one of the ‘node’ from node list being shown in ‘Nodes’ pane, it will start showing details and action on node:

Similarly, you can click on each component (e.g. Config -> ConfigMap, Workloads -> Pods, Workloads -> Deployments etc.) and see details and actions:

The allowed actions on each component will be available as button like Edit, Delete, Close buttons.

7. You can also open terminal from Lens:

8. You can also select components and edit as:

On clicking save button, the change will be applied.

9. To create new resource, Lens provide add button, click on add button:

Select the template for the resource:

After modifying the values click on ‘Create & Close’ to create the resource. After creating resource go to the left panel and click on the resource type to see the list of resource.

10. There is a button at top for adding new cluster:

This can also be performed from left top menus:

Additional features:

Team Space: Team Space is a paid service which allows to create team space and adding member to it.

Extensions: Lens provide feature to build and add extension.

Conclusion

K8s Lens provide desktop application to manage K8s cluster. It provide interactive Graphical User Interface (GUI) for listing, monitoring and modifying K8s cluster resources. The applicable actions like restart, delete, edit on resources are available as button.

K8s Lens is much easy and users can manage cluster without remembering various kubectl commands. Lens is becoming popular among developers who focus on development instead giving much focus on cluster management commands. K8s Lens is provided as ‘freeware’ (as per license file) so no need any cost to bear for normal desktop based use.

It also provides paid services for easy cluster management by using Team Workspace and Support.

Reference

--

--

Sandeep Kumar

Sandeep Kumar holds Master of Computer Application, working as Technical Architect having 11+ years of working experience in banking, retail, education domains.