# Useful Kubernetes IDE - Lens
###### tags: `Kubernetes`
## Foreword
> Lens is an open source IDE. It is a tool to manage Kubernetes. It’s can let we see our object of kubernetes on Lens.
## Installation Guide
### Step1 Download Lens
> We can download Lens on its [official site](https://k8slens.dev/). If we downloaded the Lens we can see the Lens like this figure.

### Step2 Add Kubernetes Cluster
> If we press the “add icon” on left side, we can see this page.

> Then we need to add the config to Lens. Let Lens connect to the kubernetes cluster.
>
> Now we use `cat /etc/kubernetes/admin.cfg` to copy the admin.cfg to Lens from master node.

> And press "Add Cluster". We will see our cluster show on the Lens.

## Lens Setting
> After that we can go to the setting and install the Metrics on our Lens. It will help us to monitor our nodes.

> We will see the Namespaces "lens-mertics", Pod ,and Deployment etc.

> We can see our status of nodes on Lens.

## Create object
> We can use Lens to create object, without using `kubectl apply -f xxx.yml`.
> First we need to write the yaml file.
```yaml=1
apiVersion: v1
kind: Namespace
metadata:
name: demo
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo
namespace: demo
labels:
app: demo
spec:
replicas: 1
selector:
matchLabels:
app: demo
template:
metadata:
labels:
app: demo
spec:
containers:
- name: demo
image: nginx
ports:
- containerPort: 80
```
> Press "Create resource".

> Press "Create".

> We can see the Pod and Deployment.

## Execute And Log
> In the past, we need to use `kubectl exec -it xxxx -- bash` to execute to the container. Now, wecan just press the "pod shell" buttom to execute the container.

> After we can execute to the container.

> If we need to see the Log we can press the buttom next to Pod shell to see the Pod's Log.

## Scale Up
> If we want to scale up the Pod, we need to use `kubectl scale -n demo --current-replicas=1 --replicas=10 deployment.apps/demo` to scale up.
> Now we can press the "scale" buttom to scale up.

> We can just slide it to scale up our Pod.

> And it will sucess.

## Summary
> There are many useful tools on Lens such like Configmap, Secret, and PVC etc. Maybe you can try it by yourself.
## Reference
> https://k8slens.dev/
>
> https://medium.com/@tasslin/%E7%B0%A1%E5%96%AE%E5%AF%A6%E7%94%A8%E7%9A%84kubernetes-ide-lens-d8bba1fc06ad