Red Hat CoreOS ワーカー・ノードのパフォーマンスのチューニング
Satellite
- サポートされるワーカー・ノードのオペレーティング・システム
- Red Hat CoreOS (
RHCOS)
CPU ピンニング、NUMA(Non-Uniform Memory Access)、巨大ページを有効にすることで、 Red Hat CoreOS ワーカーノードのパフォーマンスを調整できます。 これらのコンフィギュレーションは、厳しい性能要件があるアプリケーションに有益である。 しかし、このようなカスタマイズは、作業負荷のスケジューリングの問題を引き起こすかもしれない。
Red Hat OpenShift の MachineConfig ファイルを使ってワーカーノードのパフォーマンスをチューニングする代わりに、 daemonset ファイルを使ってホストを変更することができます。 詳細については、 Calico MTUの変更 または Red Hat CoreOS ワーカー・ノードのパフォーマンス調整を 参照してください。
Node Feature Discovery Operator のデプロイ
Satellite
ワーカー・ノードで NUMA、CPU ピン留め、およびヒュージ・ページを有効にするには、 Node Feature Discovery Operator をデプロイする必要があります。 詳細については、 Node Feature Discovery Operatorを参照。
ワーカー・ノードでの非均等メモリー・アクセス (NUMA)、CPU ピン留め、およびヒュージ・ページの有効化
Satellite
始める前に、 Node Feature Discovery Operator をデプロイしたことを確認してください。
-
以下の
DaemonSetをcustomize.yamlというファイルに保存します。--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: ibm-user-custom-configurator-privileged roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:openshift:scc:privileged subjects: - kind: ServiceAccount name: ibm-user-custom-configurator namespace: kube-system --- apiVersion: v1 kind: ServiceAccount metadata: name: ibm-user-custom-configurator namespace: kube-system --- apiVersion: v1 kind: ConfigMap metadata: name: ibm-user-custom-configurator namespace: kube-system data: 89-hugepages.conf: | vm.nr_hugepages=<<NUMBER_OF_HUGEPAGES>> configure.sh: | #!/usr/bin/env bash set -x cp -f /scripts/ibm-user-custom-configuration.sh /host-usr-local-bin/ibm-user-custom-configuration.sh chmod 0755 /host-usr-local-bin/ibm-user-custom-configuration.sh cp -f /scripts/ibm-user-custom-configuration.service /host-etc-systemd-dir/ibm-user-custom-configuration.service chmod 0644 /host-etc-systemd-dir/ibm-user-custom-configuration.service if [[ -f /scripts/89-hugepages.conf ]]; then cp -f /scripts/89-hugepages.conf /host-etc-systctld-dir/89-hugepages.conf fi nsenter -t 1 -m -u -i -n -p -- systemctl daemon-reload nsenter -t 1 -m -u -i -n -p -- systemctl enable ibm-user-custom-configuration.service nsenter -t 1 -m -u -i -n -p -- systemctl start ibm-user-custom-configuration.service ibm-user-custom-configuration.sh: | #!/usr/bin/env bash set -x GIGABYTES_RESERVED_MEMORY=$(echo $SYSTEM_RESERVED_MEMORY | awk -F 'Gi' '{print $1}') GIGABYTES_RESERVED_MEMORY_ROUNDED_UP=$(echo $GIGABYTES_RESERVED_MEMORY | awk '{print int($1+0.999)}') sed -i "s/SYSTEM_RESERVED_MEMORY=.*/SYSTEM_RESERVED_MEMORY=${GIGABYTES_RESERVED_MEMORY_ROUNDED_UP}Gi/g" /etc/node-sizing.env TOTAL_NUMA_MEMORY_TO_ALLOCATE=$(echo "$GIGABYTES_RESERVED_MEMORY_ROUNDED_UP" "1024" | awk '{print $1 * $2 + 100}') if cat /etc/kubernetes/kubelet.conf | jq -r .; then cat >/tmp/ibm-user-config.conf.json <<EOF { "topologyManagerPolicy": "<<TOPOLOGY_MANAGER_POLICY_VALUE>>", "memoryManagerPolicy": "Static", "cpuManagerPolicy": "static", "reservedMemory": [ { "numaNode": 0, "limits": { "memory": "${TOTAL_NUMA_MEMORY_TO_ALLOCATE}Mi" } } ] } EOF if ! cat /tmp/ibm-user-config.conf.json | jq -r .; then exit 1 fi if ! jq -s '.[0] * .[1]' /tmp/ibm-user-config.conf.json /etc/kubernetes/kubelet.conf > /etc/kubernetes/tmp-kubelet.conf; then exit 1 fi mv -f /etc/kubernetes/tmp-kubelet.conf /etc/kubernetes/kubelet.conf else cat >/tmp/ibm-user-config.conf <<EOF #START USER CONFIG topologyManagerPolicy: <<TOPOLOGY_MANAGER_POLICY_VALUE>> memoryManagerPolicy: Static cpuManagerPolicy: static reservedMemory: - numaNode: 0 limits: memory: ${TOTAL_NUMA_MEMORY_TO_ALLOCATE}Mi #END USER CONFIG EOF sed -i '/#START USER CONFIG/,/#END USER CONFIG/d' /etc/kubernetes/kubelet.conf cat /tmp/ibm-user-config.conf >>/etc/kubernetes/kubelet.conf fi ibm-user-custom-configuration.service: | [Unit] Description=Add custom user config to kubelet Before=kubelet.service After=kubelet-auto-node-size.service [Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=/etc/node-sizing.env ExecStart=/usr/local/bin/ibm-user-custom-configuration.sh [Install] WantedBy=multi-user.target --- apiVersion: apps/v1 kind: DaemonSet metadata: labels: app: ibm-user-custom-configurator name: ibm-user-custom-configurator namespace: kube-system spec: selector: matchLabels: app: ibm-user-custom-configurator template: metadata: labels: app: ibm-user-custom-configurator spec: nodeSelector: feature.node.kubernetes.io/memory-numa: "true" ibm-cloud.kubernetes.io/os: RHCOS tolerations: - operator: "Exists" hostPID: true serviceAccount: ibm-user-custom-configurator initContainers: - name: configure image: "registry.access.redhat.com/ubi8/ubi:8.6" command: ['/bin/bash', '-c', 'mkdir /cache && cp /scripts/configure.sh /cache && chmod +x /cache/configure.sh && /bin/bash /cache/configure.sh'] securityContext: privileged: true volumeMounts: - mountPath: /scripts name: script-config - mountPath: /host-etc-systemd-dir name: etc-systemd-dir - mountPath: /host-usr-local-bin name: usr-local-bin - mountPath: /host-etc-systctld-dir name: etc-systctld-dir containers: - name: pause image: us.icr.io/armada-master/pause:3.2 volumes: - name: etc-systemd-dir hostPath: path: /etc/systemd/system - name: etc-systctld-dir hostPath: path: /etc/sysctl.d - name: usr-local-bin hostPath: path: /usr/local/bin - name: script-config configMap: name: ibm-user-custom-configurator -
DaemonSetの値を編集して、パフォーマンスを調整します。
NUMBER_OF_HUGEPAGES-
割り振るヒュージ・ページの数を入力します。 例:
2048ヒュージ・ページを有効にしない場合は、0と入力します。 割り当てるヒュージ・ページの数が多いほど、アプリケーションで使用できるメモリー全体が少なくなります。 TOPOLOGY_MANAGER_POLICY_VALUE-
使用するトポロジー・マネージャー・ポリシーを入力します。 最大限のスケジューリングを可能にするため、
best-effortのポリシーを推奨する。 しかし、ワークロードのスケジューリング可用性を下げつつ、より厳しい要件の検証を行うために、他のポリシーを使用することができます。 詳細は トポロジー・マネージャーを参照。nodeSelectorセクションを編集して、ワーカー・ノードのサブセットにのみ構成を適用できます。
- 次のコマンドを実行して、
DaemonSetを適用します。kubectl replace --force -f customize.yaml - ポッドが
Running状態になったことを確認します。kubectl get pods -n kube-system -l app=ibm-user-custom-configurator -o wide - ポッドが実行されたら、各ワーカー・ノードをリブートします。
- ワーカーノードにデバッグ用ポッドをデプロイします。
oc debug node/NODE_NAME ``` 1. デバッグ・セッションの開始後に、以下のコマンドを実行します。 ```sh {: pre} nsenter -t 1 -m -u -i -n -p -- reboot ``` 1. 再起動したい各ワーカーノードについて、これらの手順を繰り返してください。
ワーカー・ノードでの CPU ピン留めとヒュージ・ページの有効化
Satellite
始める前に、 Node Feature Discovery Operator をデプロイしたことを確認してください。
-
以下の
DaemonSetをcpu-pinning.yamlというファイルに保存します。--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: ibm-user-custom-configurator-privileged roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:openshift:scc:privileged subjects: - kind: ServiceAccount name: ibm-user-custom-configurator namespace: kube-system --- apiVersion: v1 kind: ServiceAccount metadata: name: ibm-user-custom-configurator namespace: kube-system --- apiVersion: v1 kind: ConfigMap metadata: name: ibm-user-custom-configurator namespace: kube-system data: 89-hugepages.conf: | vm.nr_hugepages=<<NUMBER_OF_HUGEPAGES>> configure.sh: | #!/usr/bin/env bash set -x cp -f /scripts/ibm-user-custom-configuration.sh /host-usr-local-bin/ibm-user-custom-configuration.sh chmod 0755 /host-usr-local-bin/ibm-user-custom-configuration.sh cp -f /scripts/ibm-user-custom-configuration.service /host-etc-systemd-dir/ibm-user-custom-configuration.service chmod 0644 /host-etc-systemd-dir/ibm-user-custom-configuration.service if [[ -f /scripts/89-hugepages.conf ]]; then cp -f /scripts/89-hugepages.conf /host-etc-systctld-dir/89-hugepages.conf fi nsenter -t 1 -m -u -i -n -p -- systemctl daemon-reload nsenter -t 1 -m -u -i -n -p -- systemctl enable ibm-user-custom-configuration.service nsenter -t 1 -m -u -i -n -p -- systemctl start ibm-user-custom-configuration.service ibm-user-custom-configuration.sh: | #!/usr/bin/env bash set -x if cat /etc/kubernetes/kubelet.conf | jq -r .; then cat >/tmp/ibm-user-config.conf.json <<EOF { "cpuManagerPolicy": "static" } EOF if ! cat /tmp/ibm-user-config.conf.json | jq -r .; then exit 1 fi if ! jq -s '.[0] * .[1]' /tmp/ibm-user-config.conf.json /etc/kubernetes/kubelet.conf > /etc/kubernetes/tmp-kubelet.conf; then exit 1 fi mv -f /etc/kubernetes/tmp-kubelet.conf /etc/kubernetes/kubelet.conf else cat >/tmp/ibm-user-config.conf <<EOF #START USER CONFIG cpuManagerPolicy: static #END USER CONFIG EOF sed -i '/#START USER CONFIG/,/#END USER CONFIG/d' /etc/kubernetes/kubelet.conf cat /tmp/ibm-user-config.conf >>/etc/kubernetes/kubelet.conf fi ibm-user-custom-configuration.service: | [Unit] Description=Add custom user config to kubelet Before=kubelet.service After=kubelet-auto-node-size.service [Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=/etc/node-sizing.env ExecStart=/usr/local/bin/ibm-user-custom-configuration.sh [Install] WantedBy=multi-user.target --- apiVersion: apps/v1 kind: DaemonSet metadata: labels: app: ibm-user-custom-configurator name: ibm-user-custom-configurator namespace: kube-system spec: selector: matchLabels: app: ibm-user-custom-configurator template: metadata: labels: app: ibm-user-custom-configurator spec: nodeSelector: ibm-cloud.kubernetes.io/os: RHCOS tolerations: - operator: "Exists" hostPID: true serviceAccount: ibm-user-custom-configurator initContainers: - name: configure image: "registry.access.redhat.com/ubi8/ubi:8.6" command: ['/bin/bash', '-c', 'mkdir /cache && cp /scripts/configure.sh /cache && chmod +x /cache/configure.sh && /bin/bash /cache/configure.sh'] securityContext: privileged: true volumeMounts: - mountPath: /scripts name: script-config - mountPath: /host-etc-systemd-dir name: etc-systemd-dir - mountPath: /host-usr-local-bin name: usr-local-bin - mountPath: /host-etc-systctld-dir name: etc-systctld-dir containers: - name: pause image: us.icr.io/armada-master/pause:3.2 volumes: - name: etc-systemd-dir hostPath: path: /etc/systemd/system - name: etc-systctld-dir hostPath: path: /etc/sysctl.d - name: usr-local-bin hostPath: path: /usr/local/bin - name: script-config configMap: name: ibm-user-custom-configurator -
DaemonSetの値を編集して、パフォーマンスを調整します。
NUMBER_OF_HUGEPAGES-
割り振るヒュージ・ページの数を入力します。 例:
2048ヒュージ・ページを有効にしない場合は、0と入力します。 割り当てるヒュージ・ページの数が多いほど、アプリケーションで使用できるメモリー全体が少なくなります。nodeSelectorセクションを編集して、ワーカー・ノードのサブセットにのみ構成を適用できます。
- 次のコマンドを実行して、
DaemonSetを適用します。kubectl replace --force -f cpu-pinnning.yaml - ポッドが
Running状態になったことを確認します。kubectl get pods -n kube-system -l app=ibm-user-custom-configurator -o wide - ポッドが実行されたら、各ワーカー・ノードをリブートします。
- ワーカーノードにデバッグ用ポッドをデプロイします。
oc debug node/NODE_NAME ``` 1. デバッグ・セッションの開始後に、以下のコマンドを実行します。 ```sh {: pre} nsenter -t 1 -m -u -i -n -p -- reboot ``` 1. 再起動したい各ワーカーノードについて、これらの手順を繰り返してください。
kernel-devel パッケージの使用可能化
Satellite
Satellite サービスまたはストレージ ( Spectrum Scale Fusion など) を使用するには、 kernel-devel パッケージを有効にする必要がある場合があります。
ワーカー・ノードにカスタム構成マップとマシン構成を適用して kernel-devel を有効にするには、以下の手順を実行します。
-
MachineConfigを適用するには、次のコマンドを実行してください。ibmcloud ks cluster config --cluster CLUSTERID cat >"/tmp/kernel-devel-payload.yaml" <<EOF apiVersion: v1 kind: List metadata: name: pvg-machine-config-tester annotations: items: - apiVersion: v1 kind: Namespace metadata: name: ibm-machine-config - apiVersion: v1 data: config: |+ apiVersion: machineconfiguration.openshift.io/v1 kind: MachineConfig metadata: name: 97-kerneldevel labels: machineconfiguration.openshift.io/role: worker spec: config: ignition: version: 3.2.0 extensions: - kernel-devel kind: ConfigMap metadata: labels: ibm-cloud.kubernetes.io/user-specified-config: "true" name: user-ignition-config-97-kerneldevel namespace: ibm-machine-config EOF kubectl apply -f /tmp/kernel-devel-payload.yaml -
リソースのデプロイが完了するまでお待ちください。 これには 5 分以上かかる場合があります。
-
構成マップの詳細を確認して、デプロイメントが正常に行われたことを確認します。
config-validation="valid"フィールドが存在することを確認します。
kubectl get cm -n ibm-machine-config user-ignition-config-97-kerneldevel -o yaml | grep config-validation ``` 1. 構成マップに `user-ignition-config-97-kerneldevel` が存在することを確認します。 ```sh {: pre} kubectl get cm -n ibm-machine-config -l ibm-cloud.kubernetes.io/nodepoolfeedback="true" -o yaml | grep user-ignition-config-97-kerneldevel ``` -
クラスターにワーカーノードを追加します。 追加したワーカー・ノードでは、
kernel-develが有効になっています。 -
kernel-develが有効になっていることを確認してください。- いずれかのノードでデバッグ・ポッドを開始します。
oc debug node/NODEIP ``` 1. 次の `nsenter` コマンドを実行してください。 ```sh {: pre} nsenter -t 1 -m -u -i -n -p -- rpm -qa | grep kernel-devel ``` -
オプション:
kernel-develが不要になった場合は、以下のコマンドを実行して削除できます。kubectl delete cm -n ibm-machine-config user-ignition-config-97-kerneldevel
パフォーマンスのカスタマイズの削除
Satellite
ワーカー・ノードからカスタマイズを削除してデフォルト構成にリセットする場合は、以下の DaemonSet を適用します。
-
以下の
DaemonSetをremove-custom.yamlというファイルに保存します。--- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: ibm-user-custom-configurator-privileged roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:openshift:scc:privileged subjects: - kind: ServiceAccount name: ibm-user-custom-configurator namespace: kube-system --- apiVersion: v1 kind: ServiceAccount metadata: name: ibm-user-custom-configurator namespace: kube-system --- apiVersion: v1 kind: ConfigMap metadata: name: ibm-user-custom-configurator namespace: kube-system data: 89-hugepages.conf: | vm.nr_hugepages=0 configure.sh: | #!/usr/bin/env bash set -x cp -f /scripts/ibm-user-custom-configuration.sh /host-usr-local-bin/ibm-user-custom-configuration.sh chmod 0755 /host-usr-local-bin/ibm-user-custom-configuration.sh cp -f /scripts/ibm-user-custom-configuration.service /host-etc-systemd-dir/ibm-user-custom-configuration.service chmod 0644 /host-etc-systemd-dir/ibm-user-custom-configuration.service if [[ -f /scripts/89-hugepages.conf ]]; then cp -f /scripts/89-hugepages.conf /host-etc-systctld-dir/89-hugepages.conf fi nsenter -t 1 -m -u -i -n -p -- systemctl daemon-reload nsenter -t 1 -m -u -i -n -p -- systemctl enable ibm-user-custom-configuration.service nsenter -t 1 -m -u -i -n -p -- systemctl start ibm-user-custom-configuration.service ibm-user-custom-configuration.sh: | #!/usr/bin/env bash set -x if cat /etc/kubernetes/kubelet.conf | jq -r .; then if ! jq 'del(.topologyManagerPolicy, .memoryManagerPolicy, .cpuManagerPolicy, .reservedMemory)' /etc/kubernetes/kubelet.conf > /etc/kubernetes/tmp-kubelet.conf; then exit 1 fi mv -f /etc/kubernetes/tmp-kubelet.conf /etc/kubernetes/kubelet.conf else sed -i '/#START USER CONFIG/,/#END USER CONFIG/d' /etc/kubernetes/kubelet.conf fi ibm-user-custom-configuration.service: | [Unit] Description=Add custom user config to kubelet Before=kubelet.service After=kubelet-auto-node-size.service [Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=/etc/node-sizing.env ExecStart=/usr/local/bin/ibm-user-custom-configuration.sh [Install] WantedBy=multi-user.target --- apiVersion: apps/v1 kind: DaemonSet metadata: labels: app: ibm-user-custom-configurator name: ibm-user-custom-configurator namespace: kube-system spec: selector: matchLabels: app: ibm-user-custom-configurator template: metadata: labels: app: ibm-user-custom-configurator spec: nodeSelector: ibm-cloud.kubernetes.io/os: RHCOS tolerations: - operator: "Exists" hostPID: true serviceAccount: ibm-user-custom-configurator initContainers: - name: configure image: "registry.access.redhat.com/ubi8/ubi:8.6" command: ['/bin/bash', '-c', 'mkdir /cache && cp /scripts/configure.sh /cache && chmod +x /cache/configure.sh && /bin/bash /cache/configure.sh'] securityContext: privileged: true volumeMounts: - mountPath: /scripts name: script-config - mountPath: /host-etc-systemd-dir name: etc-systemd-dir - mountPath: /host-usr-local-bin name: usr-local-bin - mountPath: /host-etc-systctld-dir name: etc-systctld-dir containers: - name: pause image: us.icr.io/armada-master/pause:3.2 volumes: - name: etc-systemd-dir hostPath: path: /etc/systemd/system - name: etc-systctld-dir hostPath: path: /etc/sysctl.d - name: usr-local-bin hostPath: path: /usr/local/bin - name: script-config configMap: name: ibm-user-custom-configurator -
次のコマンドを実行して、
DaemonSetをクラスタに適用してください。kubectl replace --force -f remove-custom.yaml -
ポッドが
Running状態になったことを確認します。kubectl get pods -n kube-system -l app=ibm-user-custom-configurator -o wide -
ポッドが実行されたら、各ワーカー・ノードをリブートします。
- ワーカーノードにデバッグ用ポッドをデプロイします。
oc debug node/NODE_NAME ``` 1. デバッグ・セッションの開始後に、以下のコマンドを実行します。 ```sh {: pre} nsenter -t 1 -m -u -i -n -p -- reboot ``` 1. 再起動したい各ワーカーノードについて、これらの手順を繰り返してください。