Retrieve vCPU Capacity from Tanzu Application Platform

You can obtain vCPU capacity from a Tanzu Application Platform environment either manually or by running a Bash script.

Manual Collection

  1. Set the KUBECONFIG environment variable to the path to the kubeconf file for the Tanzu Application Platform cluster.
  2. Obtain either formatted or raw vCPU information from the cluster.

    • To obtain formatted output, run the following command:

      echo "vCPU capacity: $(kubectl get -A nodes -o json | jq '[.items[].status.capacity.cpu | tonumber] | add')"
      
    • To obtain raw output, run the following command:

      kubectl get -A nodes -o json | jq '[.items[].status.capacity.cpu | tonumber] | add'
      

NOTE: The output will be the total vCPU capacity of that cluster.

Bash Script Collection

  1. Set the KUBECONFIG environment variable to the path to the kubeconf file for the Tanzu Application Platform Management cluster.
  2. Copy and paste the script from the Script section below into a file named get_cpu_script.sh.
  3. Give the file permission to run.

    chmod +x /path/to/file/get_cpu_single_cluster_script.sh
    
  4. Run the script.

    /path/to/file/get_cpu_single_cluster_script.sh
    

Script

Copy this script into a text file when you run the Bash Script Collection procedure.

#!/bin/bash

printf "\nCollection Timestamp:\t%s\n" "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
printf "Total TAP vCPUs:\t%s\n\n" "$(kubectl get -A nodes -o json | jq '[.items[].status.capacity.cpu | tonumber] | add')"

When you run the script, you see the following output.

Collection Timestamp:	2022-01-24T18:45:11Z
Total TKG vCPUs:        20
check-circle-line exclamation-circle-line close-line
Scroll to top icon