Cloud Malaya Lab
  • Home Cloud Lab
    • Architecture
    • DNS Server
  • DevOps & DevSecOps
    • Kubernetes
      • Fundamental
        • Taints in Kubernetes
        • Kubernetes Observability (Monitoring) Guide
        • DNS in Kubernetes (CoreDNS)
        • Storage in Kubernetes
          • Container Storage Interface - CSI
          • Ephemeral Storage Explain
        • Cluster CPU & Memory Inspections
        • Open Source and Free Storage Solution Kubernetes
      • PoC Lab
        • Configure Access to Multiple Cluster using KUBE_CONFIG
        • High Availability Portable Mini Kubernetes Data Center with K3s
          • Lab 1: Build the K3s Infrastructure
          • Lab 2: Automate the K3s clusters deployment with Ansible
          • Lab 3: Multi Master K3s kubeconfig files for smooth accessibility
          • Lab 4: Network Configurations & Tools
        • AWX/Ansible Tower Deployment on Kubernetes
          • Lab 1 - Understanding Requirements
          • Lab 2 - AWX,AWX Operator Configurations & Deployments
          • Lab 3 - Ingress Networking & Connectivity via Nginx
          • Lab 4: AWX Web Console & accessibility on LAN
        • Troubleshooting: Ansible Tower - Reset admin password
    • Monitoring & Observability
      • Splunk
        • Splunk Deployment for SME (Malay Version)
    • System Administration - Linux
      • RedHat Derivatives
        • Add User to Sudoers
        • Yum Update vs Yum Upgrade
        • DNF update vs upgrade
        • SMP PREEMPT_DYNAMIC Definitions
      • Virtualization
        • KVM
      • Storage
  • Digital Infrastructure & Cloud Solutions
    • Solution & System Design
      • Public Cloud
        • Fundamental
          • AWS
          • Azure
          • GCP
        • Lab
          • Simple CD menggunakan Github Action
      • Private Cloud & On-Premise
      • On-Premise to Cloud Design
        • AWS Direct Connect
      • High Availability & Fault Tolerance Design
      • Disaster Recovery
Powered by GitBook
On this page
  • Quickly get the summary of total CPU
  • Quickly get the summary of total Memory
  • Inspect Current Utilization
  • Using Kubernetes Dashboard
  1. DevOps & DevSecOps
  2. Kubernetes
  3. Fundamental

Cluster CPU & Memory Inspections

PreviousEphemeral Storage ExplainNextOpen Source and Free Storage Solution Kubernetes

Last updated 1 year ago

Quickly get the summary of total CPU

$ kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.cpu}{"\n"}{end}' | awk '{sum += $2} END {print "Total CPUs across all nodes: " sum}'

Quickly get the summary of total Memory

$ kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.capacity.memory}{"\n"}{end}' | awk '{print $1 "\t" $2 / (1024 * 1024) " MB"}'

Inspect Current Utilization

Ensure that Metrics Server is installed in your Kubernetes cluster. If it's installed, you can query it to get CPU and memory usage information.

$ kubectl top nodes

Run below command to convert from Mebibytes (Mi) to Megabytes (MB)

$ kubectl top nodes | awk '{print $1, $2, $3, $4, ($5/1024/1024)"MB", $6}'

Using Kubernetes Dashboard

If you have Kubernetes Dashboard installed, you can also use it to view resource usage across your cluster.

Example Nodes metrics from Home Lab K8s Cluster