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.

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