|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * nodes/nodes-nodes-resources-configuring.adoc |
| 4 | + |
| 5 | +[id="nodes-nodes-resources-configuring-auto_{context}"] |
| 6 | += Automatically allocating resources for nodes |
| 7 | + |
| 8 | +{product-title} can automatically determine the optimal `system-reserved` CPU and memory resources for nodes associated with a specific machine config pool and update the nodes with those values when the nodes start. |
| 9 | + |
| 10 | +To automatically determine and allocate the `system-reserved` resources on nodes, create a `KubeletConfig` custom resource (CR) to set the `autoSizingReserved: true` parameter. A script on each node calculates the optimal values for the respective reserved resources based on the installed CPU and memory capacity on each node. The script takes into account that increased capacity requires a corresponding increase in the reserved resources. |
| 11 | + |
| 12 | +Automatically determining the optimal `system-reserved` settings ensures that your cluster is running efficiently and prevents node failure due to resource starvation of system components, such as CRI-O and kubelet, without your needing to manually calculate and update the values. |
| 13 | + |
| 14 | +This feature is disabled by default. |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +. Obtain the label associated with the static `MachineConfigPool` object for the type of node you want to configure. |
| 19 | +Perform one of the following steps: |
| 20 | + |
| 21 | +.. View the machine config pool: |
| 22 | ++ |
| 23 | +[source,terminal] |
| 24 | +---- |
| 25 | +$ oc describe machineconfigpool <name> |
| 26 | +---- |
| 27 | ++ |
| 28 | +For example: |
| 29 | ++ |
| 30 | +[source,terminal] |
| 31 | +---- |
| 32 | +$ oc describe machineconfigpool worker |
| 33 | +---- |
| 34 | ++ |
| 35 | +.Example output |
| 36 | +[source,yaml] |
| 37 | +---- |
| 38 | +Name: worker |
| 39 | +Namespace: |
| 40 | +Labels: machineconfiguration.openshift.io/mco-built-in= |
| 41 | + pools.operator.machineconfiguration.openshift.io/worker= |
| 42 | +Annotations: <none> |
| 43 | +API Version: machineconfiguration.openshift.io/v1 |
| 44 | +Kind: MachineConfigPool |
| 45 | +Metadata: |
| 46 | + ... |
| 47 | + creationTimestamp: 2019-02-08T14:52:39Z |
| 48 | + generation: 1 |
| 49 | + labels: |
| 50 | + pools.operator.machineconfiguration.openshift.io/worker: "" <1> |
| 51 | + ... |
| 52 | +---- |
| 53 | +<1> If a label has been added it appears under `labels`. |
| 54 | + |
| 55 | +.. If the label is not present, add a key/value pair: |
| 56 | ++ |
| 57 | +[source,terminal] |
| 58 | +---- |
| 59 | +$ oc label machineconfigpool worker custom-kubelet=small-pods |
| 60 | +---- |
| 61 | + |
| 62 | +.Procedure |
| 63 | + |
| 64 | +. Create a custom resource (CR) for your configuration change: |
| 65 | ++ |
| 66 | +.Sample configuration for a resource allocation CR |
| 67 | +[source,yaml] |
| 68 | +---- |
| 69 | +apiVersion: machineconfiguration.openshift.io/v1 |
| 70 | +kind: KubeletConfig |
| 71 | +metadata: |
| 72 | + name: dynamic-node <1> |
| 73 | +spec: |
| 74 | + autoSizingReserved: true <2> |
| 75 | + machineConfigPoolSelector: |
| 76 | + matchLabels: |
| 77 | + pools.operator.machineconfiguration.openshift.io/worker: "" <3> |
| 78 | +---- |
| 79 | +<1> Assign a name to CR. |
| 80 | +<2> Add the `autoSizingReserved` parameter set to `true` to allow {product-title} to automatically determine and allocate the `system-reserved` resources on the nodes associated with the specified label. To disable automatic allocation on those nodes, set this parameter to `false`. |
| 81 | +<3> Specify the label from the machine config pool. |
| 82 | ++ |
| 83 | +The previous example enables automatic resource allocation on all worker nodes. {product-title} drains the nodes, applies the kubelet config, and restarts the nodes. |
| 84 | + |
| 85 | +. Verify the `system-reserved` value: |
| 86 | + |
| 87 | +.. Log in to a node you configured: |
| 88 | ++ |
| 89 | +[source,terminal] |
| 90 | +---- |
| 91 | +$ oc debug node/<node_name> |
| 92 | +---- |
| 93 | + |
| 94 | +.. View details on the kubelet process: |
| 95 | ++ |
| 96 | +[source,terminal] |
| 97 | +---- |
| 98 | +# ps -ef | grep kubelet |
| 99 | +---- |
| 100 | ++ |
| 101 | +.Example output |
| 102 | +[source,terminal] |
| 103 | +---- |
| 104 | +root 1613 1 11 06:49 ? 00:00:05 kubelet --config=/etc/kubernetes/kubelet.conf --bootstrap-kubeconfig=/etc/kubernetes/kubeconfig --kubeconfig=/var/lib/kubelet/kubeconfig --container-runtime=remote --container-runtime-endpoint=/var/run/crio/crio.sock --runtime-cgroups=/system.slice/crio.service --node-labels=node-role.kubernetes.io/worker,node.openshift.io/os_id=rhcos --node-ip= --minimum-container-ttl-duration=6m0s --volume-plugin-dir=/etc/kubernetes/kubelet-plugins/volume/exec --cloud-provider=azure --cloud-config=/etc/kubernetes/cloud.conf --pod-infra-container-image=quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:7b8e2e2857d8ac3499c9eb4e449cc3296409f1da21aa21d0140134d611e65b84 --system-reserved=cpu=0.07,memory=2.5Gi --v=2 |
| 105 | +---- |
| 106 | ++ |
| 107 | +In the previous example, the worker nodes are allocated `0.07` CPU and 2.5 Gi of memory. It can take several minutes for the optimal values to appear. |
0 commit comments