Rate This Document
Findability
Accuracy
Completeness
Readability

Configuring the Kubernetes Topology Manager

To configure the Kubernetes Topology Manager, modify kubelet.service and the kubelet configuration file.

  1. Comment out ExecStart of kubelet.service. If ExecStart is not commented out, a message is displayed indicating that multiple ExecStarts exist.
    1. Open the file.
      1
      vi /usr/lib/systemd/system/kubelet.service
      
    2. Press i to enter the insert mode. Add # before ExecStart=/usr/bin/kubelet to comment out the content.
      1
      #ExecStart=/usr/bin/kubelet
      
    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  2. Modify the kubelet configuration file to enable the topology management policy.

    --topology-manager-policy options:

    • single-numa-node
    • best-effort
    • restricted
    • none
    1. Open the file.
      1
      vi /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      # Note: This dropin only works with kubeadm and kubelet v1.11+
      [Service]
      Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
      Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
      # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
      EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
      # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
      # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
      EnvironmentFile=-/etc/sysconfig/kubelet
      
    2. Add the two lines:
      1
      2
      ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/cpuset/system.slice/kubelet.service
      ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/hugetlb/system.slice/kubelet.service
      
    3. Add the configuration switches of CPU Manager and Topology Manager:
      1
      ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS --kube-reserved=cpu=2,memory=250Mi --cpu-manager-policy=static --feature-gates=CPUManager=true,TopologyManager=true --topology-manager-policy=single-numa-node
      
    4. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.