Try   HackMD

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. If we downloaded the Lens we can see the Lens like this figure.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Step2 Add Kubernetes Cluster

If we press the “add icon” on left side, we can see this page.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

We can see our status of nodes on Lens.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Create object

We can use Lens to create object, without using kubectl apply -f xxx.yml. First we need to write the yaml file.

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".

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Press "Create".

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

We can see the Pod and Deployment.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

After we can execute to the container.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

We can just slide it to scale up our Pod.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

And it will sucess.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

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/簡單實用的kubernetes-ide-lens-d8bba1fc06ad