Managing AWS EKS Clusters Locally Using Lens
Tags: kubernetes, opensource, devops, aws
Published: 2023-10-10 14:48:41


Kubernetes has undoubtedly become the go-to container orchestration platform, but managing its clusters can often be complex and tedious. This is where Lens comes in. Often dubbed as the "Kubernetes IDE,".

Lens is more than just a Kubernetes IDE; it's your one-stop-shop for effortless cluster management, offering a unique blend of usability and functionality. The tool shines exceptionally when working with Amazon Elastic Kubernetes Service (EKS), providing an intuitive and user-friendly interface to manage and monitor your clusters. In this article, we'll walk through the steps required to manage an AWS EKS cluster using Lens from a local machine.
![Lens IDE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5bpfp4cwzb2rewog2hur.png)

## Prerequisites
- An active AWS account with the requisite permissions.
- AWS CLI installed and configured
- `kubectl` installed
- EKS cluster up and running
- Lens IDE installed on your local machine

## Step-by-step guide:

### Setting up AWS CLI and Authenticating:
Before we connect Lens to EKS, ensure your AWS CLI is authenticated and has access to the EKS cluster.
```
aws configure
```
Fill in your AWS Access Key ID, Secret Access Key, default region name, and default output format when prompted.
For a more detailed guide on how to setup AWS CLI, you can use [Zacks Blog](https://zacks.one/aws-cli/)

### Setting Up Your EKS Cluster
If you haven't got an EKS cluster running, you can set one up using the `eksctl` tool, as shown below:
```
eksctl create cluster --name my-cluster --region us-west-2 --nodegroup-name my-nodes --nodes 2 --nodes-min 1 --nodes-max 3 --managed
```
Here, my-cluster is your cluster name, and my-nodes is your node group. The cluster will be created in the us-west-2 AWS region with two EC2 instances. Feel free to adjust these as per your needs.

### Installing Lens
You can download Lens from its [official website](https://k8slens.dev/) and follow the installation guide for your respective operating system.

### Connecting the Dots: kubectl and EKS
Before you can manage your EKS cluster with Lens, make sure your `kubectl` is configured to communicate with it. Run the following command to accomplish this:
```
aws eks update-kubeconfig --name my-cluster
```
This will update your Kubernetes configuration file (`~/.kube/config`), paving the way for Lens to connect to your EKS cluster.

### Let's Dive into Lens
#### Connecting Lens to EKS

1. Start Lens: Open the Lens application and navigate to the cluster management view.
2. Add Cluster: Click on the "+" icon to initiate the addition of a new cluster.
3. Select kubeconfig: Choose the updated ~/.kube/config file.
4. Connect: After the cluster loads, hit the "Connect" button.

### Navigating the Interface
Once connected, you'll be greeted with a wealth of options. From nodes, pods, and services to deployments and config maps, Lens makes it easier to manage them all.
![Lens Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uq3zm437iiqu4042ogpf.png)

### Resource Management: CRUD Operations

- Create: Use the "Create" button to upload a YAML configuration file or manually input the YAML data to create a new Kubernetes resource.
- Update: Simply click on the resource you wish to update, make the required changes, and save.
- Delete: To remove a resource, select it and click on the trash bin icon.

### The Lens Advantage: Monitoring & Observability
Lens comes equipped with built-in monitoring features, offering real-time insights into your EKS cluster. Metrics like CPU utilization, memory usage, and disk I/O can be accessed straight from the dashboard.

![Cluster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p91hzqt07wqbeuj0mt1v.png)

### Advance Features
Lens isn't just about monitoring; it's a full-fledged Kubernetes management IDE. You get features like:
- 1. Real-time cluster metrics
- 2. Direct terminal access to nodes and pods
- 3. An extensive catalog of extensions for more functionalities
![Lens Features](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dedb9vy6edenwuy56mij.png)

### Locking It Down: Security Aspects
Lens provides critical security features like Role-Based Access Control (RBAC) and Secrets management to ensure that your EKS cluster is well-secured.

To wrap up, Lens offers a compelling and intuitive way to manage your AWS EKS clusters, making it a must-have tool for anyone in the DevOps, Cloud Computing, or Kubernetes ecosystem. Its ease of setup and rich feature set make it an excellent choice for cluster management.

For further queries or discussion, feel free to drop a comment below. If you found this guide helpful, consider sharing it with your network!