
Dashboard is an open-source web-based GUI for managing Kubernetes clusters. It allows you to manage cluster resources, deploy applications, monitor and troubleshoot cluster performance, all through a web-based management interface. The Kubernetes Dashboard manages multiple resources and cluster workloads, including CronJobs, DaemonSets, Deployments, Pods, ReplicaSets, and StatefulSets, allowing you to deploy applications and monitor clusters in real time.
This article explains how to deploy the Kubernetes Dashboard, manage cluster resources using its web interface, and install an Ingress Controller to expose it securely.
Before you start, you need to:
You can install the Kubernetes Dashboard using the official Helm repository. Follow the steps below to add a new Helm repository to your configuration and install the Kubernetes Dashboard to your cluster.
Add the Kubernetes Dashboard repository to your local Helm configuration.
Update your local Helm configuration.
Install the Kubernetes Dashboard in your cluster using Helm.
Check all installed components in the kubernetes-dashboard namespace.
From the output, verify that the Kubernetes Dashboard Pods, Services, and ReplicaSets are available and active.
The Kubernetes Dashboard, by default, includes a minimal RBAC configuration and supports user login with bearer tokens. Every user needs a valid bearer token to access the Kubernetes Dashboard. Follow the steps below to create a new administrative service account and enable access to the Kubernetes Dashboard.
Create a new dashboard-admin-user.yml file using a text editor of your choice, like nano.
Add the following YAML configurations to the dashboard-admin-user.yml file.
Save and close the dashboard-admin-user.yml file.
The above configuration creates a new dashboard-admin-user service account and a cluster role binding that enables it to manage the cluster using the Kubernetes Dashboard.
The dashboard-admin-user ClusterRoleBinding references the cluster-admin role. This grants the highest privileges and full control over your entire cluster. Create a more restrictive Role or ClusterRole for production use.
Apply the configuration file.
Create a new bearer token for the dashboard-admin-user service account to use when accessing the Kubernetes Dashboard.
Copy the generated string from your output to later use as a login Bearer token.
You can access the Kubernetes Dashboard after deploying it to your cluster using port forwarding or installing an Ingress Controller to attach a load balancer with a public endpoint to your cluster. This section covers accessing the Kubernetes Dashboard using port forwarding.
The kubernetes-dashboard-kong-proxy service, which was created when you installed Kubernetes Dashboard, provides an HTTPS endpoint to access the Kubernetes Dashboard. Forward the kubernetes-dashboard-kong-proxy service port 443 to port 8443 on your local workstation.
If using a remote cloud server to manage your Kubernetes cluster, follow the steps below.
Allow the forwarded port through the firewall if it's active.
Reload the firewall to apply the change.
Forward the kubernetes-dashboard port 443 to 8443 to access the Kubernetes Dashboard using your instance's public IP address.
Your output should be similar to the one below when successful.
Visit your remote server's IP address or localhost (if managing Kubernetes locally) using https in a web browser like Chrome.
Or
Accept the insecure connection warning when prompted to access the Kubernetes Dashboard.
Paste the dashboard-admin-user token you generated earlier and click Sign in to access the Kubernetes Dashboard.
Verify the status of all workloads in the default namespace.
Click the namespace selector on the top navigation bar next to Kubernetes and select kubernetes-dashboard from the list.
Verify the status of all workloads in the kubernetes-dashboard namespace and monitor the active Deployments, Pods, and ReplicaSets.
Click Nodes within the Cluster group on the main navigation menu and verify the resource usage statistics for all nodes in your cluster.
Running the Kubernetes Dashboard using a public endpoint may expose your cluster to multiple threats. Installing an Ingress Controller lets you secure the Kubernetes Dashboard with a trusted TLS certificate and access it over HTTPS. Follow the steps below to install the Nginx Ingress Controller in your cluster and generate trusted TLS certificates using cert-manager to secure access to the Kubernetes Dashboard.
Press Ctrl + C to stop port forwarding in your terminal.
Install Nginx Ingress Controller.
Add the Nginx Ingress Controller Helm repository.
Update your Helm repositories.
Install the Nginx Ingress Controller in your cluster using Helm.
Wait a few minutes for the Nginx Ingress Controller to deploy and attach a load balancer to your cluster. Then, list all services in the ingress-nginx namespace.
Verify the EXTERNAL-IP address assigned to your ingress-nginx LoadBalancer service and update your domain's DNS records to this IP value.
Install Cert-Manager.
Add the Jetstack repository to your local Helm configuration.
Update your local Helm configuration.
Install cert-manager and all required CRDs in your Kubernetes cluster.
List all installed resources in the cert-manager namespace and verify if they are up and running.
Create a ClusterIssuer resource to generate a TLS certificate for enabling a secure HTTPS connection to the Kubernetes Dashboard.
Create a new issuer.yml manifest file to specify the Let's Encrypt ClusterIssuer configuration.
Add the following manifest to the file. Replace admin@example.com with your active email address.
Save and close the file.
The above configuration creates a new ClusterIssuer resource that uses the Let's Encrypt CA to complete domain challenges and generate trusted TLS certificates.
Apply the ClusterIssuer manifest file.
List all ClusterIssuers and verify that tls-certificate-issuer is available.
Output:
Patch the ingress-nginx-controller ConfigMap to allow the newer version of cert-manager to complete its domain verification. This is required because a strict setting in Nginx can block the automatic process cert-manager uses to prove you own the domain, which prevents it from issuing the TLS certificate.
Create a new dashboard-ingress.yml file to specify the Kubernetes Dashboard Ingress configuration.
Add the following Ingress manifest to the file. Replace dashboard.example.com with your actual domain name.
Save and close the file.
The above configuration creates a new Ingress resource in the kubernetes-dashboard namespace that forwards all incoming requests from dashboard.example.com to the kubernetes-dashboard-kong-proxy service port 443.
Apply the dashboard-ingress.yml manifest to your cluster to create the Ingress resource.
Verify the TLS certificate status.
Output:
It may take some time for the certificate's READY state to turn True.
List all Ingress resources in the kubernetes-dashboard namespace and verify that dashboard-ingress is available.
Output:
Access your dashboard.example.com domain in a new web browser window.
You can deploy applications through the Kubernetes Dashboard by applying YAML configurations or filling in application details in the web-based interface. Follow the steps below to deploy a sample Nginx application in your cluster by specifying the resource details in a form using the Kubernetes Dashboard.
Create another subdomain A record pointing to your Ingress Controller's external IP address. For example, sample-app.example.com.
Open the Kubernetes Dashboard.
Enter your dashboard-admin-user token when prompted to log in to the Kubernetes Dashboard.
Click + in the top right corner to create a new resource configuration.
Navigate to the Create from form tab to specify the application information.
Enter the application name in the App name field. For example, sample-app.
Enter a public container URL in the Container Image field. For example, nginxdemos/hello to pull from DockerHub.
Click the Service drop-down and select Internal from the list.
Enter the service's network port details, including:
80.80.Click the Namespace drop-down and select the target namespace to deploy the application, such as default.
Click Deploy to apply the application configuration to your cluster.
Monitor the application's deployment progress on the Workloads page, then navigate to Pods and verify that all pods are running.
Navigate to Services and verify that the sample-app service is available.
Click Create new resource to set up a new Ingress configuration for your application.
Add the following manifest to the Create from input field.
This Ingress configuration forwards incoming traffic from sample-app.example.com to the sample-app service on port 80. The tls-certificate-issuer automatically generates a new TLS certificate for the sample-app.example.com domain if it's pointing to the Ingress Controller's public IP address, enabling secure TLS connections to the application.
Click Upload to apply the Ingress configuration to your cluster.
Navigate to Ingresses on the main navigation menu.
Verify that the new Ingress resource is available and points to your domain.
Click the Ingress resource name to view its additional information or modify the configuration.
Open the sample-app.example.com domain in your web browser.
Verify that the sample Nginx application displays with the active pod's internal IP in your browser.
Click Auto Refresh to automatically reload the application to verify that traffic is actively load-balanced to all pods in your cluster.
In this article, you deployed the Kubernetes Dashboard in your cluster and exposed it securely using the Nginx Ingress Controller. You can now use the Kubernetes Dashboard to deploy applications, manage your cluster, and create additional resources. For more information and configuration options, visit the Kubernetes documentation.
0 Comments
Be the first to comment and share your perspective with the community.