Managing Kubernetes Clusters with Lens
Best K8s Dashboard & IDE for DevOps
7 min read
In this blog, we will learn about Lens. Lens is the best Kubernetes Dashboard and Integrated Development Environment (IDE). Lens is rightly popularised as "The Kubernetes Platform".
Before diving into the ins and outs of the Lens IDE, it is strongly recommended to learn a bit about Kubernetes and related technologies. Here's an amazing video resource on Youtube which can be watched before learning about Lens:
Kubernetes Tutorial for Beginners | What is Kubernetes? Architecture Simplified!
Video Credits : Kunal Kushwaha
What is Lens?
Lens is the largest and most advanced Kubernetes platform in the world. It is an application that helps us to have a better look into our k8 clusters. It doesn't matter if the K8 cluster is on a local machine or it's on the cloud, Lens has got your back with all things Kubernetes. Here are a few features of Lens :
- Most powerful tools for developers who want to engage with Kubernetes daily via Lens Desktop
- We can make sure that our clusters are set up correctly and configured as per our requirements.
- You can increase the visibility to see what is going on inside our clusters
- We can get Real-Time Statistics
- Add your Dashboards & Charts ( Lens, Prometheus, etc. )
- Generate Logs
- Access to many hands-on troubleshooting tools
- Great collaborative features so that developers can connect like Cluster Connect
- Open Source and Free
- ) Removes Complexities
- ) Easy access to Cloud-Native Tech Stacks like Helm, Prometheus, etc
- ) Easy Deployment
If someone is starting with K8s and want to jump straight in into the practical aspects to get to know what it is all about, Lens IDE is the best resource to use. Even a beginner can delve into Kubernetes and K8S clusters without worrying about the technical complexities of the technology. For eg, There is no need to write big YAML files or venture into CLI commands. Lens does a lot of things for us in this aspect.
For more information on Lens IDE, visit their website : Lens
Now that we know a little something about our friendly new IDE, let's download it for ourselves! Visit their website Lens, select your Operating System and download Lens Desktop. Once downloaded, install the same. Once it is installed, we can run the application on our systems
First time using the Lens IDE, we'll have to create our user and log in to the platform. I'd recommend using our GitHub account to log in.
This is how the home page looks :
As we can see. there is a catalog with a few links that we can follow. On the left panel, if we select "Clusters" then it will show our available K8S clusters :
Here, the minikube cluster is running on the local machine while the kube-demo cluster is running on Cloud. The Cloud Provider used for the scope of this blog is Civo. It is a cloud-native service provider which is blazing fast, simple to use, and surprisingly cheap for the services that they are providing. A question may arise, why are we even using a Cloud provider? Isn't our local machine enough? The simple answer is, that it depends on the K8S cluster. When working with multi-node systems, we would need cloud services as we would not be able to host and manage multiple nodes on our local machine.
For more information on Civo, visit their website: Civo
Here's the kube-demo cluster on the Civo Dashboard :
Let's get a bird's eye view of our cluster through Lens IDE, Simply clicking on the cluster will start it and the clusters can also be pinned to the left sidebar for ease of access. This sidebar is known as "Hotbar" and it makes it extremely easy to switch between running clusters. We can then click on this icon to open a dashboard that has all the statistics :
Two Clusters running at the same time on the Hotbar
Context-Aware Terminal : There's an in-built terminal in the application. We can run the following command for each of our clusters :
For local cluster :
For Cloud cluster :
As we can see both clusters have different Git Versions. Lens is pointing to the correct cluster API endpoint. Since the clusters are running in different environments, this is different for different clusters and the terminal reflects this on its own.
By default, for the local machine, Lens IDE refers to the kube config file which has the information about how the application will connect to the K8S cluster :
Lens gives us options to review the information for every single node of our cluster and also run node shell for commands.
Node Shell (to run commands)
Workload categorizes all the Kubernetes objects that we are running on a cluster.
There are a lot of features offered by Lens for pods. They can be organized using namespaces, filtered according to pod data, logs, etc.
Clicking on any pod displays more information related to that pod :
Similar layouts can be found for more Workload objects like Deployments. DaemonSets and Jobs. This interface makes it extremely easy to manage clusters.
An overview of workloads can also be viewed with information represented visually :
Configurations, Network & Storage
Similar to an app, we use configurations to store data in the form of key-value pairs which is essential to running the clusters. We can also have secret data. Similarly, we can view and edit network-related data like I.P. Addresses and Port numbers. We also have the storage option which lists all the storage classes, volumes, and related data like capacity and the path. All this is available via the Lens Application without having to program it ourselves.
Creating new resources for existing Clusters
Let's try to create a new pod. From the terminal bar, click the '+' symbol and select 'Create Resource'. Select Template as 'Pod'. Click 'Create & Close'. This will create the new pod which can be checked in the pod menu. Make sure you're on the correct namespace. Similarly, other resources can be created like deployments, daemonSets, etc. Resources can also be scaled as per requirements.
Creating cluster on Civo
Now let's create a new cluster on Civo and explore it via Lens. On your Civo Dashboard, Click on "Create new Cluster". It gives a self-explanatory and easy-to-understand form to create a cluster. You can play around with the settings and the marketplace as per the requirements and when you're ready, click on 'Create Cluster'. The Civo services are very fast and the cluster should be created in under 90 seconds.
Now let's add this cluster to Lens. From the file menu, select 'Add Cluster' or press 'Ctrl+Shift+A'. For the connection, we will download the kubeconfig file from Civo. Copy the file and paste it into Lens 'Add Cluster' section and this will connect our cluster with our IDE. We can also mention the config data in the default config file.
Nodes created on Civo:
Download the kube config file from the cluster dashboard on Civo.
Open this file and copy paster in the Add Cluster section of Lens.
This will add the cluster to Lens. Click on the cluster to connect it as it would be disconnected initially. You can also add it to the Hotbar for quick access.
The new cluster is added to Lens and connected:
Now that we have our cluster on the Lens Platform, we have endless options to configure and manage our clusters and nodes as per our needs. We can enable metrics from the settings, use Prometheus for charts, and even share the clusters via Cluster Connect for collaborative development.
Closing Thoughts and Future scope
As we saw, our life was made so easy by Lens when it comes to using and managing everything Kubernetes. It is an extremely popular platform and will only gain use in the near future. Not having to write big YAML files also saves a lot of time and effort and increases developer experience. Many things related to Lens are yet to be explored and we would definitely recommend our readers to play around with this environment as much as possible. Supporting and Contributing to Lens should also be our radars.
- Blog based on Video by Kunal Kushwaha : Managing Kubernetes Clusters with Lens
- Blog Cover from Lens Website Homepage : Lens
Did you find this article valuable?
Support WeMakeDevs by becoming a sponsor. Any amount is appreciated!