Headlamp is a new open source tool by Kinvolk, created to visualise Kubernetes clusters in a modern way. The biggest highlight of it is "Extensibility". Headlamp is extensible by the concept of Plugins, which means you can create your own plugins and use them with Headlamp to make it yours.
As mentioned in the official documentation, "Plugins are one of the key features of Headlamp". They allow users to modify what, and how, information is displayed, as well as other functionality. The ultimate goal of the plugins system is to allow vendors to build and deploy Headlamp with extra functionality without having to maintain a fork of the project. More information on how to build and use plugins can be found here
Headlamp can be installed within the cluster to access it over the internet or it can also be installed as an application. In this tutorial we will install Headlamp in a Civo managed K3s cluster and go through its features.
Note: This guide is not a comparison with other existing cluster visualisation tools. instead it's a walkthrough of the installation and some features that Headlamp provides.
- A Kubernetes cluster you control. We'll take advantage of Civo's super-fast managed K3s service to experiment with this quickly.
- kubectl installed, and the
kubeconfigfile for your cluster downloaded.
Make sure you can connect to your Kubernetes cluster by running
$ kubectl get nodes NAME STATUS ROLES AGE VERSION kube-node-97b7 Ready <none> 4d v1.18.6+k3s1 kube-master-e72e Ready master 4d v1.18.6+k3s1 kube-node-c532 Ready <none> 4d v1.18.6+k3s1
You should see the names of the nodes in your cluster displayed similar to above.
Step 1: Service account and ClusterRoleBinding Creation
Run the following commands to create the service account, the binding, and to acquire a secrets token ID.
$ kubectl -n kube-system create serviceaccount headlamp-admin serviceaccount/headlamp-admin created $ kubectl create clusterrolebinding headlamp-admin --serviceaccount=kube-system:headlamp-admin --clusterrole=cluster-admin clusterrolebinding.rbac.authorization.k8s.io/headlamp-admin created $ kubectl -n kube-system get secrets | grep headlamp-admin headlamp-admin-token-kzv5t kubernetes.io/service-account-token 3 13s
Make note of the token as this will be used to login to the Headlamp dashboard:
kubectl -n kube-system describe secret headlamp-admin-token-kzv5t
Step2: Install Headlamp
This creates a Headlamp deployment and service:
kubectl apply -f https://raw.githubusercontent.com/kinvolk/headlamp/master/kubernetes-headlamp.yaml service/headlamp created deployment.apps/headlamp created kubectl get pods -n kube-system | grep headlamp headlamp-7c54bdf8c9-cz5pj 1/1 Running 0 95s kubectl get svc -n kube-system | grep headlamp headlamp ClusterIP 192.168.169.23 <none> 80/TCP 109s
Step 3: Create ingress
By default, Civo K3s clusters will come with Traefik as an ingress controller, so we will simply use that here. Run the following, but make sure to change the your-cluster-id in the host line to match your cluster's DNS entry (which you can see on the cluster administration page):
$ cat << EOF | kubectl apply -f - pipe heredoc> apiVersion: extensions/v1beta1 kind: Ingress metadata: name: headlamp namespace: kube-system spec: rules: - host: headlamp.<your-cluster-id>.k8s.civo.com http: paths: - backend: serviceName: headlamp servicePort: 80 EOF ingress.extensions/headlamp created
Let's make sure that we have a working ingress, by running:
$ kubectl get ing -n kube-system | grep headlamp headlamp <none> headlamp.fb54c6ea-e9a5-4bda-8a05-e68115ac21d0.k8s.civo.com 220.127.116.11 80 46s
If you see output like above, you will be able to connect to the Headlamp interface at the ingress URL you defined.
Step 3: Open the Headlamp UI
We will be using the token login, so enter the token from the headlamp secret from step 1 above.
The initial cluster overview gives the for CPU Usage, Memory Usage and Pods, the events are also listed below.
You can have different views of your cluster, such as Namespaces, Nodes, etc.
You can have an overview of all Nodes in the cluster, and detailed view for each node, with information about the labels, annotations and system information as well.
You can also edit the Node directly from the UI :
Workload section - It gives the list of workloads that are deployed to the cluster. You can view and edit this section directly from the UI as well:
Storage view - It gives the view of Storage classes, Persistent volumes and PVC:
Network view - It gives the view for services and ingress:
Security Section - It gives the view of Service Account, Roles, RoleBindings and Secrets
Overall, Headlamp presents simple UI, while the aggregated view gives a fresh look to the eyes.
Oops, I nearly forgot to mention the DARK MODE. Yes, Headlamp comes with a dark mode as well:
Give Headlamp a try, and let us know how it compares to any other Kubernetes visualisation tools you may have used!