Menu Close

Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

42.2. 在命令行中运行集群容量分析

安装 openshift-enterprise-cluster-capacity RPM 软件包以获取 工具。在命令行中运行该工具:

$ hypercc cluster-capacity --kubeconfig <path-to-kubeconfig> \
    --podspec <path-to-pod-spec>

kubeconfig 选项 表示您的 Kubernetes 配置文件,-- podspec 选项表示一个示例 pod 规格文件,该工具将使用该文件来估算资源使用量。podspeclimitsrequests 的形式指定资源要求。Hyper cc cluster-capacity 工具在估算分析时会考虑 pod 的资源要求。

pod 规格输入的示例如下:

apiVersion: v1
kind: Pod
metadata:
  name: small-pod
  labels:
    app: guestbook
    tier: frontend
spec:
  containers:
  - name: php-redis
    image: gcr.io/google-samples/gb-frontend:v4
    imagePullPolicy: Always
    resources:
      limits:
        cpu: 150m
        memory: 100Mi
      requests:
        cpu: 150m
        memory: 100Mi

您还可以添加 --verbose 选项,以输出集群的各个节点上可以调度多少个 pod 的详细描述:

$ hypercc cluster-capacity --kubeconfig <path-to-kubeconfig> \
    --podspec <path-to-pod-spec> --verbose

输出结果类似如下:

small-pod pod requirements:
	- CPU: 150m
	- Memory: 100Mi

The cluster can schedule 52 instance(s) of the pod small-pod.

Termination reason: Unschedulable: No nodes are available that match all of the
following predicates:: Insufficient cpu (2).

Pod distribution among nodes:
small-pod
	- 192.168.124.214: 26 instance(s)
	- 192.168.124.120: 26 instance(s)

在上例中,集群中估计可以调度的 pod 数量是 52。