8.2.2. コマンドラインでの OpenShift Cluster Capacity Tool の実行
コマンドラインから OpenShift Cluster Capacity Tool を実行して、クラスターにスケジュール設定可能な Pod 数を見積ることができます。
ツールがリソース使用状況を見積もるために使用するサンプル Pod 仕様ファイルを作成します。pod spec はそのリソース要件を limits または requests として指定します。クラスター容量ツールは、Pod のリソース要件をその見積もりの分析に反映します。
前提条件
- Red Hat Ecosystem Catalog からコンテナーイメージとして入手できる OpenShift Cluster Capacity Tool を実行してください。関連情報セクションのリンクを参照してください。
サンプルの Pod 仕様ファイルを作成します。
以下のような YAML ファイルを作成します。
apiVersion: v1 kind: Pod metadata: name: small-pod labels: app: guestbook tier: frontend spec: securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault 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 securityContext: allowPrivilegeEscalation: false capabilities: drop: [ALL]クラスターロールを作成します。
$ oc create -f <file_name>.yaml以下に例を示します。
$ oc create -f pod-spec.yaml
手順
ターミナルから、Red Hat レジストリーにログインします。
$ podman login registry.redhat.ioクラスター容量ツールのイメージをプルします。
$ podman pull registry.redhat.io/openshift4/ose-cluster-capacityクラスター容量ツールを実行します。
$ podman run -v $HOME/.kube:/kube:Z -v $(pwd):/cc:Z ose-cluster-capacity \ /bin/cluster-capacity --kubeconfig /kube/config --<pod_spec>.yaml /cc/<pod_spec>.yaml \ --verboseここでは、以下のようになります。
- <pod_spec>.yaml
- 使用する Pod の仕様を指定します。
- verbose
- クラスター内の各ノードでスケジュールできる Pod の数の詳細な説明を出力します。
出力例
small-pod pod requirements: - CPU: 150m - Memory: 100Mi The cluster can schedule 88 instance(s) of the pod small-pod. Termination reason: Unschedulable: 0/5 nodes are available: 2 Insufficient cpu, 3 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate. Pod distribution among nodes: small-pod - 192.168.124.214: 45 instance(s) - 192.168.124.120: 43 instance(s)上記の例では、クラスターにスケジュールできる推定 Pod の数は 88 です。