Here is a way to install a minimalist kubernetes UI - Headlamp.
A simple way of installing it is using yaml files, like this one:
kind: Service
apiVersion: v1
metadata:
name: headlamp
namespace: kube-system
spec:
ports:
- port: 80
targetPort: 4466
selector:
k8s-app: headlamp
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: headlamp
namespace: kube-system
spec:
replicas: 1
selector:
matchLabels:
k8s-app: headlamp
template:
metadata:
labels:
k8s-app: headlamp
spec:
containers:
- name: headlamp
image: ghcr.io/headlamp-k8s/headlamp:latest
args:
- "-in-cluster"
- "-plugins-dir=/headlamp/plugins"
ports:
- containerPort: 4466
livenessProbe:
httpGet:
scheme: HTTP
path: /
port: 4466
initialDelaySeconds: 30
timeoutSeconds: 30
nodeSelector:
'kubernetes.io/os': linux
---
kind: Secret
apiVersion: v1
metadata:
name: headlamp-admin
namespace: kube-system
annotations:
kubernetes.io/service-account.name: "headlamp-admin"
type: kubernetes.io/service-account-token
This will install a deployment named headlamp
in kube-system
namespace, a service to expose the UI, and a secret for the admin user.
Next, we can expose the UI using nginx like bellow:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: headlamp-ingress
namespace: kube-system
spec:
ingressClassName: nginx
tls:
- hosts:
- headlamp.example.dev
secretName: example-tls
rules:
- host: headlamp.example.dev
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: headlamp
port:
number: 80
Take note of the host name - in this example headlamp.example.dev
and the corresponding TLS certificate (example-tls
)
Then, generate a service account:
kubectl -n kube-system create serviceaccount headlamp-admin
Give it admin rights in the kubernetes cluster:
kubectl create clusterrolebinding headlamp-admin --serviceaccount=kube-system:headlamp-admin --clusterrole=cluster-admin
And then create a token for the login:
kubectl create token headlamp-admin -n kube-system
If everything it’s ok, the UI should load :
Documentation and links:
- Headlamp documentation - https://headlamp.dev/docs/latest/installation/in-cluster/#using-helm