Get the latest Kubernetes Dashboard and deploy
GITHUB_URL=https://github.com/kubernetes/dashboard/releases
VERSION_KUBE_DASHBOARD=$(curl -w '%{url_effective}' -I -L -s -S ${GITHUB_URL}/latest -o /dev/null | sed -e 's|.*/||')
sudo k3s kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/${VERSION_KUBE_DASHBOARD}/aio/deploy/recommended.yamlCreate service account and role
In admin-service user.yaml, enter the following values:
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboardIn admin-user-role.yaml, enter the following values:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboardNow apply changes to deploy it to K3S cluster:
sudo k3s kubectl create -f dashboard.admin-user.yml -f dashboard.admin-user-role.ymlExpose service as NodePort to access from browser
sudo k3s kubectl edit svc kubernetes-dashboard -n kubernetes-dashboardIn edit mode change type: ClusterIP to type: NodePort. And save it. Your file should look like below:
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2020-10-27T14:32:58Z"
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
resourceVersion: "72638"
selfLink: /api/v1/namespaces/kubernetes-dashboard/services/kubernetes-dashboard
uid: 8282464c-607f-4e40-ad5c-ee781e83d5f0
spec:
clusterIP: 10.43.210.41
externalTrafficPolicy: Cluster
ports:
- nodePort: 30353
port: 443
protocol: TCP
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}You can get the port number by executing the below command:
sudo k3s kubectl get svc kubernetes-dashboard -n kubernetes-dashboardNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.43.210.41 <none> 443:30353/TCP 3h39mIn my Kubernetes cluster, I received a port number 30353 as shown in the above output. In your case, it might be different. This port is exposed on each worker node and master. You can browse one of your worker node IP addresses with port at the end, and you will see a login page.
Get token of a service account
sudo k3s kubectl -n kubernetes-dashboard describe secret admin-user-tokenIt will output a token in your console. Grab that token and insert it in to token input box.
My Dashboard link: https://192.168.1.21:30353
All done!


