這篇文章主要講解了“怎么搭建一個(gè)集成了containerd的k8s集群”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“怎么搭建一個(gè)集成了containerd的k8s集群”吧!

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡(jiǎn)單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名申請(qǐng)、網(wǎng)絡(luò)空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、路橋網(wǎng)站維護(hù)、網(wǎng)站推廣。
cri (Container runtime interface)
cri is a containerd plugin implementation of Kubernetes container runtime interface (CRI).
cri是 kubernetes的容器運(yùn)行時(shí)接口的容器插件實(shí)現(xiàn)。
<!--more-->
containerd
containerd is an industry-standard container runtime with an emphasis on simplicity, robustness and portability.
containerd完全支持運(yùn)行容器的的CRI運(yùn)行時(shí)規(guī)范。
cri在containerd1.1以上的版本的原生插件。它內(nèi)置于containerd并默認(rèn)啟用。
cri-o
OCI-based implementation of Kubernetes Container Runtime Interface.
kubernetes為了兼容cri和oci孵化了項(xiàng)目cri-o。為了架設(shè)在cri和oci之間的一座橋梁。由此cri-o既兼容cri插件實(shí)現(xiàn)又兼容oci的容器運(yùn)行時(shí)標(biāo)準(zhǔn)。
oci (Open Container Initiative)
oci是由多家公司成立的項(xiàng)目,并由linux基金會(huì)進(jìn)行管理,致力于container runtime 的標(biāo)準(zhǔn)的制定和runc的開發(fā)等工作。
runc
runc is a CLI tool for spawning and running containers according to the OCI specification.
runc,是對(duì)于OCI標(biāo)準(zhǔn)的一個(gè)參考實(shí)現(xiàn),是一個(gè)可以用于創(chuàng)建和運(yùn)行容器的CLI(command-line interface)工具。
由于docker嵌入了太多自身內(nèi)容,為了減輕容器負(fù)擔(dān)。此次選用containerd作為kubernetes的容器實(shí)現(xiàn)方案。
下載containerd二進(jìn)制包。我這里已經(jīng)編譯并打包了好了,內(nèi)含containerd、runc、crictl、ctr等。
runc版本: 1.0.1-dev
containerd版本: v1.2.4
解壓二進(jìn)制包并生成默認(rèn)文件
tar -C /usr/local/bin -xzf containerd-v1.2.4.tar.gz chmod a+x /usr/local/bin/* containerd config default > /etc/containerd/config.toml
生成的默認(rèn)配置文件注意 [grpc] 的 address 字段默認(rèn)為 /run/containerd/containerd.sock
配置文件其他參數(shù)含義參照github地址: https://github.com/containerd/containerd/blob/master/docs/man/containerd-config.toml.5.md
在 /etc/systemd/system 目錄下編寫文件 containerd.service內(nèi)容如下
[Unit] Description=containerd container runtime Documentation=https://containerd.io After=network.target [Service] ExecStartPre=/sbin/modprobe overlay ExecStart=/usr/local/bin/containerd Restart=always RestartSec=5 Delegate=yes KillMode=process OOMScoreAdjust=-999 LimitNOFILE=1048576 # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNPROC=infinity LimitCORE=infinity [Install] WantedBy=multi-user.target
啟動(dòng)containerd
systemctl enable containerd systemctl restart containerd systemctl status containerd
看containerd啟動(dòng)狀態(tài)如果是running就沒有問題。下面我們測(cè)試?yán)∫幌耯ub的鏡像。
測(cè)試containerd
ctr images pull docker.io/library/nginx:alpine
看到輸出done,說明containerd運(yùn)行一切正常。
下一步我們使用crictl連接containerd。
修改crictl的配置文件,在 /etc/crictl.yaml 寫入以下內(nèi)容:
runtime-endpoint: unix:///run/containerd/containerd.sock image-endpoint: unix:///run/containerd/containerd.sock timeout: 10 debug: false
這里注意runtime-endpoint 和image-endpoint 必須與/etc/containerd/config.toml中配置保持一致。
驗(yàn)證一下cri插件是否可用
crictl pull nginx:alpine crictl rmi nginx:alpine crictl images
其中 crictl images 會(huì)列出所有的cri容器鏡像。
到此我們的cri + containerd已經(jīng)完成整合了。下一步我們需要修改kubeadm配置進(jìn)行安裝。
這里我們就需要導(dǎo)入k8s的離線鏡像包了。這里需要注意一下,kubernetes是調(diào)用的cri接口,所以導(dǎo)入時(shí)也需要從cri插件導(dǎo)入鏡像。
cri導(dǎo)入鏡像命令(cri導(dǎo)入鏡像):
ctr cri load images.tar
containerd導(dǎo)入鏡像命令(containerd導(dǎo)入鏡像):
ctr images import images.tar
在 kubelet配置文件 10-kubeadm.conf 的[Service] 結(jié)點(diǎn)加入以下配置:
Environment="KUBELET_EXTRA_ARGS=--container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock"
在kubeadm配置文件 kubeadm.yaml 中加入
apiVersion: kubeadm.k8s.io/v1beta1 kind: InitConfiguration nodeRegistration: criSocket: /run/containerd/containerd.sock name: containerd
到此containerd和kubernetes的集成就完成了。下面可以直接安裝即可。
感謝各位的閱讀,以上就是“怎么搭建一個(gè)集成了containerd的k8s集群”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)怎么搭建一個(gè)集成了containerd的k8s集群這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
本文題目:怎么搭建一個(gè)集成了containerd的k8s集群
當(dāng)前鏈接:http://chinadenli.net/article40/goisho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、響應(yīng)式網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、品牌網(wǎng)站建設(shè)、面包屑導(dǎo)航、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)