Skip to content

Lens (Mirantis)

Lens is a graphical tool to help navigate within a cluster. It is useful as it integrates performance metrics (cpu, ram etc) as well as easy access to Pods.

Assuming the cluster is behind Gateway Device on its own subnet this page shows how to port forward the k8s API Server on port 6443 to the Ansible host so that Lens can attach to the cluster.

This project will add 127.0.0.1 SAN to the allowed addresses in the k8s API Server certificate. This is done to allow port-forwarded connections to the cluster, assuming the (Anisble) host has the k8s config file.

Copy the k8s config file from the k8s-control-plane node

mkdir ~/.kube/
scp ubuntu@k8s-control-plane-node:/home/kube/.config ~/.kube/cluster.home.config -o "ProxyCommand ssh ubuntu@cluster.home -W %h:%p"

Edit kubeconfig file and replace the cluster IP address (eg: ) with 127.0.0.1.

nano ~/.kube/cluster.home.config

Port forward from the Ansible host to the k8s-control-plane-node via the Gateway Device

ssh ubuntu@cluster.home -L 6443:k8s-control-plane-node:6443 -o "ProxyCommand ssh ubuntu@cluster.home -W %h:%p"`

Check kubectl can access the cluster

export KUBECONFIG=~/.ssh/cluster.home.config
kubectl get ns

NAME              STATUS   AGE
default           Active   3m56s
kube-node-lease   Active   3m57s
kube-public       Active   3m57s
kube-system       Active   3m57s

Now add this config file to Lens and it should be able to connect so long as the 6443 port forward is in place.

Metrics

https://docs.k8slens.dev/faq-technical/#why-i-dont-see-any-metrics-or-some-of-the-metrics-are-not-working