From e7d29715b4e0a3b3deb18d3afdfbd8c618e6fae0 Mon Sep 17 00:00:00 2001
From: Tom M <tom.mbrt@googlemail.com>
Date: Fri, 22 Mar 2024 20:21:39 +0100
Subject: [PATCH] Add kubelet_cpu_manager_policy_options (#11023)

---
 docs/vars.md                                              | 8 ++++++++
 .../node/templates/kubelet-config.v1beta1.yaml.j2         | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/docs/vars.md b/docs/vars.md
index 4f20f59a9..1c36e6734 100644
--- a/docs/vars.md
+++ b/docs/vars.md
@@ -220,6 +220,14 @@ Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/dns-stack.m
 
 * *kubelet_cpu_manager_policy* -  If set to `static`, allows pods with certain resource characteristics to be granted increased CPU affinity and exclusivity on the node. And it should be set with `kube_reserved` or `system-reserved`, enable this with the following guide:[Control CPU Management Policies on the Node](https://kubernetes.io/docs/tasks/administer-cluster/cpu-management-policies/)
 
+* *kubelet_cpu_manager_policy_options* -  A dictionary of cpuManagerPolicyOptions to enable. Keep in mind to enable the corresponding feature gates and make sure to pass the booleans as string (i.e. don't forget the quotes)!
+
+```yml
+kubelet_cpu_manager_policy_options:
+    distribute-cpus-across-numa: "true"
+    full-pcpus-only: "true"
+```
+
 * *kubelet_topology_manager_policy* - Control the behavior of the allocation of CPU and Memory from different [NUMA](https://en.wikipedia.org/wiki/Non-uniform_memory_access) Nodes. Enable this with the following guide: [Control Topology Management Policies on a node](https://kubernetes.io/docs/tasks/administer-cluster/topology-manager).
 
 * *kubelet_topology_manager_scope* - The Topology Manager can deal with the alignment of resources in a couple of distinct scopes: `container` and `pod`. See [Topology Manager Scopes](https://kubernetes.io/docs/tasks/administer-cluster/topology-manager/#topology-manager-scopes).
diff --git a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
index ba90fc9c8..3d76ba485 100644
--- a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
+++ b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
@@ -160,6 +160,10 @@ seccompDefault: {{ kubelet_seccomp_default | bool }}
 {% if kubelet_cpu_manager_policy is defined %}
 cpuManagerPolicy: {{ kubelet_cpu_manager_policy }}
 {% endif %}
+{% if kubelet_cpu_manager_policy_options is defined %}
+cpuManagerPolicyOptions:
+  {{ kubelet_cpu_manager_policy_options | to_nice_yaml(indent=2) }}
+{% endif %}
 {% if kubelet_topology_manager_policy is defined %}
 topologyManagerPolicy: {{ kubelet_topology_manager_policy }}
 {% endif %}
-- 
GitLab