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.

142 lines
4.2 KiB

  1. # containerd
  2. [containerd] An industry-standard container runtime with an emphasis on simplicity, robustness and portability
  3. Kubespray supports basic functionality for using containerd as the default container runtime in a cluster.
  4. _To use the containerd container runtime set the following variables:_
  5. ## k8s_cluster.yml
  6. When kube_node contains etcd, you define your etcd cluster to be as well schedulable for Kubernetes workloads. Thus containerd and dockerd can not run at same time, must be set to bellow for running etcd cluster with only containerd.
  7. ```yaml
  8. container_manager: containerd
  9. ```
  10. ## etcd.yml
  11. ```yaml
  12. etcd_deployment_type: host
  13. ```
  14. ## Containerd config
  15. Example: define registry mirror for docker hub
  16. ```yaml
  17. containerd_registries_mirrors:
  18. - prefix: docker.io
  19. mirrors:
  20. - host: https://mirror.gcr.io
  21. capabilities: ["pull", "resolve"]
  22. skip_verify: false
  23. - host: https://registry-1.docker.io
  24. capabilities: ["pull", "resolve"]
  25. skip_verify: false
  26. ```
  27. `containerd_registries_mirrors` is ignored for pulling images when `image_command_tool=nerdctl`
  28. (the default for `container_manager=containerd`). Use `crictl` instead, it supports
  29. `containerd_registries_mirrors` but lacks proper multi-arch support (see
  30. [#8375](https://github.com/kubernetes-sigs/kubespray/issues/8375)):
  31. ```yaml
  32. image_command_tool: crictl
  33. ```
  34. ### Containerd Runtimes
  35. Containerd supports multiple runtime configurations that can be used with
  36. [RuntimeClass] Kubernetes feature. See [runtime classes in containerd] for the
  37. details of containerd configuration.
  38. In kubespray, the default runtime name is "runc", and it can be configured with the `containerd_runc_runtime` dictionary:
  39. ```yaml
  40. containerd_runc_runtime:
  41. name: runc
  42. type: "io.containerd.runc.v2"
  43. engine: ""
  44. root: ""
  45. options:
  46. systemdCgroup: "false"
  47. binaryName: /usr/local/bin/my-runc
  48. base_runtime_spec: cri-base.json
  49. ```
  50. Further runtimes can be configured with `containerd_additional_runtimes`, which
  51. is a list of such dictionaries.
  52. Default runtime can be changed by setting `containerd_default_runtime`.
  53. #### Base runtime specs and limiting number of open files
  54. `base_runtime_spec` key in a runtime dictionary is used to explicitly
  55. specify a runtime spec json file. `runc` runtime has it set to `cri-base.json`,
  56. which is generated with `ctr oci spec > /etc/containerd/cri-base.json` and
  57. updated to include a custom setting for maximum number of file descriptors per
  58. container.
  59. You can change maximum number of file descriptors per container for the default
  60. `runc` runtime by setting the `containerd_base_runtime_spec_rlimit_nofile`
  61. variable.
  62. You can tune many more [settings][runtime-spec] by supplying your own file name and content with `containerd_base_runtime_specs`:
  63. ```yaml
  64. containerd_base_runtime_specs:
  65. cri-spec-custom.json: |
  66. {
  67. "ociVersion": "1.0.2-dev",
  68. "process": {
  69. "user": {
  70. "uid": 0,
  71. ...
  72. ```
  73. The files in this dict will be placed in containerd config directory,
  74. `/etc/containerd` by default. The files can then be referenced by filename in a
  75. runtime:
  76. ```yaml
  77. containerd_runc_runtime:
  78. name: runc
  79. base_runtime_spec: cri-spec-custom.json
  80. ...
  81. ```
  82. Config insecure-registry access to self hosted registries.
  83. ```yaml
  84. containerd_registries_mirrors:
  85. - prefix: test.registry.io
  86. mirrors:
  87. - host: http://test.registry.io
  88. capabilities: ["pull", "resolve"]
  89. skip_verify: true
  90. - prefix: 172.19.16.11:5000
  91. mirrors:
  92. - host: http://172.19.16.11:5000
  93. capabilities: ["pull", "resolve"]
  94. skip_verify: true
  95. - prefix: repo:5000
  96. mirrors:
  97. - host: http://repo:5000
  98. capabilities: ["pull", "resolve"]
  99. skip_verify: true
  100. ```
  101. [containerd]: https://containerd.io/
  102. [RuntimeClass]: https://kubernetes.io/docs/concepts/containers/runtime-class/
  103. [runtime classes in containerd]: https://github.com/containerd/containerd/blob/main/docs/cri/config.md#runtime-classes
  104. [runtime-spec]: https://github.com/opencontainers/runtime-spec
  105. ### Optional : NRI
  106. [Node Resource Interface](https://github.com/containerd/nri) (NRI) is disabled by default for the containerd. If you
  107. are using contained version v1.7.0 or above, then you can enable it with the
  108. following configuration:
  109. ```yaml
  110. nri_enabled: true
  111. ```