11.9. ホストされたクラスターで無視されたラベルのバランシング
ノードプールをスケールアップした後、balancingIgnoredLabels を使用してノードプール全体にマシンを均等に分散できます。
前提条件
-
HostedClusterおよびNodePoolリソースを作成している。
手順
同じラベル値を使用して、関連する各ノードプールに
node.group.balancing.ignoredラベルを追加します。以下のコマンドを実行します。oc patch -n <hosted_cluster_namespace> \ nodepool <node_pool_name> \ --type=merge \ --patch='{"spec": {"nodeLabels": {"node.group.balancing.ignored": "<label_name>"}}}'$ oc patch -n <hosted_cluster_namespace> \ nodepool <node_pool_name> \ --type=merge \ --patch='{"spec": {"nodeLabels": {"node.group.balancing.ignored": "<label_name>"}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下のコマンドを実行して、ホストされたクラスターのクラスター自動スケーリングを有効にします。
oc patch -n <hosted_cluster_namespace> \ hostedcluster <hosted_cluster_name> \ --type=merge \ --patch='{"spec": {"autoscaling": {"balancingIgnoredLabels": ["node.group.balancing.ignored"]}}}'$ oc patch -n <hosted_cluster_namespace> \ hostedcluster <hosted_cluster_name> \ --type=merge \ --patch='{"spec": {"autoscaling": {"balancingIgnoredLabels": ["node.group.balancing.ignored"]}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow Cluster Autoscaler がノード数を管理できるようにするため、
NodePoolリソースからspec.replicasフィールドを削除します。以下のコマンドを実行します。oc patch -n <hosted_cluster_namespace> \ nodepool <node_pool_name> \ --type=json \ --patch='[{"op": "remove", "path": "/spec/replicas"}]'$ oc patch -n <hosted_cluster_namespace> \ nodepool <node_pool_name> \ --type=json \ --patch='[{"op": "remove", "path": "/spec/replicas"}]'Copy to Clipboard Copied! Toggle word wrap Toggle overflow クラスターの自動スケーリングを有効にして、ノードプールの最小および最大ノード数を設定します。以下のコマンドを実行します。
oc patch -n <hosted_cluster_namespace> \ nodepool <nodepool_name> \ --type=merge --patch='{"spec": {"autoScaling": {"max": 3, "min": 1}}}'$ oc patch -n <hosted_cluster_namespace> \ nodepool <nodepool_name> \ --type=merge --patch='{"spec": {"autoScaling": {"max": 3, "min": 1}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 次のコマンドを実行して、
kubeconfigファイルを生成します。hcp create kubeconfig \ --name <hosted_cluster_name> \ --namespace <hosted_cluster_namespace> > nested.config
$ hcp create kubeconfig \ --name <hosted_cluster_name> \ --namespace <hosted_cluster_namespace> > nested.configCopy to Clipboard Copied! Toggle word wrap Toggle overflow ノードプールをスケールアップした後、次のコマンドを実行して、すべてのコンピュートノードが
Readyステータスであることを確認します。oc --kubeconfig nested.config get nodes -l 'hypershift.openshift.io/nodePool=<node_pool_name>'
$ oc --kubeconfig nested.config get nodes -l 'hypershift.openshift.io/nodePool=<node_pool_name>'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下のコマンドを実行して、新規ノードに
node.group.balancing.ignoredラベルが含まれていることを確認します。oc --kubeconfig nested.config get nodes \ -l 'hypershift.openshift.io/nodePool=<node_pool_name>' \ -o jsonpath='{.items[*].metadata.labels}' | grep "node.group.balancing.ignored"$ oc --kubeconfig nested.config get nodes \ -l 'hypershift.openshift.io/nodePool=<node_pool_name>' \ -o jsonpath='{.items[*].metadata.labels}' | grep "node.group.balancing.ignored"Copy to Clipboard Copied! Toggle word wrap Toggle overflow 以下のコマンドを実行して、ホストされたクラスターのクラスター自動スケーリングを有効にします。
oc patch -n <hosted_cluster_namespace> \ hostedcluster <hosted_cluster_name> \ --type=merge \ --patch='{"spec": {"autoscaling": {"balancingIgnoredLabels": ["node.group.balancing.ignored"]}}}'$ oc patch -n <hosted_cluster_namespace> \ hostedcluster <hosted_cluster_name> \ --type=merge \ --patch='{"spec": {"autoscaling": {"balancingIgnoredLabels": ["node.group.balancing.ignored"]}}}'Copy to Clipboard Copied! Toggle word wrap Toggle overflow
検証
各ノードプールによってプロビジョニングされたノードの数が均等に分散されていることを確認します。たとえば、同じラベル値で 3 つのノードプールを作成した場合、ノード数は 3、2、および 3 になる可能性があります。以下のコマンドを実行します。
oc --kubeconfig nested.config get nodes -l 'hypershift.openshift.io/nodePool=<node_pool_name>'
$ oc --kubeconfig nested.config get nodes -l 'hypershift.openshift.io/nodePool=<node_pool_name>'Copy to Clipboard Copied! Toggle word wrap Toggle overflow