This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 38. Analyzing Cluster Capacity
38.1. Overview Copier lienLien copié sur presse-papiers!
As a cluster administrator, you can use the cluster capacity tool to view the number of pods that can be scheduled to increase the current resources before they become exhausted, and to ensure any future pods can be scheduled. This capacity comes from an individual node host in a cluster, and includes CPU, memory, disk space, and others.
The cluster capacity tool simulates a sequence of scheduling decisions to determine how many instances of an input pod can be scheduled on the cluster before it is exhausted of resources to provide a more accurate estimation.
The remaining allocatable capacity is a rough estimation, because it does not count all of the resources being distributed among nodes. It analyzes only the remaining resources and estimates the available capacity that is still consumable in terms of a number of instances of a pod with given requirements that can be scheduled in a cluster.
Also, pods might only have scheduling support on particular sets of nodes based on its selection and affinity criteria. As a result, the estimation of which remaining pods a cluster can schedule can be difficult.
You can run the cluster capacity analysis tool as a stand-alone utility from the command line, or as a job in a pod inside an OpenShift Container Platform cluster. Running it as job inside of a pod enables you to run it multiple times without intervention.
38.2. Running Cluster Capacity Analysis on the Command Line Copier lienLien copié sur presse-papiers!
To run the tool on the command line:
cluster-capacity --kubeconfig <path-to-kubeconfig> \
--podspec <path-to-pod-spec>
$ cluster-capacity --kubeconfig <path-to-kubeconfig> \
--podspec <path-to-pod-spec>
The --kubeconfig option indicates your Kubernetes configuration file, and the --podspec option indicates a sample pod specification file, which the tool uses for estimating resource usage. The podspec specifies its resource requirements as limits or requests. The cluster capacity tool takes the pod’s resource requirements into account for its estimation analysis.
An example of the pod specification input is:
You can also add the --verbose option to output a detailed description of how many pods can be scheduled on each node in the cluster:
cluster-capacity --kubeconfig <path-to-kubeconfig> \
--podspec <path-to-pod-spec> --verbose
$ cluster-capacity --kubeconfig <path-to-kubeconfig> \
--podspec <path-to-pod-spec> --verbose
The output will look similar to the following:
In the above example, the number of estimated pods that can be scheduled onto the cluster is 52.
38.3. Running Cluster Capacity as a Job Inside of a Pod Copier lienLien copié sur presse-papiers!
Running the cluster capacity tool as a job inside of a pod has the advantage of being able to be run multiple times without needing user intervention. Running the cluster capacity tool as a job involves using a ConfigMap.
Create the cluster role:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the service account:
oc create sa cluster-capacity-sa
$ oc create sa cluster-capacity-saCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add the role to the service account:
oc adm policy add-cluster-role-to-user cluster-capacity-role \ system:serviceaccount:default:cluster-capacity-sa$ oc adm policy add-cluster-role-to-user cluster-capacity-role \ system:serviceaccount:default:cluster-capacity-saCopy to Clipboard Copied! Toggle word wrap Toggle overflow Define and create the pod specification:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The cluster capacity analysis is mounted in a volume using a
ConfigMapnamedcluster-capacity-configmapto mount input pod spec filepod.yamlinto a volumetest-volumeat the path/test-pod.If you haven’t created a
ConfigMap, create one before creating the job:oc create configmap cluster-capacity-configmap \ --from-file=pod.yaml=pod.yaml$ oc create configmap cluster-capacity-configmap \ --from-file=pod.yaml=pod.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the job using the below example of a job specification file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- A required environment variable letting the cluster capacity tool know that it is running inside a cluster as a pod.
Thepod.yamlkey of theConfigMapis the same as the pod specification file name, though it is not required. By doing this, the input pod spec file can be accessed inside the pod as/test-pod/pod.yaml.
Run the cluster capacity image as a job in a pod:
oc create -f cluster-capacity-job.yaml
$ oc create -f cluster-capacity-job.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check the job logs to find the number of pods that can be scheduled in the cluster:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow