Kubernetes Lens Dashboard - Practical Installation and Usage Guide

Step-by-step practical tutorial on installing and using Kubernetes Lens Dashboard for cluster management, deployment operations, and pod troubleshooting

Hello Deployment Example

Download the YAML configuration file for the hello deployment example

Download hello-deployment.yaml

Install Lens Dashboard

Lens is a free dashboard app that you can install on Windows, Mac and Linux.

Windows (Chocolatey):

choco install lens

macOS (Brew):

brew install --cask lens

Launch Lens

You should be connected to your cluster on Docker Desktop. If not, you can add it or another cluster by:

  1. Clicking on the hamburger menu
  2. Selecting Add Cluster
  3. The clusters that are already present in the config file will be listed in the dropdown menu

Deploy the App

kubectl create -f hello-deployment.yaml

Creates the deployment with 3 replicas as defined in the YAML file.

Lens Dashboard

Open the Workloads menu and look at the pods, deployments and replications.

Delete a Pod Using the UI

Select one of the pods and delete it either by clicking on the ellipse icon or the Delete icon at the bottom of the screen. You'll notice that the pod will be replaced almost immediately.

Open a Terminal

At the bottom of the screen, you will see a link called Terminal. Click on it to open the built-in terminal.

Delete a Pod Using the Terminal

kubectl delete pod [podName]

Copy one of the pod names and delete it using the terminal.

Cleanup

kubectl delete -f hello-deployment.yaml

Deletes all resources defined in the YAML configuration file.

YAML Configuration File

apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-dep
  namespace: default
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  selector:
    matchLabels:
      app: hello-dep
  template:
    metadata:
      labels:
        app: hello-dep
    spec:
      containers:
      - image: gcr.io/google-samples/hello-app:1.0
        name: hello-dep
        ports:
        - containerPort: 8080

YAML Configuration Explanation:

Deployment Structure:

  • apiVersion: apps/v1 → Specifies the Kubernetes API version for Deployments
  • kind: Deployment → Defines this as a Deployment resource
  • metadata.name: hello-dep → Names the deployment "hello-dep"
  • namespace: default → Places the deployment in the default namespace

Deployment Spec:

  • replicas: 3 → Creates 3 identical pod instances
  • strategy.type: RollingUpdate → Uses rolling update strategy for deployments
  • rollingUpdate.maxSurge: 1 → Allows 1 extra pod during updates
  • rollingUpdate.maxUnavailable: 1 → Allows 1 pod to be unavailable during updates
  • selector.matchLabels.app: hello-dep → Selects pods with label app=hello-dep

Pod Template:

  • metadata.labels.app: hello-dep → Labels the pods with app=hello-dep
  • spec.containers → Defines the container specifications
  • image: gcr.io/google-samples/hello-app:1.0 → Uses the hello-app sample image
  • name: hello-dep → Names the container "hello-dep"
  • containerPort: 8080 → Exposes port 8080 on the container

How It Works:

This deployment creates 3 replicas of a simple hello-app container. The RollingUpdate strategy ensures that updates happen gradually without downtime. If a pod is deleted (either manually or due to failure), the deployment controller will automatically create a new one to maintain the desired 3 replicas.