Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Why Cluster Monitoring Matters
📖 Scenario: You are managing a Kubernetes cluster that runs several applications for your company. To keep everything running smoothly, you need to monitor the cluster's health and resource usage.
🎯 Goal: Learn how to set up basic cluster monitoring by creating a simple Kubernetes ConfigMap with monitoring settings, then apply a label selector to identify monitored nodes, and finally list the nodes being monitored.
📋 What You'll Learn
Create a ConfigMap named monitoring-config with a key enabled set to true
Create a label selector variable called monitor_label with the value monitor=true
Use kubectl get nodes -l monitor=true command to list nodes with the monitoring label
Print the output of the command
💡 Why This Matters
🌍 Real World
Monitoring Kubernetes clusters is essential to ensure applications run smoothly and resources are used efficiently.
💼 Career
DevOps engineers and site reliability engineers use cluster monitoring to detect issues early and maintain system stability.
Progress0 / 4 steps
1
Create a ConfigMap for monitoring
Create a Kubernetes ConfigMap named monitoring-config with a data key enabled set to true using the kubectl create configmap command.
Kubernetes
Hint
Use kubectl create configmap monitoring-config --from-literal=enabled=true to create the ConfigMap.
2
Set a label selector variable
Create a shell variable called monitor_label and set it to the string monitor=true.
Kubernetes
Hint
Use monitor_label="monitor=true" to create the variable.
3
List nodes with the monitoring label
Use the kubectl get nodes command with the label selector stored in monitor_label to list all nodes labeled for monitoring.
Kubernetes
Hint
Use kubectl get nodes -l $monitor_label to list nodes with the label.
4
Display the monitored nodes
Print the output of the kubectl get nodes -l $monitor_label command to show the nodes currently monitored.
Kubernetes
Hint
Running kubectl get nodes -l $monitor_label will print the nodes with the label.
Practice
(1/5)
1. Why is cluster monitoring important in Kubernetes?
easy
A. It removes unused containers automatically.
B. It helps detect problems early and keeps the system healthy.
C. It replaces the need for backups.
D. It automatically scales the cluster without user input.
Solution
Step 1: Understand the purpose of monitoring
Monitoring tracks system health and performance to spot issues early.
Step 2: Compare options with monitoring goals
Only early problem detection and health maintenance match monitoring's purpose.
Final Answer:
It helps detect problems early and keeps the system healthy. -> Option B
Quick Check:
Monitoring = Early problem detection [OK]
Hint: Monitoring = spotting problems early to keep system healthy [OK]
Common Mistakes:
Confusing monitoring with automatic scaling
Thinking monitoring replaces backups
Assuming monitoring deletes containers
2. Which command is used to check the status of nodes in a Kubernetes cluster for monitoring?
easy
A. kubectl get nodes
B. kubectl describe service
C. kubectl get pods
D. kubectl logs
Solution
Step 1: Identify command to list nodes
The command kubectl get nodes lists all cluster nodes and their status.
Step 2: Eliminate other commands
kubectl get pods lists pods, not nodes; kubectl describe service shows service details; kubectl logs shows logs of pods.
Final Answer:
kubectl get nodes -> Option A
Quick Check:
Nodes status = kubectl get nodes [OK]
Hint: Nodes status command is 'kubectl get nodes' [OK]
Common Mistakes:
Using 'kubectl get pods' to check nodes
Confusing logs with node status
Describing services instead of nodes
3. Given the output below from kubectl top nodes, what does it indicate?
NAME CPU(cores) MEMORY(bytes)
node-1 250m 512Mi
node-2 900m 1Gi
node-3 100m 256Mi
medium
A. node-3 has the highest CPU usage.
B. node-1 is using the most memory.
C. All nodes have equal resource usage.
D. node-2 is under heavy CPU and memory load compared to others.
Solution
Step 1: Analyze CPU and memory usage per node
node-2 shows 900m CPU and 1Gi memory, which is higher than node-1 and node-3.
Step 2: Compare usage values
node-3 has lowest CPU (100m), node-1 has moderate CPU (250m), node-2 is highest in both CPU and memory.
Final Answer:
node-2 is under heavy CPU and memory load compared to others. -> Option D
Quick Check:
Highest CPU and memory = node-2 [OK]
Hint: Highest CPU and memory usage means heavy load [OK]
Common Mistakes:
Mistaking 100m as highest CPU
Assuming equal resource usage
Confusing memory units
4. You set up cluster monitoring but notice no metrics appear when running kubectl top nodes. What is the most likely cause?
medium
A. Nodes are offline.
B. kubectl command is outdated.
C. Metrics-server is not installed or running.
D. Pods are not labeled correctly.
Solution
Step 1: Understand what provides metrics for 'kubectl top'
The metrics-server collects resource usage data for nodes and pods.
Step 2: Identify why metrics might be missing
If metrics-server is missing or not running, kubectl top shows no data.
Final Answer:
Metrics-server is not installed or running. -> Option C
Quick Check:
Missing metrics = metrics-server issue [OK]
Hint: No metrics? Check if metrics-server is running [OK]
Common Mistakes:
Blaming kubectl version without checking metrics-server
Assuming nodes are offline without verification
Thinking pod labels affect node metrics
5. You want to improve cluster reliability by setting up alerts for high CPU usage on nodes. Which approach best supports this goal?
hard
A. Use Prometheus to monitor node metrics and configure alert rules for CPU thresholds.
B. Manually check node CPU usage daily with kubectl top nodes.
C. Restart nodes periodically to prevent high CPU usage.
D. Disable monitoring to reduce overhead and avoid false alerts.
Solution
Step 1: Identify monitoring tool for alerts
Prometheus collects metrics and supports alerting rules for conditions like high CPU.
Step 2: Evaluate options for reliability
Manual checks are slow and error-prone; restarting nodes blindly is not a solution; disabling monitoring removes visibility.
Final Answer:
Use Prometheus to monitor node metrics and configure alert rules for CPU thresholds. -> Option A
Quick Check:
Automated alerts = Prometheus + alert rules [OK]
Hint: Automate alerts with Prometheus for reliable monitoring [OK]