What is OpenLens and why should we install it?
OpenLens is the open-source core of Lens, the most popular Kubernetes IDE (Integrated Development Environment) on the market. Think of it as an extremely powerful visual control panel that allows you to manage multiple clusters without having to rely exclusively on the command line (kubectl).
Why install it?
- Real-Time Visibility: Forget about constantly running
kubectl get pods -w. OpenLens shows you the status of your resources instantly. - Simplified Management: You can deploy, edit, and scale applications with just a few clicks.
- Easier Troubleshooting: It allows you to access container logs and open terminals inside pods directly and visually.
- Metrics Integration: As we will see later, it integrates perfectly with Prometheus to show performance graphs without leaving the application.
3. OpenLens Installation and Configuration on Windows
3.1 Install OpenLens with Chocolatey
- If you don’t have Chocolatey installed on your Windows system yet, you must install it first. Open PowerShell as administrator and run:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- Once Chocolatey is installed, install OpenLens using the following command in PowerShell (as administrator):
choco install openlens
- Wait for the installation to complete. OpenLens should be available in the Windows Start menu.
3.2 Configure OpenLens to connect to the cluster
-
Start OpenLens
-
If you have correctly saved the kubeconfig file in
C:\Users\<your-user>\.kube\config, OpenLens should automatically detect your cluster -
If it doesn’t detect it automatically:
- Click on “File” -> “Add Cluster”
- Browse for the kubeconfig file you saved
- Click on “Add Cluster”
-
If you still can’t, you can always copy the content and provide it to OpenLens
-
Now you should see your cluster in the list on the left
-
Click on it to connect and manage it
3.3 Explore the OpenLens interface
- Main Dashboard: Provides an overview of the cluster status
- Workloads: Shows pods, deployments, statefulsets, etc.
- Network: Shows services, ingresses, etc.
- Storage: Shows volumes, claims, etc.
- Configuration: Shows configmaps, secrets, etc.
- Nodes: Shows detailed information about the nodes
3.4 Configure metrics in OpenLens
To visualize performance metrics in OpenLens, we must configure Prometheus and the metrics service:
- Install the metrics-server in the cluster:
# On the master node
sudo kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml --kubeconfig /etc/rancher/k3s/k3s.yaml
# Edit the deployment to add the flag that allows insecure certificates
sudo kubectl edit deployment metrics-server -n kube-system --kubeconfig /etc/rancher/k3s/k3s.yaml
- In the editor that opens, pray it’s not vim, add
--kubelet-insecure-tlsto the container arguments underspec.template.spec.containers[0].args. Look for theargs:section and add the line. It should look something like this:
ATTENTION!: If it is vim, try to type something; let’s say when the file opens you are viewing it but not editing it.
args:
- --cert-dir=/tmp
- --secure-port=10250
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
- --kubelet-use-node-status-port
- --metric-resolution=15s
- --kubelet-insecure-tls # Add this line
-
Save and close the editor (if you are using vim, press ESC and then type
:wqand Enter). -
Verify that the metrics-server is working:
sudo kubectl get deployment metrics-server -n kube-system --kubeconfig /etc/rancher/k3s/k3s.yaml
-
Now, in OpenLens, configure Prometheus for advanced metrics:
- Open OpenLens
- Select your cluster
- Go to “Cluster Settings” (gear icon in the bottom left)
- Click on the “Metrics” tab
- In “Prometheus Service Address”, enter:
http://prometheus-kube-prometheus-prometheus.monitoring.svc.cluster.local:9090 - Click on “Save”
-
If everything is configured correctly, you will now be able to see metric graphs in:
- The cluster overview page
- The nodes page
- The pods page
- Other resource pages
With this, you will have CPU, memory, network, and disk metrics directly integrated into the OpenLens interface, making monitoring easier without having to constantly switch to Grafana.