Table of Contents
- Understanding Kubernetes Management Tools
- Kubernetes Dashboard: The GUI for Visual Management
- 2.1 What is the Kubernetes Dashboard?
- 2.2 Key Features of the Dashboard
- 2.3 Installing the Kubernetes Dashboard
- 2.4 Accessing the Dashboard
- 2.5 Configuring Dashboard Access (RBAC)
- 2.6 Navigating and Using the Dashboard
- 2.7 Troubleshooting Common Dashboard Issues
- Essential Kubernetes CLI Tools
- 3.1
kubectl: The Official Kubernetes CLI- 3.1.1 Installing
kubectl - 3.1.2 Configuring
kubectl(kubeconfig) - 3.1.3 Basic
kubectlCommands - 3.1.4 Advanced
kubectlCommands
- 3.1.1 Installing
- 3.2 Third-Party CLI Tools
- 3.2.1
k9s: Terminal UI for Kubernetes - 3.2.2
kubectx/kubens: Switch Contexts and Namespaces - 3.2.3
stern: Aggregated Logging for Pods - 3.2.4
kubeval: Validate Kubernetes Manifests
- 3.2.1
- 3.1
- GUI vs. CLI: When to Use Which?
- Best Practices for Using Kubernetes Tools
- Conclusion
- References
1. Understanding Kubernetes Management Tools
Kubernetes clusters consist of nodes, pods, deployments, services, and other resources. Managing these manually via raw API calls is impractical. Instead, tools abstract the complexity:
- GUIs (e.g., Kubernetes Dashboard): Visual interfaces for monitoring cluster health, managing resources, and troubleshooting. Ideal for beginners, visual learners, or quick ad-hoc tasks.
- CLIs (e.g.,
kubectl,k9s): Text-based tools for interacting with clusters. Essential for automation, scripting, and advanced operations (e.g., deploying manifests, scaling resources).
Both tools complement each other: the Dashboard offers visibility, while CLIs provide precision and control.
2. Kubernetes Dashboard: The GUI for Visual Management
2.1 What is the Kubernetes Dashboard?
The Kubernetes Dashboard is an official, web-based GUI maintained by the Kubernetes SIG-UI team. It allows users to:
- View cluster resources (pods, deployments, services, etc.).
- Deploy applications via form inputs or YAML/JSON manifests.
- Monitor resource usage (CPU, memory, network).
- Troubleshoot issues (view logs, exec into pods, check events).
2.2 Key Features of the Dashboard
- Resource Visualization: Real-time graphs for CPU/memory usage across nodes and pods.
- Resource Management: Create, edit, or delete deployments, services, config maps, and secrets.
- Troubleshooting Tools: View pod logs, exec into containers, and inspect events (e.g., “pod failed to start”).
- RBAC Integration: Role-based access control (RBAC) ensures users only see resources they’re authorized to manage.
2.3 Installing the Kubernetes Dashboard
The Dashboard is not deployed by default in most Kubernetes clusters. Install it using kubectl:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
This deploys the Dashboard in the kubernetes-dashboard namespace. Verify the pod is running:
kubectl get pods -n kubernetes-dashboard
You should see a pod named kubernetes-dashboard-<random-string> with status Running.
2.4 Accessing the Dashboard
The Dashboard is not exposed publicly by default (for security). Use one of these methods to access it:
Method 1: kubectl proxy (Local Access)
Run kubectl proxy to create a secure tunnel from your local machine to the Dashboard:
kubectl proxy
Access the Dashboard at:
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Method 2: NodePort (Expose on Cluster Node)
For remote access (not recommended for production), edit the Dashboard service to use NodePort:
kubectl edit service kubernetes-dashboard -n kubernetes-dashboard
Change type: ClusterIP to type: NodePort, then save. Find the port:
kubectl get service kubernetes-dashboard -n kubernetes-dashboard
Output (example):
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard NodePort 10.100.234.56 <none> 443:30007/TCP 5m
Access via https://<node-ip>:30007 (replace <node-ip> with your cluster node’s IP).
2.5 Configuring Dashboard Access (RBAC)
By default, the Dashboard denies access without proper authentication. To log in, create a service account with the necessary permissions:
Step 1: Create a Service Account
Save the following as dashboard-sa.yaml:
apiVersion: v1
kind: ServiceAccount
metadata:
name: dashboard-user
namespace: kubernetes-dashboard
Apply it:
kubectl apply -f dashboard-sa.yaml
Step 2: Bind the Service Account to a Cluster Role
Create a cluster role binding to grant admin access (for testing only—use limited roles in production):
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dashboard-user-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: dashboard-user
namespace: kubernetes-dashboard
Apply:
kubectl apply -f dashboard-crb.yaml
Step 3: Get the Access Token
Retrieve the token for the service account:
kubectl -n kubernetes-dashboard create token dashboard-user
Copy the token and use it to log in to the Dashboard via the “Token” option.
2.6 Navigating and Using the Dashboard
Once logged in, the Dashboard displays a cluster overview with:
- Nodes: Health and resource usage of worker/master nodes.
- Workloads: Pods, deployments, stateful sets, and daemonsets.
- Services & Ingress: Network resources exposing applications.
- Config & Storage: Config maps, secrets, and persistent volumes.
Example: Scaling a Deployment
- Go to Workloads > Deployments.
- Select a deployment (e.g.,
nginx-deployment). - Click Scale and adjust the “Replicas” field (e.g., from 2 to 3).
- Click Update—the Dashboard will apply the change, and new pods will spin up.
Example: Viewing Pod Logs
- Go to Workloads > Pods.
- Select a pod (e.g.,
nginx-deployment-abc123). - Click Logs to view real-time container logs. Use the dropdown to switch between containers in the pod.
2.7 Troubleshooting Common Dashboard Issues
- “Access Denied” Errors: Ensure your service account has the correct RBAC permissions.
- Dashboard Pod Not Starting: Check pod events with
kubectl describe pod <pod-name> -n kubernetes-dashboard. - Blank Screen After Login: Clear browser cache or use a different browser (Dashboard uses cookies for sessions).
3. Essential Kubernetes CLI Tools
While the Dashboard simplifies visualization, CLIs are the workhorses of Kubernetes management. Below are the most critical tools for beginners.
3.1 kubectl: The Official Kubernetes CLI
kubectl is the primary tool for interacting with Kubernetes clusters via the API server. It lets you create, inspect, update, and delete resources.
3.1.1 Installing kubectl
-
Linux:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x kubectl sudo mv kubectl /usr/local/bin/ -
macOS:
brew install kubectl -
Windows:
Use Chocolatey:choco install kubernetes-clior download from the official release page.
3.1.2 Configuring kubectl
kubectl uses a kubeconfig file (default: ~/.kube/config) to connect to clusters. Most cloud providers (AWS EKS, GKE, AKS) auto-generate this file when you create a cluster. To verify:
kubectl config view # Show current cluster context
kubectl get nodes # List cluster nodes (should return node info if configured)
3.1.3 Basic kubectl Commands
| Command | Purpose | Example |
|---|---|---|
kubectl get pods | List all pods in the current namespace | kubectl get pods -n default (specify namespace) |
kubectl describe pod <pod-name> | Detailed pod info (events, status) | kubectl describe pod nginx-abc123 |
kubectl create deployment <name> --image=<image> | Create a deployment | kubectl create deployment nginx --image=nginx:1.23 |
kubectl apply -f <file.yaml> | Apply a manifest file | kubectl apply -f deployment.yaml |
kubectl delete pod <pod-name> | Delete a pod | kubectl delete pod nginx-abc123 |
kubectl logs <pod-name> | View pod logs | kubectl logs nginx-abc123 -f (follow logs) |
kubectl exec -it <pod-name> -- /bin/bash | Exec into a pod’s container | kubectl exec -it nginx-abc123 -- /bin/bash |
3.1.4 Advanced kubectl Commands
-
Port-forwarding: Expose a pod port locally:
kubectl port-forward pod/nginx-abc123 8080:80 # Access pod port 80 at localhost:8080 -
Rollbacks: Undo a deployment change:
kubectl rollout undo deployment/nginx-deployment -
Label resources: Add metadata to resources (e.g., for scheduling):
kubectl label pods nginx-abc123 environment=production
3.2 Third-Party CLI Tools
3.2.1 k9s: Terminal UI for Kubernetes
k9s is a terminal-based GUI that combines the simplicity of a dashboard with the speed of a CLI. It offers real-time cluster monitoring, resource management, and keyboard shortcuts for efficiency.
-
Installation:
# Linux/macOS brew install derailed/k9s/k9s # or download from https://github.com/derailed/k9s/releases -
Key Features:
- Live updates of pods, deployments, and nodes.
- One-click log viewing, exec, and port-forwarding.
- Search/filter resources with
/(e.g.,/nginxto find nginx pods). - Keyboard shortcuts:
:podsto view pods,:deployfor deployments,dto delete,lfor logs.
3.2.2 kubectx/kubens: Switch Contexts and Namespaces
kubectx lets you switch between clusters (contexts) quickly, while kubens switches namespaces.
-
Installation:
# Linux/macOS brew install kubectx # or download from https://github.com/ahmetb/kubectx -
Usage:
kubectx minikube # Switch to "minikube" cluster context kubens production # Switch to "production" namespace
3.2.3 stern: Aggregated Logging for Pods
stern tails logs from multiple pods or containers, even across deployments. Useful for debugging distributed applications.
-
Installation:
brew install stern # or download from https://github.com/stern/stern -
Usage:
stern nginx # Tail logs from all pods with "nginx" in their name stern -n production my-app # Tail "my-app" logs in the "production" namespace
3.2.4 kubeval: Validate Kubernetes Manifests
kubeval checks YAML/JSON manifests for syntax errors and schema compliance before deployment.
-
Installation:
brew install kubeval # or download from https://github.com/instrumenta/kubeval -
Usage:
kubeval deployment.yaml # Validate a single manifest kubeval *.yaml # Validate all YAML files in a directory
4. GUI vs. CLI: When to Use Which?
| Use Case | Dashboard (GUI) | CLI Tools |
|---|---|---|
| Visualizing cluster health (CPU/memory usage) | ✅ Ideal (real-time graphs) | ❌ Less intuitive (use kubectl top pods for stats) |
| Quick ad-hoc tasks (e.g., scaling a deployment) | ✅ Click-and-drag simplicity | ❌ Requires typing kubectl scale deployment <name> --replicas=3 |
| Automation/scripting (e.g., CI/CD pipelines) | ❌ Not programmable | ✅ Essential (kubectl apply -f manifest.yaml in scripts) |
| Troubleshooting (e.g., inspecting pod events) | ✅ “Events” tab shows errors clearly | ✅ kubectl describe pod <name> (more detailed, but text-heavy) |
| Managing multiple clusters | ❌ Requires reconfiguring access | ✅ kubectx switches contexts in 1 command |
| Non-technical users | ✅ Lower learning curve | ❌ Steeper learning curve |
Rule of Thumb: Use the Dashboard for quick visual checks or when you need to “see” the cluster. Use CLIs for everything else—especially automation, precision, or remote work.
5. Best Practices for Using Kubernetes Tools
-
Secure the Dashboard:
- Never expose the Dashboard publicly without authentication (use
NodePortonly in private networks). - Restrict permissions with RBAC (e.g., read-only roles for most users, admin roles only for critical tasks).
- Never expose the Dashboard publicly without authentication (use
-
Optimize
kubectlWorkflow:- Use aliases:
alias k=kubectl,alias kgp='kubectl get pods'(save in~/.bashrcor~/.zshrc). - Enable autocompletion:
source <(kubectl completion bash)(add to your shell config).
- Use aliases:
-
Keep Tools Updated:
- Update
kubectl,k9s, and the Dashboard to match your cluster’s Kubernetes version (e.g.,kubectlv1.26 for cluster v1.26).
- Update
-
Version Control Manifests:
- Store YAML/JSON manifests in Git (e.g., GitHub, GitLab) to track changes and enable rollbacks.
-
Learn
kubectl explain:- Use
kubectl explain pod.specto explore Kubernetes API fields (avoids guessing YAML syntax).
- Use
6. Conclusion
Kubernetes management tools—whether GUI (Dashboard) or CLI (kubectl, k9s)—are essential for taming cluster complexity. The Dashboard simplifies visualization and quick tasks, while CLIs empower automation and precision. As a beginner, start with the Dashboard to build intuition, then master kubectl and complementary tools like k9s for advanced workflows.
Remember: the best Kubernetes practitioners use both tools in tandem. With practice, you’ll learn when to click and when to type—unlocking the full potential of your cluster.