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.

144 lines
4.3 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. The `containerd_registries` and `containerd_insecure_registries` configs are deprecated.
  35. ### Containerd Runtimes
  36. Containerd supports multiple runtime configurations that can be used with
  37. [RuntimeClass] Kubernetes feature. See [runtime classes in containerd] for the
  38. details of containerd configuration.
  39. In kubespray, the default runtime name is "runc", and it can be configured with the `containerd_runc_runtime` dictionary:
  40. ```yaml
  41. containerd_runc_runtime:
  42. name: runc
  43. type: "io.containerd.runc.v2"
  44. engine: ""
  45. root: ""
  46. options:
  47. systemdCgroup: "false"
  48. binaryName: /usr/local/bin/my-runc
  49. base_runtime_spec: cri-base.json
  50. ```
  51. Further runtimes can be configured with `containerd_additional_runtimes`, which
  52. is a list of such dictionaries.
  53. Default runtime can be changed by setting `containerd_default_runtime`.
  54. #### Base runtime specs and limiting number of open files
  55. `base_runtime_spec` key in a runtime dictionary is used to explicitly
  56. specify a runtime spec json file. `runc` runtime has it set to `cri-base.json`,
  57. which is generated with `ctr oci spec > /etc/containerd/cri-base.json` and
  58. updated to include a custom setting for maximum number of file descriptors per
  59. container.
  60. You can change maximum number of file descriptors per container for the default
  61. `runc` runtime by setting the `containerd_base_runtime_spec_rlimit_nofile`
  62. variable.
  63. You can tune many more [settings][runtime-spec] by supplying your own file name and content with `containerd_base_runtime_specs`:
  64. ```yaml
  65. containerd_base_runtime_specs:
  66. cri-spec-custom.json: |
  67. {
  68. "ociVersion": "1.0.2-dev",
  69. "process": {
  70. "user": {
  71. "uid": 0,
  72. ...
  73. ```
  74. The files in this dict will be placed in containerd config directory,
  75. `/etc/containerd` by default. The files can then be referenced by filename in a
  76. runtime:
  77. ```yaml
  78. containerd_runc_runtime:
  79. name: runc
  80. base_runtime_spec: cri-spec-custom.json
  81. ...
  82. ```
  83. Config insecure-registry access to self hosted registries.
  84. ```yaml
  85. containerd_registries_mirrors:
  86. - prefix: test.registry.io
  87. mirrors:
  88. - host: http://test.registry.io
  89. capabilities: ["pull", "resolve"]
  90. skip_verify: true
  91. - prefix: 172.19.16.11:5000
  92. mirrors:
  93. - host: http://172.19.16.11:5000
  94. capabilities: ["pull", "resolve"]
  95. skip_verify: true
  96. - prefix: repo:5000
  97. mirrors:
  98. - host: http://repo:5000
  99. capabilities: ["pull", "resolve"]
  100. skip_verify: true
  101. ```
  102. [containerd]: https://containerd.io/
  103. [RuntimeClass]: https://kubernetes.io/docs/concepts/containers/runtime-class/
  104. [runtime classes in containerd]: https://github.com/containerd/containerd/blob/main/docs/cri/config.md#runtime-classes
  105. [runtime-spec]: https://github.com/opencontainers/runtime-spec
  106. ### Optional : NRI
  107. [Node Resource Interface](https://github.com/containerd/nri) (NRI) is disabled by default for the containerd. If you
  108. are using contained version v1.7.0 or above, then you can enable it with the
  109. following configuration:
  110. ```yaml
  111. nri_enabled: true
  112. ```