DEV Community

chauhoangminhnguyen
chauhoangminhnguyen

Posted on • Originally published at howtodevez.blogspot.com

Setting up Kubernetes Dashboard with Kind

Introduction

In a previous article, I guided you through using Helm to deploy on Google Kubernetes Engine. However, if you want to cut down costs by using Kubernetes in your local environment instead of relying on a cloud provider during development, then Kind is your go-to.

There are several tools to help set up Kubernetes locally, such as MiniKube, Kind, K3S, KubeAdm, and more. Each tool has its own pros and cons. In this article, I'll walk you through using Kind to quickly set up a Kubernetes cluster on Docker. Kind stands out for its compactness, making Kubernetes start up quickly, being user-friendly, and supporting the latest Kubernetes versions.

Helm Kind K8s

Working with Kind

Firstly, follow the instructions here to install Kind according to your operating system.

If you're using Ubuntu, execute the command:

[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
Enter fullscreen mode Exit fullscreen mode

After successfully installing Kind, you can check its version with the following command:

Kind version

To create a cluster, use this command:

kind create cluster --name {cluster name}

# ex
kind create cluster --name local
Enter fullscreen mode Exit fullscreen mode

Kind create cluster

Use Helm to set up the Kubernetes Dashboard

The Kubernetes Dashboard is a tool for managing Kubernetes clusters with an easy-to-use web UI.

First, add the Kubernetes Dashboard repository:

helm repo add {repo name} https://kubernetes.github.io/dashboard

# ex
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard
Enter fullscreen mode Exit fullscreen mode

Next, install the chart:

helm upgrade --install {release name} k8s-dashboard/kubernetes-dashboard --create-namespace -n {namespace}

# ex
helm upgrade --install kubernetes-dashboard k8s-dashboard/kubernetes-dashboard --create-namespace -n kubernetes-dashboard
Enter fullscreen mode Exit fullscreen mode

Please note that you need to successfully create a Kubernetes cluster before you can install a Helm chart.

-n {namespace}: Setting a namespace is optional, but organizing resources by namespace can be helpful, especially if you need to install multiple Helm charts.

Once you've successfully installed the Helm chart, the result will be as follows:

Helm upgrade

You can check if the resources were created successfully like this:

kubectl get all -n {namespace}

# ex
kubectl get all -n kubernetes-dashboard
Enter fullscreen mode Exit fullscreen mode

kubectl get all

Next, forward the port for the service so it can be accessed from localhost.

kubectl port forward

As a result, you can access the Kubernetes Dashboard like this:

K8s dashboard

To generate a token, create a file named service-account.yml with the following content:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
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: kube-system
Enter fullscreen mode Exit fullscreen mode

Apply to Create Resources:

kubectl apply

Next, generate a token like this:

Generate token

Use that token to login to the Kubernetes Dashboard.

K8s dashboard homepage

See you again in the next articles!


If you found this content helpful, please visit the original article on my blog to support the author and explore more interesting content.

BlogspotBlogspotDev.toFacebookX


Some series you might find interesting:

Top comments (0)