# 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. ![](https://i.imgur.com/0Ko89oL.png) ### Step2 Add Kubernetes Cluster > If we press the “add icon” on left side, we can see this page. ![](https://i.imgur.com/yVkLLQk.png) > 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. ![](https://i.imgur.com/5e2MVOK.png) > And press "Add Cluster". We will see our cluster show on the Lens. ![](https://i.imgur.com/hp4uWoC.png) ## 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. ![](https://i.imgur.com/5RTELYM.png) > We will see the Namespaces "lens-mertics", Pod ,and Deployment etc. ![](https://i.imgur.com/j5KEsyR.png) > We can see our status of nodes on Lens. ![](https://i.imgur.com/Q1PiXwR.png) ## 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". ![](https://i.imgur.com/rSQHqrD.png) > Press "Create". ![](https://i.imgur.com/TYMwhjW.png) > We can see the Pod and Deployment. ![](https://i.imgur.com/XgbwE1b.png) ## 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. ![](https://i.imgur.com/fgWMIlP.png) > After we can execute to the container. ![](https://i.imgur.com/Mseg3R5.png) > If we need to see the Log we can press the buttom next to Pod shell to see the Pod's Log. ![](https://i.imgur.com/muOvN7s.png) ## 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. ![](https://i.imgur.com/n2nO5C6.png) > We can just slide it to scale up our Pod. ![](https://i.imgur.com/yjzYd2v.png) > And it will sucess. ![](https://i.imgur.com/gem3CoO.png) ## 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