As you probably saw, just few days ago we released Kontena Lens as a stand-alone product that can be used on virtually any Kubernetes cluster. Kontena Lens provides all of the necessary tools and technology for taking control of your Kubernetes clusters. Ensure your cluster has been properly set up and configured. Enjoy increased visibility and hands-on troubleshooting capabilities.

In this tutorial we’re going to set up Kontena Lens on top of your local Minikube Kubernetes “cluster”.

Step 1. Install kubectl client tooling

We’ll be using kubectl to both validate our fresh minikube setup and to install Kontena Lens, so it needs to be installed first. Follow the official guide to set it up on your OS.

Step 2. Install Minikube

In this tutorial, I’m running Minikube on my local macOS laptop with VirtualBox, hence the example commands are for macOS. Refer to official Minikube installation docs for further details and examples on how to install it on other operating systems and/or virtualization platforms.

Setting up Minikube on macOS is super easy with Homebrew:

$ brew cask install minikube

That’s all you need to get minikube tooling in place.

Kontena Lens comes with lots of additional tooling for monitorability of the cluster so it requires a bit more resources. We need to create the cluster with bit more capacity than the default 2G RAM. Let's start Minikube with 4G RAM like this:

$ minikube start --memory=4g

In a few minutes you should have your local minikube up-and-running.

Verify that minikube tooling has set up the local client configuration to point to your newly created local cluster:

$ kubectl config current-context
minikube

To verify everything has booted up properly, check that all of the pods are actually running by issuing:

$ kubectl get pod --all-namespaces

Step 3. Install Kontena Lens

First we need to download Kontena Lens installer manifests for minikube. I’m using wget but you can use your favorite tooling.

$ wget https://lens-installer.kontena.io/latest/minikube.yaml

To be able to configure Kontena Lens dashboard ingress rules properly we need to dig up our minikube IP address with:

$ minikube ip

Take a note of the IP address in the output.

Next we need to modify the Lens installation manifests to match the current IP address shown in the output above. In my case the IP address is 192.168.99.101, so I need to configure the ingress host to host: lens.192.168.99.101.nip.io. In my case, the configmap should look like this:

apiVersion: v1
kind: ConfigMap
metadata:
  name: kontena-lens-installer
  namespace: kube-system
  labels:
    k8s-app: kontena-lens-installer
data:
  lens.yml: |-
    name: mini-lens
    ingress:
      host: lens.192.168.99.101.nip.io
      tls:
        enabled: false
    persistence:
      enabled: true
    metrics:
      persistence:
        enabled: true

There’s no need to modify other parts of the manifests.

To initiate Kontena Lens installation, simply apply the manifest:

$ kubectl apply -f minikube.yaml

The installation runs as a job within the cluster and might take a minute or two to finish. Check that the job has completed without any errors:

$ kubectl -n kube-system get job kontena-lens-installer
NAME                     COMPLETIONS   DURATION   AGE
kontena-lens-installer   1/1           22s        106s

Once the installation job has finished, it’ll take a few minutes to bootstrap all of the components in the cluster. You can check the progress and status with:

$ kubectl get pod --all-namespaces

You’ll see that there are a couple of additional namespaces created for Lens components and quite a few pods running the additional functionality for monitorability.

Step 4. Accessing Lens dashboard

The installer will create a lens-admin ServiceAccount that has administrator rights to the cluster. To fetch the lens-admin user token, see the installer logs:

$ kubectl logs -n kube-system -l k8s-app=kontena-lens-installer

Logs should end with instructions on how to access the Kontena Lens UI.

Example log output:

    No authentication configuration set, skipping.
    Installing Kontena Stats components ...
    Removing Ingress Probe ...
==> Lens is now installed! (took 3 seconds)
    Post-install message from Kontena Lens UI components:
      Kontena Lens UI is configured to respond at: https://lens.192.168.99.101.nip.io
      Starting up Kontena Lens the first time might take a couple of minutes, until that you'll see 503 with the address given above.
      
      You can login to Kontena Lens as admin with a ServiceAccount token that can be fetched with the following command:
      kubectl -n kube-system get secrets lens-admin-token-lvv9p -o jsonpath="{.data.token}" | base64 --decode

So, if you issue the last command:

$ kubectl -n kube-system get secrets lens-admin-token-lvv9p -o jsonpath="{.data.token}" | base64 --decode

You should get the token you can use to login to Lens dashboard.

Now open your browser to the address you used for the ingress hostname in the installation manifests. To login use the access token you got from the service account token.

kontena_lens_dashboard

Step 5. Obtain a license

Kontena Lens comes with an evaluation license valid for 14 days with full functionality. After you have evaluated Lens and want to purchase a valid license, navigate to https://account.kontena.io/licenses. Once you have purchased a valid license, you can assign it to the cluster by using the “Assign License” button on cluster overview. Just copy-paste the license key you got when purchasing the license.

kontena_lens_license_assign

What's next

We're always super happy to hear any feedback regarding Lens, so go ahead and join the discussion on our Slack channel. If you hit any snags during the installation, give us a shout on the Slack and we'll help you out.

Stay tuned for similar tutorials for GKE, EKS and other Kubernetes installations.