Skip to main content

Monitoring Kubernetes Resources Using the Dashboard

Objective

This lab walks you through the process of using the Kubernetes Dashboard to view and manage Kubernetes resources. This user-friendly web-based GUI facilitates the management and troubleshooting of applications within your minikube cluster.

Prerequisites

Initial Setup

Navigate to the root directory of the python-fastapi-demo-docker project where your environment variables are sourced:

cd ~/environment/python-fastapi-demo-docker

1. Installing the Kubernetes Dashboard

Installl the Kubernetes Dashboard and Metrics Server addons by running:

minikube addons enable dashboard
minikube addons enable metrics-server

Metrics Server collects CPU and memory usage statistics of the pods and nodes, and you can monitor them using the Kubernetes Dashboard.

2. Accessing Kubernetes Dashboard

Use the tabs below to see the steps for the specific environment where you are running this lab.

Expose Kubernetes Dashboard port 80 using host port 8001 by running:

kubectl -n kubernetes-dashboard port-forward --address 0.0.0.0 service/kubernetes-dashboard 8001:80

Execute the command below in a new VScode terminal to show the URL to connect to the Kubernetes Dashboard:

echo "http://$PUBLIC_IP:8001"

Access this URL using your web browser.

3. Viewing Kubernetes resources

Filter Kubernetes resources by the Namespace my-cool-app

This workshop uses the 'my-cool-app' namespace. While the option to view "All namespaces" exists, narrowing down to specific resources streamlines the process. To filter, type the following:

kubernetes-dashboard-1

Subsequently, navigate to 'Workloads' to list relevant resources. With 'metrics-server' enabled, you can also view CPU and memory statistics here.

kubernetes-dashboard-2

Then, press the Pod 'fastapi-deployment' link circled in red.

View the details of the Pod 'fastapi-deployment'

Click on the 'fastapi-deployment' pod to check the spec and status.

kubernetes-dashboard-3

Click the first button from the left of the red frame (top right corner of the dashboard) to check the Pod's container log. You can use this functionality in lieu of the 'kubectl logs' command when using the Kubernetes Dashboard.

kubernetes-dashboard-4

Press the second button from the left of the red frame (top right corner of the dashboard) to log in to the Pod using a shell. You can use this functionality in lieu of the 'kubectl exec' command when using the Kubernetes Dashboard.

kubernetes-dashboard-5

View the details of the Service 'fastapi-service'

Switching to 'Services' in the navigation pane presents a list of created services.

kubernetes-dashboard-6

Press the Service 'fastapi-service' link circled in red to check the spec and status of the Service 'fastapi-service', or check the endpoint pod list to see which requests have been routed.

kubernetes-dashboard-7

View the details of the Node 'minikube'

Exploring 'Nodes' shows the available nodes that have been created. In Minikube's case, typically you'll see the 'minikube' node, because it's a cluster that has only one node.

kubernetes-dashboard-8

Click the Node 'minikube' link circled in red. Here, you can check the node's spec, status, and usage status.

kubernetes-dashboard-9

Conclusion

This lab has provided how to review deployed Kubernetes resources using the Kubernetes Dashboard. You are able to manage and troubleshoot Kubernetes resources with a GUI by using the Kubernetes Dashboard instead of using kubectl commands. By using it, it will be easier to manage workloads in actual production environments.