Cloud Resource
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Dashboard

Embarking on a journey with Kubernetes? You’ll need the Kubernetes Dashboard as your trusted co-pilot. The Dashboard, a user-friendly, web-based interface, is indispensable for deploying containerized applications, troubleshooting application issues, and managing cluster resources on Kubernetes. In this guide, we’ll provide you with step-by-step instructions on how to deploy and access the Kubernetes Dashboard, empowering you to effectively manage your Kubernetes cluster. Let’s dive right in!

Deploying Kubernetes Dashboard v2.7.0 and v3.0.0-alpha0: A Comparative Guide

The Kubernetes Dashboard is a powerful, user-friendly interface designed to streamline the management of your Kubernetes environment. Over time, the Kubernetes Dashboard has evolved, with each version offering enhancements, additional features, and improvements. In this article, we’ll explore the deployment processes for two versions: v2.7.0 and the pre-release version v3.0.0-alpha0, to provide an in-depth understanding of their differences and help you decide which version is most suited for your needs.

The Kubernetes Dashboard v2.7.0 is a stable version that offers a comprehensive set of features for managing your applications, inspecting and managing cluster resources, and adjusting cluster settings. It’s an excellent choice if you’re looking for a reliable, tried-and-tested tool to simplify your Kubernetes management tasks.

On the other hand, v3.0.0-alpha0 represents the next generation of the Kubernetes Dashboard. Although it’s still in the alpha stage of development, this version promises several exciting new features and enhancements over v2.7.0. Deploying this version could give you a head-start in experiencing and learning these new features. However, given its alpha status, it may have bugs or incomplete features, which makes it a less suitable choice for production environments.

Both versions can be deployed using a resource descriptor from the Kubernetes GitHub repository, which describes all the necessary components to set up the Dashboard in your Kubernetes cluster.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml

Or

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v3.0.0-alpha0/charts/kubernetes-dashboard.yaml

Setting Up a Service Account and Cluster Role for the Kubernetes Dashboard: A Practical Guide

Navigating the Kubernetes environment often necessitates various levels of access and permissions. For an effective and secure management of resources, Kubernetes leverages the Role-Based Access Control (RBAC) authorization mechanism. To interact with your Kubernetes Dashboard, you’ll need to set up a Service Account and a Cluster Role. In this post, we will guide you through the creation of these components.

A Service Account in Kubernetes provides an identity for processes running in a Pod. In this context, we are creating a Service Account named ‘admin-user’ in the ‘kubernetes-dashboard’ namespace. This account will be used to interact with the Kubernetes Dashboard.

In addition to a Service Account, Kubernetes uses ClusterRoles for defining permissions over a group of resources. The ‘cluster-admin’ ClusterRole, which we’re binding to our ‘admin-user’ Service Account, is a super-user role that gives full control over every resource in the cluster.

This guide will provide a step-by-step process on how to create a YAML file for the Service Account, another for the Cluster Role Binding, and then use kubectl to create these resources in your Kubernetes cluster. Please remember that, in a production environment, granting such broad permissions should be done judiciously, following the principle of least privilege.

Stay with us as we walk through each step in detail, providing clear explanations and useful tips along the way. With this guide, setting up your Service Account and Cluster Role for the Kubernetes Dashboard will be a breeze.

cat <<EOF |tee dashboard.admin-user.yml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
EOF
cat <<EOF |tee dashboard.admin-user-role.yml
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-dashboard
EOF
kubectl create -f dashboard.admin-user.yml -f dashboard.admin-user-role.yml

Create manifest file for Kubernetes Dashboard v3.0.0-alpha0 Ingress

cat <<EOF |tee kubernetes-dashboard-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    cert-manager.io/issuer: selfsigned
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  generation: 1
  labels:
    app.kubernetes.io/name: nginx-ingress
    app.kubernetes.io/part-of: kubernetes-dashboard
  name: kubernetes-dashboard
  namespace: kubernetes-dashboard
spec:
  ingressClassName: nginx
  rules:
  - host: k3s.yourdomain.com
    http:
      paths:
      - backend:
          service:
            name: kubernetes-dashboard-web
            port:
              name: web
        path: /
        pathType: Prefix
      - backend:
          service:
            name: kubernetes-dashboard-api
            port:
              name: api
        path: /api
        pathType: Prefix
  tls:
  - hosts:
    - k3s.yourdomain.com
    secretName: kubernetes-dashboard-certs
EOF

And apply YAML

kubectl apply -f kubernetes-dashboard-ingress.yaml

Change dashboard network to nodeport - optional

kubectl --namespace kubernetes-dashboard patch svc kubernetes-dashboard -p '{"spec": {"type": "NodePort"}}'

Get node service port - optional

kubectl get svc -n kubernetes-dashboard kubernetes-dashboard -o yaml

Get auth token

kubectl -n kubernetes-dashboard create token admin-user

For NodePort connection: https://192.168.0.248:port

For URL connection: https://k3s.yourdomain.com