K8s Lens IDE on AWS/ACI EKS infrastructure

Table of contents

  1. Introduction
  2. What we will show in this article
  3. Get Started with Lens
    1. Install Lens
    2. Onboard your K8s Cluster
      1. Pre-Requisite Setup
      2. Add in your K8s Cluster(s)
    3. Using Lens
  4. References

Introduction

Recently, I was looking into Lens IDE for K8s and found it to be very impressive. What I liked about it most is that it is really simple and can be installed on your desktop (macOS, Windows or Linux) in minutes. After the intial install all you have to do is to onboard your K8s cluster ( on Physical Infrastructure, AKS, EKS, GKE or anywhere else), put in a couple of quick basic configuration parameters and you have a fully working, easy to use IDE for your K8s cluster. You can onboard multiple clusters and switching between them is a one click operation on the UI. You can then view metrics, of your K8s related clusters and deployments, create/delete/edit/visualize all your K8s objects like namespaces, deployments, services etc. You can even shell into any of your pod containers all from the UI. You can read more about Lens at: https://docs.k8slens.dev/main/. If you are not very well versed with K8s, then this will be of great help. If you are well versed with K8s, you will appreciate this even more for it’s simplicity of operations.

What we will show in this article

In this article, I will show how to onboard and use Lens on the ACI/AWS EKS cluster that we deployed based on the writeup at: https://unofficialaciguide.com/2021/12/20/terraform-with-cisco-nexus-dashboard-orchestrator-for-building-hybrid-cloud-and-end-to-end-services/

Please keep in mind that Lens has no bearing on ACI per se. You can install Lens and manage any K8s based cluster. I was in two minds about writing this article because unofficialaciguide.com is really meant to cover ACI and related technologies only. However, I though for folks that are not familiar with Lens, this would really help them out and would be appreciated.

Get Started with Lens

First thing to do is to install Lens. You can install Lens on any desktop, Mac, Linux, Windows.

Install Lens

To install Lens, go to https://k8slens.dev
Download and install the appropriate code based on your OS. A snapshot of the available images are shown below:
file
Figure1: Lens Images available

Onboard your K8s Cluster

Pre-Requisite Setup

Since in this article, we show how to onboard the EKS (AWS K8s), cluster, we need to ensure that we also have AWS CLI installed on the desktop and create the default AWS profile. If you are going to install on physical K8s cluster, you don’t need AWS CLI and AWS profile. For Azure AKS and GCP GKE you will need to perform similar actions. In this example, I am demonstrating on a MAC desktop.

  1. Install AWS CLI, please follow: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
  2. Create AWS default Profile: aws configure --profile tfuser ( # tfuser is the username you created in AWS for this.)
  3. export the profile export AWS_DEFAULT_PROFILE=tfuser and then check that it is working with aws sts get-caller-identity
  4. Install kubectl if not already installed on your desktop. Please follow https://kubernetes.io/docs/tasks/tools/
  5. copy the kubeconfig file to the home directory fo file: ~/.kube/config (in my demo case in the prviious article, I had shown install of EKS cluster from ubuntu jumpbox. I just copied the contents of the ~/.kube/config from ubuntu jumpbox to my mac desktop. If you installed the EKS cluster from your MAC desktop, then the kube config file will already be there)
  6. Modify the kubeconfig file to include the environment for the AWS Profile you created. In the example below, since the AWS default profile was created with name tfuser, I modified my kubeconfig file to include that

file
Figure 2: adding in the env for AWS profile in kube-config

Add in your K8s Cluster(s)
  • open up the Lens app on your desktop. It will ask you if you want to sign in using git or google. That step is optional and if you do that, it will let you share your enviornment with "Lens Spaces". You can skip that step if you wish to

  • Add Cluster. You can either point to your kube-config file by pointing to ~/.kube/config or you can do file/add and paste your kube-config in there. After that click on the submenu connect
    file
    Figure 3: Adding in cluster

  • Right Click on the cluster and click on Settings
    file
    Figure 4: Cluster Settings

  • put in some name that makes sense to you. You can also upload an image for the Icon for that cluster from your desktop. ( I just uploaded an icon for AWS EKS)
    file
    Figure 5: Putting in name of cluster

  • Add to hotbar, so this cluster is available from there
    file
    Figure 6: Adding Cluster to hotbar

  • Now, right click on the cluster name , click Settings and then click on Lens Metrics

file
Figure 7: Going to Settings/Lens Metrics

  • Turn on all the options avaialable here to capture the Lens Metrics
    file
    Figure 8: Turning on Metrics

  • Now click on Metrics and choose Lens for Prometheus
    file
    Figure 9: Turning on Lens for Prometheus

  • Now on top bar, click on Lens and then Extensions
    file
    Figure 10: Extensions Menu

  • Click on available extensions
    file
    Figure 11: Available Extensions

  • Click on Resource Map Extension from the browser tab that opens up
    file
    Figure 12: Resource map

  • Click on the extension name to download it
    file
    Figure 13: Downloading the Resource Map Extension

  • Go back to the lens browser and install the downloaded extension
    file
    file
    Figure 14: Installing the extension

  • once install is done (few minutes) close Lens and reopen. Click on the hotbar to the desired cluster ( you might have installed more than 1 cluster in Lens) and click on resource map. You can choose the namespace, or keep it at All namespaces. You will see the resource map here.
    file
    Figure 15: Looking at Resource Map

Using Lens

Using Lens is really simple and intutive. You just choose your cluster and then click on the menus and do whatever you want to do. Since it’s so intutive, there is no need for me to show you around. I will just point out some basic stuff here.

  • Clicking on Left Menu and choosing your options. In the example below, I show the view from Workload/Overview on one of my clusters
    file
    Figure 16: Workload/Overview

  • Clicking on one of the Pods, shows you more info on the Pod. You can also use the upper bar as shown below to do the appropriate action
    file
    Figure 17: Options for Pods

  • below you can see the edit option for pod
    file
    Figure 18: Editing a pod

  • Below you can see shell to a pod to a particular container (equivalent to kubectl -n <namespace> exec -it <podName> -c <containerName> sh)
    file
    Figure 19: Shell to container in pod

  • To Create a resource ( any K8s resource), hit the + button on the bottom bar and then click on Create resource. A terminal session will open up, where you can type or paste the appropriate yaml file. You can also get the templates for the most commonly used resources so, you can then modify that for your desired resource.
    file
    Figure 20: Creating a resource

References

https://docs.k8slens.dev/main/
https://k8slens.dev
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
https://kubernetes.io/docs/tasks/tool

Go To TOP


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.