自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

一篇帶你弄懂Containerd vs Docker

運(yùn)維 系統(tǒng)運(yùn)維
containerd與docker還是有很多不同之處,但最終要實(shí)現(xiàn)的效果都一致。至于我們?cè)谑褂胟8s過程中,具體使用哪一種作為運(yùn)行時(shí),還是根據(jù)實(shí)際情況選擇。

[[435278]]

引言

最近公司打算在新的產(chǎn)品中不再使用docker,而是使用containerd作為運(yùn)行時(shí)。至于原因嘛,沒有直接告訴我們。于是,我就打算自己去了解一番;并與docker做個(gè)對(duì)比,看看兩者的差異。

介紹

docker相信大家已經(jīng)非常熟悉了,我就不介紹了。這里來介紹一下containerd。github上針對(duì)containerd的介紹如下:

  1. containerd is an industry-standard container runtime with an emphasis on simplicity, robustness and portability.  
  2. It is available as a daemon for Linux and Windows,  
  3. which can manage the complete container lifecycle of its host system: image transfer and storage,  
  4. container execution and supervision, low-level storage and network attachments, etc. 

大致意思就是說Containerd是一個(gè)強(qiáng)調(diào)簡(jiǎn)單性、健壯性和可移植性的行業(yè)標(biāo)準(zhǔn)容器運(yùn)行時(shí)??梢栽趙indows和linux上使用,能夠管理宿主機(jī)上容器整個(gè)生命周期,包括鏡像傳輸、容器創(chuàng)建和管理,低級(jí)別的存儲(chǔ)和網(wǎng)絡(luò)附件等等。其架構(gòu)如下:

功能

使用過docker的朋友肯定對(duì)docker很熟悉了。這里就只說一下containerd的功能。containerd的功能如下:

  • 支持 OCI 的鏡像標(biāo)準(zhǔn)
  • OCI 的容器運(yùn)行時(shí)
  • 鏡像的推送和拉取
  • 容器運(yùn)行時(shí)生命周期管理
  • 多租戶的鏡像存儲(chǔ)
  • 網(wǎng)絡(luò)管理以及網(wǎng)絡(luò) namespace 管理,支持容器網(wǎng)絡(luò)加入已有的 namespace

對(duì)比

接下來,對(duì)docker和containerd進(jìn)行一個(gè)多方面的比較??纯磧烧呔烤褂心男┤眲e,也幫助大家以后進(jìn)行選擇合適的去用。

調(diào)用鏈

在使用k8s時(shí),使用docker和containerd的調(diào)用鏈如下所示:

不難看出,使用containerd時(shí),調(diào)用鏈更短,不再需要經(jīng)過dockershim和docker

數(shù)據(jù)目錄

相信大家都知道docker的數(shù)據(jù)目錄默認(rèn)是在/var/lib/docker目錄下;而切換到containerd時(shí),數(shù)據(jù)目錄默認(rèn)為/var/lib/containerd

日志

當(dāng)我們?cè)谑褂胟8s時(shí),如果使用了docker作為運(yùn)行時(shí),其實(shí)容器程序日志的落盤是由docker來負(fù)責(zé)的。/var/log/pod和/var/log/container下的日志文件會(huì)軟連接到/var/lib/docker下對(duì)應(yīng)的日志文件,如果還需要對(duì)日志做一些參數(shù)配置,直接修改docker配置文件即可;而如果我們現(xiàn)在使用containerd作為運(yùn)行時(shí),則容器日志的落盤將由kubelet來負(fù)責(zé),/var/log/container下的日志文件會(huì)軟連接到/var/log/pod下的日志文件,如果需要調(diào)整日志參數(shù),則需要修改kubelet相關(guān)配置

CNI

當(dāng)使用docker作為運(yùn)行時(shí)時(shí),kubelet中的docker-shim負(fù)責(zé)調(diào)用cni;而當(dāng)使用containerd作為運(yùn)行時(shí)時(shí),containerd中內(nèi)置的containerd-cri負(fù)責(zé)調(diào)用cni

  1. [plugins."io.containerd.grpc.v1.cri".cni] 
  2.       bin_dir = "/opt/cni/bin" 
  3.       conf_dir = "/etc/cni/net.d" 

流服務(wù)

熟悉k8s的朋友都知道,kubectl exec 和 kubelet log等命令需要通過apiserver與容器通信,這其中就涉及到了流服務(wù)。而docker API本身支持,kubelet中的docker-shim通過docker API流轉(zhuǎn)發(fā);但containerd卻要對(duì)此進(jìn)行單獨(dú)配置

  1. [plugins."io.containerd.grpc.v1.cri"
  2.     stream_idle_timeout = "4h0m0s" 
  3.     stream_server_address = "127.0.0.1" 
  4.     stream_server_port = "0" 
  5.     enable_tls_streaming = false 

命令

使用containerd作為運(yùn)行時(shí)后,常用的命令也變了。下面舉兩個(gè)例子。另外,使用containerd時(shí),可以安裝nerdctl工具配合containerd的namespace來一起使用,這樣就跟使用docker命令一樣了

命名空間

containerd引入了namespace。名稱空間允許多個(gè)使用者使用同一容器,彼此之間不會(huì)發(fā)生沖突。它的優(yōu)點(diǎn)是可以共享內(nèi)容,但仍然與容器和鏡像分離。所以,在使用containerd相關(guān)命令時(shí),需要添加-n namespace參數(shù)。

  1. Namespaces allow multiple consumers to use the same containerd without conflicting with each other.  
  2. It has the benefit of sharing content but still having separation with containers and images. 

總結(jié)

總體來看,containerd與docker還是有很多不同之處,但最終要實(shí)現(xiàn)的效果都一致。至于我們?cè)谑褂胟8s過程中,具體使用哪一種作為運(yùn)行時(shí),還是根據(jù)實(shí)際情況選擇。

參考

https://github.com/containerd/containerd

本文轉(zhuǎn)載自微信公眾號(hào)「運(yùn)維開發(fā)故事」

 

責(zé)任編輯:姜華 來源: 運(yùn)維開發(fā)故事
相關(guān)推薦

2023-02-28 23:04:15

2022-05-30 18:18:23

NoSQL數(shù)據(jù)庫

2022-02-23 09:36:11

GoRuby編程語言

2022-02-17 08:35:59

OLTPOLAP數(shù)據(jù)倉庫

2024-12-26 16:49:20

Python字典元素

2021-06-30 10:01:09

Python字典代碼

2021-06-16 10:03:37

Python案例分析Python基礎(chǔ)

2022-03-11 08:32:53

C代碼代碼編輯vscode

2022-02-18 08:54:21

docker操作系統(tǒng)Linux

2022-02-22 08:15:59

微服務(wù)架構(gòu)單體架構(gòu)

2021-01-07 11:10:47

關(guān)鍵字

2021-07-03 10:02:30

Python字符串瀏覽器

2021-10-15 07:57:04

Docker 日志容器

2021-06-09 09:00:11

Python數(shù)據(jù)類型基礎(chǔ)

2024-11-27 16:38:07

2021-06-05 10:02:15

Python進(jìn)制數(shù)據(jù)類型

2024-05-10 13:46:36

Python進(jìn)制

2021-05-20 06:57:16

RabbitMQ開源消息

2023-04-20 08:00:00

ES搜索引擎MySQL

2018-10-22 12:50:20

CDN網(wǎng)絡(luò)內(nèi)容發(fā)布網(wǎng)絡(luò)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)