You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.4 KiB

  1. # cgroups
  2. To avoid the rivals for resources between containers or the impact on the host in Kubernetes, the kubelet components will rely on cgroups to limit the container’s resources usage.
  3. ## Enforcing Node Allocatable
  4. You can use `kubelet_enforce_node_allocatable` to set node allocatable enforcement.
  5. ```yaml
  6. # A comma separated list of levels of node allocatable enforcement to be enforced by kubelet.
  7. kubelet_enforce_node_allocatable: "pods"
  8. # kubelet_enforce_node_allocatable: "pods,kube-reserved"
  9. # kubelet_enforce_node_allocatable: "pods,kube-reserved,system-reserved"
  10. ```
  11. Note that to enforce kube-reserved or system-reserved, `kube_reserved_cgroups` or `system_reserved_cgroups` needs to be specified respectively.
  12. Here is an example:
  13. ```yaml
  14. kubelet_enforce_node_allocatable: "pods,kube-reserved,system-reserved"
  15. # Reserve this space for kube resources
  16. # Set to true to reserve resources for kube daemons
  17. kube_reserved: true
  18. kube_reserved_cgroups_for_service_slice: kube.slice
  19. kube_reserved_cgroups: "/{{ kube_reserved_cgroups_for_service_slice }}"
  20. kube_memory_reserved: 256Mi
  21. kube_cpu_reserved: 100m
  22. # kube_ephemeral_storage_reserved: 2Gi
  23. # kube_pid_reserved: "1000"
  24. # Reservation for master hosts
  25. kube_master_memory_reserved: 512Mi
  26. kube_master_cpu_reserved: 200m
  27. # kube_master_ephemeral_storage_reserved: 2Gi
  28. # kube_master_pid_reserved: "1000"
  29. # Set to true to reserve resources for system daemons
  30. system_reserved: true
  31. system_reserved_cgroups_for_service_slice: system.slice
  32. system_reserved_cgroups: "/{{ system_reserved_cgroups_for_service_slice }}"
  33. system_memory_reserved: 512Mi
  34. system_cpu_reserved: 500m
  35. # system_ephemeral_storage_reserved: 2Gi
  36. # system_pid_reserved: "1000"
  37. # Reservation for master hosts
  38. system_master_memory_reserved: 256Mi
  39. system_master_cpu_reserved: 250m
  40. # system_master_ephemeral_storage_reserved: 2Gi
  41. # system_master_pid_reserved: "1000"
  42. ```
  43. After the setup, the cgroups hierarchy is as follows:
  44. ```bash
  45. / (Cgroups Root)
  46. ├── kubepods.slice
  47. │ ├── ...
  48. │ ├── kubepods-besteffort.slice
  49. │ ├── kubepods-burstable.slice
  50. │ └── ...
  51. ├── kube.slice
  52. │ ├── ...
  53. │ ├── {{container_manager}}.service
  54. │ ├── kubelet.service
  55. │ └── ...
  56. ├── system.slice
  57. │ └── ...
  58. └── ...
  59. ```
  60. You can learn more in the [official kubernetes documentation](https://kubernetes.io/docs/tasks/administer-cluster/reserve-compute-resources/).