Lens

From G1Joshi/Agent-Skills · View interactive version

Lens is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert Lens (Kubernetes IDE) assistance covering cluster visualization, pod metrics, log viewing, helm release management, and RBAC auditing. Use when operating and troubleshooting Kubernetes clusters via GUI.

How to use this skill

Skill file

Lens Desktop

Lens is an intuitive Kubernetes desktop IDE that simplifies cluster monitoring, pod troubleshooting, log inspection, and multi-cluster navigation.

When to Use

Quick Start

# Add active kubeconfig context to Lens desktop application:
# File > Add Cluster > Select from local ~/.kube/config

Core Concepts

Unified Multi-Cluster Kubeconfig Management

Configuring Lens to track multiple cloud and on-premise clusters via aggregated kubeconfig:

# Merge multiple cloud kubeconfigs into a dedicated Lens catalog file
export KUBECONFIG=~/.kube/config:~/.kube/prod-eks.yaml:~/.kube/staging-gke.yaml
kubectl config view --flatten > ~/.kube/lens-clusters.yaml

# Set permissions and launch Lens with target kubeconfig
chmod 600 ~/.kube/lens-clusters.yaml

Lens cluster catalog entry in ~/.k8slens/clusters.json:

{
  "clusters": [
    {
      "id": "prod-us-east-1",
      "name": "Production EKS US-East",
      "kubeConfigPath": "~/.kube/lens-clusters.yaml",
      "contextName": "arn:aws:eks:us-east-1:123456789012:cluster/prod-us-east",
      "prometheus": {
        "type": "prometheus-operator",
        "service": "monitoring/prometheus-k8s:9090"
      }
    }
  ]
}

Lens Metrics & Prometheus Operator Integration

Configuring Prometheus ServiceMonitor to feed live node and pod metrics into Lens:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: lens-metrics-collector
  namespace: monitoring
  labels:
    release: prometheus-stack
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: kube-state-metrics
  endpoints:
    - port: http-metrics
      interval: 15s

Automated Pod Log Export & Shell Diagnostics

```bash

# Inside Lens pod shell: inspect process tree and open network sockets

ps aux

netstat -tuln

curl -I http://localhost:8080/healthz

```

Common Patterns

Multi-Cluster Kubeconfig Management

Problem: Managing distinct credentials for dozens of Kubernetes clusters.

Solution: Merge multiple cluster configs into a unified directory watched by Lens.

# Merge multiple kubeconfigs
export KUBECONFIG=~/.kube/config:~/.kube/prod-cluster.yaml:~/.kube/staging-cluster.yaml
kubectl config view --flatten > ~/.kube/all-clusters.yaml
# Add ~/.kube/all-clusters.yaml to Lens Catalog

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| :----------------------------------- | :---------------------------------------------------------------------- | :------------------------------------------------------------------------- |

| Metrics not showing in Lens charts | Prometheus not installed or Lens cluster metrics settings unconfigured. | Right-click cluster > Settings > Metrics > Select Prometheus provider. |

| Cluster state shows Disconnected | API server unreachable or certificate expired in kubeconfig. | Refresh kubeconfig token via cloud CLI (e.g. aws eks update-kubeconfig). |

| Lens CPU / Memory usage high | Monitoring multiple high-pod clusters simultaneously. | Close inactive cluster workspaces in Lens drawer. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.