rancher / k3os

Purpose-built OS for Kubernetes, fully managed by Kubernetes.
https://k3os.io
Apache License 2.0
3.5k stars 403 forks source link

How to Install Kubernetes Dashboard on k3os #535

Open aanjaneyam opened 4 years ago

aanjaneyam commented 4 years ago

I am absolutely new to kubernetes, k3s or rancher. I have read the guides for k3s and k3os. However, I was a bit confused as how to install the kubernetes dashboard - the graphical user interface on k3os/kubernetes OS. Is the process to install the dashboard on k3os the same as k3s as described in the link below or there is a different process for k3os?

https://rancher.com/docs/k3s/latest/en/installation/kube-dashboard/

On a side note is the kubernetes dashboard the only comprehensive UI available or is there any other better UI providing more features.

I believe, since k3os is a complete packaged ready made solution for kubernetes on small devices, it may be a good idea to integrate a web based graphical user interface in the k3os like minikube does, thus eliminating the need to install it separately.

zimme commented 4 years ago

Using that guide should work just fine on k3os as far as I can tell.

What I've been doing instead though, is creating a folder kubernetes-dashboard in /var/lib/rancher/k3s/server/manifests which contains the following files. This could be done using the write_files directive in the k3os cloud-init config or manually as I do it currently in my home lab.

00-namespace.yml

apiVersion: v1
kind: Namespace
metadata:
  name: kubernetes-dashboard

01-kubernetes-dashboard.yml

apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
  namespace: kube-system
  name: kubernetes-dashboard
spec:
  chart: kubernetes-dashboard
  repo: https://kubernetes.github.io/dashboard
  targetNamespace: kubernetes-dashboard

02-kubernetes-dashboard-admin.yml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: <username>
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: <username>
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: <username>
  namespace: kubernetes-dashboard

Replace <username> with whatever username you want for the admin user.

The helm-controller will now deploy kubernetes-dashboard and then you can access the dashboard using the following commands.

Get the token to use for login. Replace <username> in the following command.

kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep <username> | awk '{print $1}')

Start the proxy

kubectl proxy

Open the following link in your browser.

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login

As for the question of other UI's for kubernetes, Rancher would be the obvious one 😝 Other than that I think portainer is going to focus on kubernetes going forward but I don't think that is available today.

Maybe k3os could deploy a default webui, however as there are choices and it's not that hard to deploy yourself I'm not sure it should be baked in. However I don't work at rancher so I'll leave that decision ut to them 😄

aanjaneyam commented 4 years ago

@zimme Many thanks for detailed, clear and simple reply. I did some research and yes guess what I discovered rancher server too as an UI option. Looks promising, I am contemplating the below as I am only running it on my developer laptop for home use, learning and testing (along with learning ins and outs of k3s cli)

https://rancher.com/docs/rancher/v2.x/en/installation/other-installation-methods/single-node-docker/

Since this is home use I plan to use rancher server as an agent too for running docker containers (which are different to k3os containered CRI containers). Docs say it is not recommended but I believe running rancher server as an agent would give me more with less resources.

docker run -d --restart=unless-stopped \
  -p 8080:80 -p 8443:443 \
  -v /opt/rancher:/var/lib/rancher \
  rancher/rancher:latest

And then add k30s two node cluster. I hope the above works

So the whole setup is (All using qemu kvm virtual machines based) k3sserver with docker container runtime and rancher server and rancher-agent installed on it (Alpine Linux) K3os-master01 with the default containerd (k3os as master01)- to be managed by rancher server above. (k3os) K3os-agent-01 with the default containerd (k3os as agent01) - to be managed by rancher server above. (k3os)

For rancher server I intend to uses k3s with docker as container runtime using the following commands :

curl https://releases.rancher.com/install-docker/19.03.sh | sh
&&
curl -sfL https://get.k3s.io | sh -s - --docker

Hope I am going in the right direction to set up rancher as GUI and kubernetes cluster as a whole as described above.

Yeah you are right portainer is not yet there.

Any differences between Kubernetes dashboard and Rancher server? Give the fierce competition between them and they both are being actively developed.

zimme commented 4 years ago

The biggest difference between kubernetes-dashboard and Rancher would be that k8s-dashboard is only a ui for a single cluster and Rancher is for single or multiple clusters. But I'm not too sure if k8s-dashboard is limited to single cluster management.

dweomer commented 4 years ago

@aanjaneyam I would also recommend the Rancher UI but I might be biased :smiling_imp: