当前位置:  首页>> 技术小册>> Kubernetes合辑1-安装Kubernetes

containerd 部署方式有两种,一种是使用 docker-ce 仓库进行安装,另一种是下载二进制包手动安装,这里选择比较麻烦的后者。

安装containerd的详细文档在 github 页面,需要注意,CNI插件我们通过Kubernetes仓库安装
containerd 可以从 release 界面下载,我们使用的是 1.6.4 版本,1.6.3 存在Bug
runc 可以从 release 界面下载,我们使用的是 1.1.1 版本

  1. [root@maxiaoke deploy-kubernetes]# cd containerd/
  2. [root@maxiaoke containerd]# wget https://github.com/containerd/containerd/releases/download/v1.6.4/containerd-1.6.4-linux-amd64.tar.gz
  3. [root@maxiaoke containerd]# wget -O runc https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64
  4. [root@maxiaoke containerd]# tar -tf containerd-1.6.4-linux-amd64.tar.gz
  5. bin/
  6. bin/containerd-stress
  7. bin/ctr
  8. bin/containerd-shim-runc-v1
  9. bin/containerd
  10. bin/containerd-shim
  11. bin/containerd-shim-runc-v2
  1. [root@maxiaoke deploy-kubernetes]# gosh push -i node.ip containerd/containerd-1.6.4-linux-amd64.tar.gz /tmp/
  2. [root@maxiaoke deploy-kubernetes]# gosh cmd -i node.ip "tar -xf /tmp/containerd-1.6.4-linux-amd64.tar.gz -C /usr/local"
  3. [root@maxiaoke deploy-kubernetes]# gosh push -i node.ip containerd/containerd.service /usr/lib/systemd/system/ # 文件内容在下个代码块中
  4. [root@maxiaoke deploy-kubernetes]# gosh cmd -i node.ip "mkdir /etc/containerd"
  5. [root@maxiaoke deploy-kubernetes]# gosh push -i node.ip containerd/config.toml /etc/containerd/
  6. [root@maxiaoke deploy-kubernetes]# chmod +x containerd/runc
  7. [root@maxiaoke deploy-kubernetes]# gosh push -i node.ip containerd/runc /usr/local/bin/
  8. [root@maxiaoke deploy-kubernetes]# gosh cmd -i node.ip "systemctl daemon-reload; systemctl start containerd ; systemctl enable containerd "

containerd/containerd.service:

  1. # Copyright The containerd Authors.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. [Unit]
  15. Description=containerd container runtime
  16. Documentation=https://containerd.io
  17. After=network.target local-fs.target
  18. [Service]
  19. # 这里面主动加载了 overlay,所以上述的 k8s-module.conf 中才没有添加
  20. ExecStartPre=-/sbin/modprobe overlay
  21. ExecStart=/usr/local/bin/containerd
  22. Type=notify
  23. Delegate=yes
  24. KillMode=process
  25. Restart=always
  26. RestartSec=5
  27. # Having non-zero Limit*s causes performance problems due to accounting overhead
  28. # in the kernel. We recommend using cgroups to do container-local accounting.
  29. LimitNPROC=infinity
  30. LimitCORE=infinity
  31. LimitNOFILE=infinity
  32. # Comment TasksMax if your systemd version does not supports it.
  33. # Only systemd 226 and above support this version.
  34. TasksMax=infinity
  35. OOMScoreAdjust=-999
  36. [Install]
  37. WantedBy=multi-user.target

containerd/config.toml:

  1. disabled_plugins = []
  2. imports = []
  3. oom_score = 0
  4. plugin_dir = ""
  5. required_plugins = []
  6. root = "/var/lib/containerd"
  7. state = "/run/containerd"
  8. temp = ""
  9. version = 2
  10. [cgroup]
  11. path = ""
  12. [debug]
  13. address = ""
  14. format = ""
  15. gid = 0
  16. level = ""
  17. uid = 0
  18. [grpc]
  19. address = "/run/containerd/containerd.sock"
  20. gid = 0
  21. max_recv_message_size = 16777216
  22. max_send_message_size = 16777216
  23. tcp_address = ""
  24. tcp_tls_ca = ""
  25. tcp_tls_cert = ""
  26. tcp_tls_key = ""
  27. uid = 0
  28. [metrics]
  29. address = ""
  30. grpc_histogram = false
  31. [plugins]
  32. [plugins."io.containerd.gc.v1.scheduler"]
  33. deletion_threshold = 0
  34. mutation_threshold = 100
  35. pause_threshold = 0.02
  36. schedule_delay = "0s"
  37. startup_delay = "100ms"
  38. [plugins."io.containerd.grpc.v1.cri"]
  39. device_ownership_from_security_context = false
  40. disable_apparmor = false
  41. disable_cgroup = false
  42. disable_hugetlb_controller = true
  43. disable_proc_mount = false
  44. disable_tcp_service = true
  45. enable_selinux = false
  46. enable_tls_streaming = false
  47. enable_unprivileged_icmp = false
  48. enable_unprivileged_ports = false
  49. ignore_image_defined_volumes = false
  50. max_concurrent_downloads = 3
  51. max_container_log_line_size = 16384
  52. netns_mounts_under_state_dir = false
  53. restrict_oom_score_adj = false
  54. sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.6"
  55. selinux_category_range = 1024
  56. stats_collect_period = 10
  57. stream_idle_timeout = "4h0m0s"
  58. stream_server_address = "127.0.0.1"
  59. stream_server_port = "0"
  60. systemd_cgroup = false
  61. tolerate_missing_hugetlb_controller = true
  62. unset_seccomp_profile = ""
  63. [plugins."io.containerd.grpc.v1.cri".cni]
  64. bin_dir = "/opt/cni/bin"
  65. conf_dir = "/etc/cni/net.d"
  66. conf_template = ""
  67. ip_pref = ""
  68. max_conf_num = 1
  69. [plugins."io.containerd.grpc.v1.cri".containerd]
  70. default_runtime_name = "runc"
  71. disable_snapshot_annotations = true
  72. discard_unpacked_layers = false
  73. ignore_rdt_not_enabled_errors = false
  74. no_pivot = false
  75. snapshotter = "overlayfs"
  76. [plugins."io.containerd.grpc.v1.cri".containerd.default_runtime]
  77. base_runtime_spec = ""
  78. cni_conf_dir = ""
  79. cni_max_conf_num = 0
  80. container_annotations = []
  81. pod_annotations = []
  82. privileged_without_host_devices = false
  83. runtime_engine = ""
  84. runtime_path = ""
  85. runtime_root = ""
  86. runtime_type = ""
  87. [plugins."io.containerd.grpc.v1.cri".containerd.default_runtime.options]
  88. [plugins."io.containerd.grpc.v1.cri".containerd.runtimes]
  89. [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
  90. base_runtime_spec = ""
  91. cni_conf_dir = ""
  92. cni_max_conf_num = 0
  93. container_annotations = []
  94. pod_annotations = []
  95. privileged_without_host_devices = false
  96. runtime_engine = ""
  97. runtime_path = ""
  98. runtime_root = ""
  99. runtime_type = "io.containerd.runc.v2"
  100. [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
  101. BinaryName = ""
  102. CriuImagePath = ""
  103. CriuPath = ""
  104. CriuWorkPath = ""
  105. IoGid = 0
  106. IoUid = 0
  107. NoNewKeyring = false
  108. NoPivotRoot = false
  109. Root = ""
  110. ShimCgroup = ""
  111. SystemdCgroup = true
  112. [plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime]
  113. base_runtime_spec = ""
  114. cni_conf_dir = ""
  115. cni_max_conf_num = 0
  116. container_annotations = []
  117. pod_annotations = []
  118. privileged_without_host_devices = false
  119. runtime_engine = ""
  120. runtime_path = ""
  121. runtime_root = ""
  122. runtime_type = ""
  123. [plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime.options]
  124. [plugins."io.containerd.grpc.v1.cri".image_decryption]
  125. key_model = "node"
  126. [plugins."io.containerd.grpc.v1.cri".registry]
  127. config_path = ""
  128. [plugins."io.containerd.grpc.v1.cri".registry.auths]
  129. [plugins."io.containerd.grpc.v1.cri".registry.configs]
  130. [plugins."io.containerd.grpc.v1.cri".registry.headers]
  131. [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
  132. [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
  133. endpoint = ["https://q2gr04ke.mirror.aliyuncs.com"]
  134. [plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming]
  135. tls_cert_file = ""
  136. tls_key_file = ""
  137. [plugins."io.containerd.internal.v1.opt"]
  138. path = "/opt/containerd"
  139. [plugins."io.containerd.internal.v1.restart"]
  140. interval = "10s"
  141. [plugins."io.containerd.internal.v1.tracing"]
  142. sampling_ratio = 1.0
  143. service_name = "containerd"
  144. [plugins."io.containerd.metadata.v1.bolt"]
  145. content_sharing_policy = "shared"
  146. [plugins."io.containerd.monitor.v1.cgroups"]
  147. no_prometheus = false
  148. [plugins."io.containerd.runtime.v1.linux"]
  149. no_shim = false
  150. runtime = "runc"
  151. runtime_root = ""
  152. shim = "containerd-shim"
  153. shim_debug = false
  154. [plugins."io.containerd.runtime.v2.task"]
  155. platforms = ["linux/amd64"]
  156. sched_core = false
  157. [plugins."io.containerd.service.v1.diff-service"]
  158. default = ["walking"]
  159. [plugins."io.containerd.service.v1.tasks-service"]
  160. rdt_config_file = ""
  161. [plugins."io.containerd.snapshotter.v1.aufs"]
  162. root_path = ""
  163. [plugins."io.containerd.snapshotter.v1.btrfs"]
  164. root_path = ""
  165. [plugins."io.containerd.snapshotter.v1.devmapper"]
  166. async_remove = false
  167. base_image_size = ""
  168. discard_blocks = false
  169. fs_options = ""
  170. fs_type = ""
  171. pool_name = ""
  172. root_path = ""
  173. [plugins."io.containerd.snapshotter.v1.native"]
  174. root_path = ""
  175. [plugins."io.containerd.snapshotter.v1.overlayfs"]
  176. root_path = ""
  177. upperdir_label = false
  178. [plugins."io.containerd.snapshotter.v1.zfs"]
  179. root_path = ""
  180. [plugins."io.containerd.tracing.processor.v1.otlp"]
  181. endpoint = ""
  182. insecure = false
  183. protocol = ""
  184. [proxy_plugins]
  185. [stream_processors]
  186. [stream_processors."io.containerd.ocicrypt.decoder.v1.tar"]
  187. accepts = ["application/vnd.oci.image.layer.v1.tar+encrypted"]
  188. args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
  189. env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]
  190. path = "ctd-decoder"
  191. returns = "application/vnd.oci.image.layer.v1.tar"
  192. [stream_processors."io.containerd.ocicrypt.decoder.v1.tar.gzip"]
  193. accepts = ["application/vnd.oci.image.layer.v1.tar+gzip+encrypted"]
  194. args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
  195. env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]
  196. path = "ctd-decoder"
  197. returns = "application/vnd.oci.image.layer.v1.tar+gzip"
  198. [timeouts]
  199. "io.containerd.timeout.bolt.open" = "0s"
  200. "io.containerd.timeout.shim.cleanup" = "5s"
  201. "io.containerd.timeout.shim.load" = "5s"
  202. "io.containerd.timeout.shim.shutdown" = "3s"
  203. "io.containerd.timeout.task.state" = "2s"
  204. [ttrpc]
  205. address = ""
  206. gid = 0
  207. uid = 0

该分类下的相关小册推荐: