|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * hosted_control_planes/hcp-machine-config.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="balance-ignored-labels-autoscaler-hcp_{context}"] |
| 7 | += Balancing ignored labels in a hosted cluster |
| 8 | + |
| 9 | +After you scale up your node pools, you can use `balancingIgnoredLabels` to evenly distribute the machines across node pools. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You have created the `HostedCluster` and `NodePool` resources. |
| 14 | +
|
| 15 | +.Procedure |
| 16 | + |
| 17 | +. Add the `node.group.balancing.ignored` label to each of the relevant node pool by using the same label value. Run the following command: |
| 18 | ++ |
| 19 | +[source,terminal] |
| 20 | +---- |
| 21 | +$ oc patch -n <hosted_cluster_namespace> \ |
| 22 | + nodepool <node_pool_name> \ |
| 23 | + --type=merge \ |
| 24 | + --patch='{"spec": {"nodeLabels": {"node.group.balancing.ignored": "<label_name>"}}}' |
| 25 | +---- |
| 26 | + |
| 27 | +. Enable cluster autoscaling for your hosted cluster by running the following command: |
| 28 | ++ |
| 29 | +[source,terminal] |
| 30 | +---- |
| 31 | +$ oc patch -n <hosted_cluster_namespace> \ |
| 32 | + hostedcluster <hosted_cluster_name> \ |
| 33 | + --type=merge \ |
| 34 | + --patch='{"spec": {"autoscaling": {"balancingIgnoredLabels": ["node.group.balancing.ignored"]}}}' |
| 35 | +---- |
| 36 | + |
| 37 | +. Remove the `spec.replicas` field from the `NodePool` resource to allow the cluster autoscaler to manage the node count. Run the following command: |
| 38 | ++ |
| 39 | +[source,terminal] |
| 40 | +---- |
| 41 | +$ oc patch -n <hosted_cluster_namespace> \ |
| 42 | + nodepool <node_pool_name> \ |
| 43 | + --type=json \ |
| 44 | + --patch='[{"op": "remove", "path": "/spec/replicas"}]' |
| 45 | +---- |
| 46 | + |
| 47 | +. Enable cluster autoscaling to configure the minimum and maximum node counts for your node pools. Run the following command: |
| 48 | ++ |
| 49 | +[source,terminal] |
| 50 | +---- |
| 51 | +$ oc patch -n <hosted_cluster_namespace> \ |
| 52 | + nodepool <nodepool_name> \ |
| 53 | + --type=merge --patch='{"spec": {"autoScaling": {"max": 3, "min": 1}}}' |
| 54 | +---- |
| 55 | + |
| 56 | +. Generate the `kubeconfig` file by running the following command: |
| 57 | ++ |
| 58 | +[source,terminal] |
| 59 | +---- |
| 60 | +$ hcp create kubeconfig \ |
| 61 | + --name <hosted_cluster_name> \ |
| 62 | + --namespace <hosted_cluster_namespace> > nested.config |
| 63 | +---- |
| 64 | + |
| 65 | +. After scaling up the node pools, check that all worker nodes are in the `Ready` status by running the following command: |
| 66 | ++ |
| 67 | +[source,terminal] |
| 68 | +---- |
| 69 | +$ oc --kubeconfig nested.config get nodes -l 'hypershift.openshift.io/nodePool=<node_pool_name>' |
| 70 | +---- |
| 71 | + |
| 72 | +. Confirm that the new nodes contain the `node.group.balancing.ignored` label by running the following command: |
| 73 | ++ |
| 74 | +[source,terminal] |
| 75 | +---- |
| 76 | +$ oc --kubeconfig nested.config get nodes \ |
| 77 | + -l 'hypershift.openshift.io/nodePool=<node_pool_name>' \ |
| 78 | + -o jsonpath='{.items[*].metadata.labels}' | grep "node.group.balancing.ignored" |
| 79 | +---- |
| 80 | + |
| 81 | +. Enable cluster autoscaling for your hosted cluster by running the following command: |
| 82 | ++ |
| 83 | +[source,terminal] |
| 84 | +---- |
| 85 | +$ oc patch -n <hosted_cluster_namespace> \ |
| 86 | + hostedcluster <hosted_cluster_name> \ |
| 87 | + --type=merge \ |
| 88 | + --patch='{"spec": {"autoscaling": {"balancingIgnoredLabels": ["node.group.balancing.ignored"]}}}' |
| 89 | +---- |
| 90 | + |
| 91 | +.Verification |
| 92 | + |
| 93 | +* Verify that the number of nodes provisioned by each node pool is evenly distributed. For example, if you created three node pools with the same label value, the node counts might be 3, 2, and 3. Run the following command: |
| 94 | ++ |
| 95 | +[source,terminal] |
| 96 | +---- |
| 97 | +$ oc --kubeconfig nested.config get nodes -l 'hypershift.openshift.io/nodePool=<node_pool_name>' |
| 98 | +---- |
0 commit comments