# Lens Installation with LensSpaces

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Lens is by far the best Kubernetes Management tool available. However, now they made it a Pro version which has a monthly/ yearly subscription attached to it. First, the 15-day trial version is still available !!</div>
</div>

Download the Latest Lens from the [official](https://k8slens.dev/) website and Install it

If you are using Lens in the same network where Kubernetes is installed probably all you need to do is just copy over the *.kube/config* to C:/users/&lt;username&gt;.

In this location create that /.kube folder and copy over the config file here.

Now, close the Lens application if it is already open and also set the environmental variable of KUBECONFIG = c:/users/&lt;username&gt;/.kube/config with the following command

```bash
setx KUBECONFIG "C:\Users\<username>\.kube\config"
```

Close the cmd prompt, reopen the command prompt and type

```bash
echo %KUBECONFIG%
```

This will provide you with the result of the path that we set.

Now open the Lens Application, Click on the Browse your local catalog

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699092264146/20d4be98-72fc-4a07-a717-93a9cd2b5f4e.png align="center")

It will autodetect to the K8s cluster which is in the same network and get it connected to it.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699092314137/8a04e582-d980-4bda-8367-ac8506b4dbb9.png align="center")

Now if your Kubernetes Cluster is on Cloud VMs and you want to connect to you. The fastest way to achieve the solution is to use the LensSpaces.

Click on the top right-hand corner where it shows your laptop/computer name

In the DropDown Select **Create a Space**

It will ask you to name the space. Give a name all in small letters without spaces and click on Create.

Now, it will open the settings page, in that click on the ClusterConnect --&gt; Tokens as shown below

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699092605964/e5213d33-9569-4a2f-9181-7b69dbdeb259.png align="center")

Click on the Generate Token

Provide the name of the Kubernetes Cluster as per your cluster

Location as US

Click on Connect. it will provide you a YAML file with sha key in the kubectl apply format.

Click on the Copy, in inorder to copy the command the big long command and run on the master node. It will automatically, create pods, network policy, svcs, metrics pod etc.

Now go back to the Catalog menu, In which you can see that Kubernetes is getting connected. Just in a few minutes, you will observe that the Kubernetes will be connected to Lens

Now, you can delete pods, observe the metrics of the pods, namespaces, RAM etc. of each node

Lastly, Click on the **Cluster Name**

It will bring up the drop down menu , in which click on the settings,

Now as you are connected,

Click on the Lens Security Center, Click on the **Enable Trivy Operator**

Just give an ideal count of **10** and click on **the Apply** button**.** This will automatically install and run the Trivy Operator in the Cluster.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1699093153579/48d3fe03-69f6-4c6c-9fd0-35b127e745da.png align="center")

Now Click on the Lens Metrics in the Menu

## **Lens Metrics**

**PROMETHEUS**

**Enable bundled Prometheus metrics stack** ON

**KUBE STATE METRICS**

**Enable bundled kube-state-metrics stack** ON

**NODE EXPORTER**

**Enable bundled node-exporter stack** ON

and click on the Apply button

wait for some time, it will load and bring up all these pods

Now, go to Metrics in the MENU

Observe that it says, autodetected the Prometheus on the cluster with some additional information.

That's All, you got a new lens configured and connected with metrics
