Kubernetes棄用Docker後怎麼辦?

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"近兩天,Kubernetes在其最新的Changelog中宣佈,自Kubernetes 1.20之後將棄用Docker作爲容器運行時。這一消息在雲原生領域激起了不小的水花,在Rancher技術社區裏許多小夥伴也對此進行了激烈的討論。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Kubernetes爲什麼選擇棄用Docker呢?我們需要先簡單瞭解Dockershim。它是一個橋接服務,幫助Kubernetes與Docker進行通信,Kubelet 之前使用 dockershim 實現對 Docker 的 CRI 支持(Docker本身目前尚未實現CRI)。但時至今日,維護Dockershim已成爲運維\/開發人員的沉重負擔。因此Kubernetes社區建議大家考慮使用包含 CRI 完整實現(兼容 v1alpha1 或 v1)的可用容器運行時。從而取消了對Docker作爲容器運行時的支持。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"不過大家不必過分擔心,近期從Rancher社區裏面蒐集了一些大家比較關注的問題,下面一一爲大家解答:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"1、Kubernetes Kubelet 棄用了Docker作爲容器運行時,有代替方案嗎?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在Kubernetes集羣中,容器運行時負責提取和運行容器鏡像。Docker只是被普遍使用的容器運行時,在Docker被棄用之後,我們還有兩個常見的選項:"},{"type":"text","marks":[{"type":"strong"}],"text":"containerd"},{"type":"text","text":" 和 "},{"type":"text","marks":[{"type":"strong"}],"text":"CRI-O"},{"type":"text","text":"。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Containerd 是一個工業級標準的容器運行時,它極爲簡單、健壯並且具備可移植性。Containerd 可以在宿主機中管理完整的容器生命週期。這是一個100%開源的軟件,已於"},{"type":"link","attrs":{"href":"http:\/\/mp.weixin.qq.com\/s?__biz=MzIyMTUwMDMyOQ==&mid=2247490522&idx=1&sn=288f1fdb5dbc4cc3f338fe66f391d969&chksm=e83a9d1cdf4d140a21c2244ac6b83bfc12309b0bc73d60d32564a843552cbb20781db634208e&scene=21#wechat_redirect","title":"","type":null},"content":[{"type":"text","text":"去年2月份從CNCF"}]},{"type":"text","text":"畢業。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"去年年初,Rancher推出的"},{"type":"link","attrs":{"href":"http:\/\/mp.weixin.qq.com\/s?__biz=MzIyMTUwMDMyOQ==&mid=2247492604&idx=1&sn=897075471e091f70b192546406941827&chksm=e839653adf4eec2c6ff83465acaec9bf788f6b3c0ca2bd6f5f034857880973b145dcc394ca4e&scene=21#wechat_redirect","title":"","type":null},"content":[{"type":"text","text":"輕量級Kubernetes發行版K3s"}]},{"type":"text","text":"已經使用containerd作爲默認容器運行時。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"containerd:https:\/\/github.com\/containerd\/containerd\/"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CRI-O是由Red Hat推出的一款容器運行時,旨在提供一種在OCI一致的運行時和Kubelet之間的集成方式。在文章後半部分我們將會進一步對比containerd和CRI-O的性能,爲您在選擇容器運行時的時候提供參考。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"CRI-O:https:\/\/github.com\/cri-o\/cri-o"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"2、我仍然可以在Kubernetes 1.20中使用Docker嗎?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"是的,如果使用Docker作爲運行時,在1.20中只會在Kubelet啓動時打印一個警告日誌。Kubernetes最早將在2021年末發佈1.23版本中將dockershim移除。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"3、我現有的Docker鏡像仍然可以使用嗎?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"仍然可以使用。Docker生成的鏡像實際上並不是特定於Docker的鏡像,而是OCI(Open Container Initiative)鏡像。無論你使用什麼工具構建鏡像,任何符合OCI標準的鏡像在Kubernetes看來都是一樣的。containerd和CRI-O都能夠提取這些鏡像並運行它們。所以您可以仍然使用Docker來構建容器鏡像,並且可以繼續在containerd和CRI-O上使用。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"4、我應該使用哪個CRI實現?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這是一個比較複雜的問題,它取決於許多因素。如果您之前熟練使用Docker,那麼遷移到containerd應該是一個相對容易的選擇,並且containerd具有更好的性能和更低的成本。當然,您也可以探索CNCF領域中的其他項目,來選擇更適合您的環境。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"來源:https:\/\/kubernetes.io\/blog\/2020\/12\/02\/dockershim-faq\/#which-cri-implementation-should-i-use"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"eBay對containerd和CRI-O進行了一組性能測試,包括創建、啓動、停止和刪除容器,以比較它們所耗的時間。如圖所示,containerd在各個方面都表現良好,除了啓動容器這項。從總用時來看,containerd的用時比cri-o要短。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"以下數據來自"},{"type":"link","attrs":{"href":"http:\/\/mp.weixin.qq.com\/s?__biz=MzA3MDMyNDUzOQ==&mid=2650506128&idx=1&sn=aee08ff704c0a7be5dcf7b3dd8c0438a&chksm=8731bbc4b04632d240b98d12915573addb1c243da18d2b36f32a1f30838877a1ea32fe7cde1f&scene=21#wechat_redirect","title":"","type":null},"content":[{"type":"text","text":"eBay的分享"}]},{"type":"text","text":":"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/yy\/8b\/yyda982b7148320c25fe7c494b74268b.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"containerd和cri-o的性能比較"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.infoq.cn\/resource\/image\/55\/0f\/55d43c7d9b91b3fb4c5420c5549b690f.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"containerd和cri-o的綜合比較"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Rancher,阿里雲,AWS, Google,IBM和Microsoft作爲初始成員(https:\/\/github.com\/containerd\/containerd\/blob\/master\/ADOPTERS.md),共同建設 containerd 社區。2017年3月,Docker 將 containerd 捐獻給CNCF(雲原生計算基金會)。containerd得到了快速的發展和廣泛的支持。Docker引擎已經將containerd作爲容器生命週期管理的基礎,Kubernetes也在2018年5月,正式支持containerd作爲容器運行時管理器。2019年2月,"},{"type":"link","attrs":{"href":"http:\/\/mp.weixin.qq.com\/s?__biz=MzIyMTUwMDMyOQ==&mid=2247490522&idx=1&sn=288f1fdb5dbc4cc3f338fe66f391d969&chksm=e83a9d1cdf4d140a21c2244ac6b83bfc12309b0bc73d60d32564a843552cbb20781db634208e&scene=21#wechat_redirect","title":"","type":null},"content":[{"type":"text","text":"CNCF宣佈containerd畢業"}]},{"type":"text","text":",成爲"},{"type":"text","marks":[{"type":"strong"}],"text":"生產可用的項目"},{"type":"text","text":",更加穩定。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"5、Rancher 對 Containerd 的支持"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Rancher 在輕量級Kubernetes發行版 K3s和 RKE2(2020年10月推出)中早已將 containerd 作爲默認的容器運行時。"},{"type":"text","marks":[{"type":"strong"}],"text":"相信在 Rancher 2.x 支持 Kubernetes 1.20+ 之後會將這些寶貴經驗運用到新版本的Rancher 2.x 迭代中。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其實Kubernetes棄用Docker這一決定已經醞釀很長時間了,可能對於沒有密切關注這個方面的工程師來說有些措手不及。但其實無需特別擔心:如果你是"},{"type":"text","marks":[{"type":"strong"}],"text":"Kubernetes的終端用戶"},{"type":"text","text":",這僅僅是一個後端容器運行時的更改,從使用方面來說幾乎感覺不到區別;如果你是一名"},{"type":"text","marks":[{"type":"strong"}],"text":"開發\/運維人員"},{"type":"text","text":",你依舊可以繼續使用Docker來構建鏡像,以相同的方式將鏡像推送到Registry,並且將這些鏡像部署到你的Kubernetes中;如果你是"},{"type":"text","marks":[{"type":"strong"}],"text":"運行和操作集羣的用戶"},{"type":"text","text":",你只需要將Docker切換成你需要的容器運行時即可。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本文轉載自:RancherLabs(ID:RancherLabs)"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"原文鏈接:"},{"type":"link","attrs":{"href":"https:\/\/mp.weixin.qq.com\/s?__biz=MzIyMTUwMDMyOQ==&mid=2247495062&idx=1&sn=055adc9b434b6255e3d87c8e3d26d0db&chksm=e8396b50df4ee24616fbd4b10f0c485c4e2dc06713e2f8dbcd9250cc8fb62fc66c23de47a95e&mpshare=1&scene=1&srcid=1205FS1hHdOWT1WJdkIOwAW9&sharer_sharetime=1607149503745&sharer_shareid=942119afdfbc37ad9eb04201dfe5b060&key=81a6468567c4ca9471fd81dfa6b5c4bb1116e69c7eaac999aa60599106b7563ac9e4839b81765b306a7758c46abdde2a7cc378f1ead8984924de7ee01c0b894f6222c4867a5b2070e18da55d9241df651b476861663e6372360388aa65d3a4154439e1c3790845ad8b06da4113bd5aa0b123a30e7838a8b5cfb43f373aa6b8b9&ascene=1&uin=NDY1Mzg4MTg4&devicetype=Windows+10+x64&version=63000039&lang=zh_CN&exportkey=A6RQ20TdUVHWa2bIpojAVBM%3D&pass_ticket=SDZTACfaynkyzZdchvC0lVuBNOxy0gbIc4xvr4raR7kSPu%2Fq8XIgEqgQRC2QE670&wx_header=0","title":"xxx","type":null},"content":[{"type":"text","text":"Kubernetes棄用Docker後怎麼辦?"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章