<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>containerd on 青云卷</title><link>https://mydream.ink/tags/containerd/</link><description>Recent content in containerd on 青云卷</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><copyright>Copyright © 2018–2023</copyright><lastBuildDate>Sat, 18 Mar 2023 18:04:55 +0800</lastBuildDate><atom:link href="https://mydream.ink/tags/containerd/index.xml" rel="self" type="application/rss+xml"/><item><title>通过 kubeadm 安装 kubernetes 1.26</title><link>https://mydream.ink/posts/cloud-native/kubernetes/install-kubenetes-1.26-by-kubeadm/</link><pubDate>Sat, 18 Mar 2023 18:04:55 +0800</pubDate><guid>https://mydream.ink/posts/cloud-native/kubernetes/install-kubenetes-1.26-by-kubeadm/</guid><description>&lt;h1 id="环境准备">环境准备&lt;/h1>
&lt;p>master 节点使用 cri-o、worker 节点使用 containerd 作为运行时&lt;/p>
&lt;h2 id="master-节点">master 节点&lt;/h2>
&lt;ul>
&lt;li>操作系统：Ubuntu Server 22.04 LTS&lt;/li>
&lt;li>规格：2c4g&lt;/li>
&lt;li>cloud-master1 10.67.3.9&lt;/li>
&lt;li>cloud-master2 10.67.3.13&lt;/li>
&lt;li>cloud-master3 10.67.3.15&lt;/li>
&lt;/ul>
&lt;h2 id="worker-节点">worker 节点&lt;/h2>
&lt;ul>
&lt;li>操作系统：Ubuntu Server 22.04 LTS&lt;/li>
&lt;li>规格：2c2g&lt;/li>
&lt;li>VM-2-42-ubuntu 10.67.2.42&lt;/li>
&lt;/ul>
&lt;h2 id="负载均衡">负载均衡&lt;/h2>
&lt;ul>
&lt;li>43.135.64.117&lt;/li>
&lt;/ul>
&lt;h1 id="节点配置">节点配置&lt;/h1>
&lt;p>所有节点都需要的初始化配置，含 master 和 worker 节点&lt;/p>
&lt;h2 id="安装-kubeadmkubeletkubectl">安装 kubeadm、kubelet、kubectl&lt;/h2>
&lt;ol>
&lt;li>
&lt;p>更新 &lt;code>apt&lt;/code> 包索引并安装使用 Kubernetes &lt;code>apt&lt;/code> 仓库所需要的包：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get install -y apt-transport-https ca-certificates curl
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>下载 Google Cloud 公开签名秘钥：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>添加 Kubernetes &lt;code>apt&lt;/code> 仓库：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">echo&lt;/span> &lt;span style="color:#d88200">&amp;#34;deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main&amp;#34;&lt;/span> &lt;span style="color:#111">|&lt;/span> sudo tee /etc/apt/sources.list.d/kubernetes.list
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>更新 &lt;code>apt&lt;/code> 包索引，安装 kubelet、kubeadm 和 kubectl，并锁定其版本：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get install -y kubelet kubeadm kubectl
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-mark hold kubelet kubeadm kubectl
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;h2 id="配置操作系统">配置操作系统&lt;/h2>
&lt;h3 id="转发-ipv4-并让-iptables-看到桥接流量">&lt;strong>&lt;strong>转发 IPv4 并让 iptables 看到桥接流量&lt;/strong>&lt;/strong>&lt;/h3>
&lt;p>执行下述指令：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>cat &lt;span style="color:#d88200">&amp;lt;&amp;lt;EOF | sudo tee /etc/modules-load.d/k8s.conf
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">overlay
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">br_netfilter
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo modprobe overlay
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo modprobe br_netfilter
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>*# 设置所需的 sysctl 参数，参数在重新启动后保持不变*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cat &lt;span style="color:#d88200">&amp;lt;&amp;lt;EOF | sudo tee /etc/sysctl.d/k8s.conf
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">net.bridge.bridge-nf-call-iptables = 1
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">net.bridge.bridge-nf-call-ip6tables = 1
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">net.ipv4.ip_forward = 1
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>*# 应用 sysctl 参数而不重新启动*
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo sysctl --system
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>通过运行以下指令确认 &lt;code>br_netfilter&lt;/code> 和 &lt;code>overlay&lt;/code> 模块被加载：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>lsmod &lt;span style="color:#111">|&lt;/span> grep br_netfilter
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>lsmod &lt;span style="color:#111">|&lt;/span> grep overlay
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>通过运行以下指令确认 &lt;code>net.bridge.bridge-nf-call-iptables&lt;/code>、&lt;code>net.bridge.bridge-nf-call-ip6tables&lt;/code> 和 &lt;code>net.ipv4.ip_forward&lt;/code> 系统变量在你的 &lt;code>sysctl&lt;/code> 配置中被设置为 1：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sysctl net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables net.ipv4.ip_forward
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h1 id="创建高可用控制面">创建高可用控制面&lt;/h1>
&lt;h2 id="配置负载均衡器">配置负载均衡器&lt;/h2>
&lt;p>43.135.64.117:443 → 10.67.3.9:6443、10.67.3.13:6443、10.67.3.15:6443&lt;/p>
&lt;h2 id="配置-master-运行时">配置 master 运行时&lt;/h2>
&lt;h3 id="查看默认-cgroup-驱动">查看默认 cgroup 驱动&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>stat -fc %T /sys/fs/cgroup/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="安装-cri-o">安装 CRI-O&lt;/h3>
&lt;p>root 执行&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">export&lt;/span> &lt;span style="color:#111">OS&lt;/span>&lt;span style="color:#f92672">=&lt;/span>xUbuntu_22.04
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">export&lt;/span> &lt;span style="color:#111">VERSION&lt;/span>&lt;span style="color:#f92672">=&lt;/span>1.26
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">echo&lt;/span> &lt;span style="color:#d88200">&amp;#34;deb [signed-by=/usr/share/keyrings/libcontainers-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/&lt;/span>&lt;span style="color:#111">$OS&lt;/span>&lt;span style="color:#d88200">/ /&amp;#34;&lt;/span> &amp;gt; /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">echo&lt;/span> &lt;span style="color:#d88200">&amp;#34;deb [signed-by=/usr/share/keyrings/libcontainers-crio-archive-keyring.gpg] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/&lt;/span>&lt;span style="color:#111">$VERSION&lt;/span>&lt;span style="color:#d88200">/&lt;/span>&lt;span style="color:#111">$OS&lt;/span>&lt;span style="color:#d88200">/ /&amp;#34;&lt;/span> &amp;gt; /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:&lt;span style="color:#111">$VERSION&lt;/span>.list
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mkdir -p /usr/share/keyrings
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/&lt;span style="color:#111">$OS&lt;/span>/Release.key &lt;span style="color:#111">|&lt;/span> gpg --dearmor -o /usr/share/keyrings/libcontainers-archive-keyring.gpg
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/&lt;span style="color:#111">$VERSION&lt;/span>/&lt;span style="color:#111">$OS&lt;/span>/Release.key &lt;span style="color:#111">|&lt;/span> gpg --dearmor -o /usr/share/keyrings/libcontainers-crio-archive-keyring.gpg
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>apt-get install cri-o cri-o-runc
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>CRI-O 默认也使用 systemd cgroup 驱动&lt;/p>
&lt;h3 id="启动-cri-o">启动 CRI-O&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>systemctl &lt;span style="color:#111">enable&lt;/span> crio
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>systemctl start crio
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="配置控制面">配置控制面&lt;/h2>
&lt;h3 id="初始化-master1">初始化 master1&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo kubeadm init --control-plane-endpoint &lt;span style="color:#d88200">&amp;#34;43.135.64.117:443&amp;#34;&lt;/span> --upload-certs
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ul>
&lt;li>
&lt;p>成功后得到如下输出：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>Your Kubernetes control-plane has initialized successfully!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>To start using your cluster, you need to run the following as a regular user:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> mkdir -p &lt;span style="color:#111">$HOME&lt;/span>/.kube
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sudo cp -i /etc/kubernetes/admin.conf &lt;span style="color:#111">$HOME&lt;/span>/.kube/config
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sudo chown &lt;span style="color:#00a8c8">$(&lt;/span>id -u&lt;span style="color:#00a8c8">)&lt;/span>:&lt;span style="color:#00a8c8">$(&lt;/span>id -g&lt;span style="color:#00a8c8">)&lt;/span> &lt;span style="color:#111">$HOME&lt;/span>/.kube/config
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Alternatively, &lt;span style="color:#00a8c8">if&lt;/span> you are the root user, you can run:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#111">export&lt;/span> &lt;span style="color:#111">KUBECONFIG&lt;/span>&lt;span style="color:#f92672">=&lt;/span>/etc/kubernetes/admin.conf
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>You should now deploy a pod network to the cluster.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Run &lt;span style="color:#d88200">&amp;#34;kubectl apply -f [podnetwork].yaml&amp;#34;&lt;/span> with one of the options listed at:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> https://kubernetes.io/docs/concepts/cluster-administration/addons/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>You can now join any number of the control-plane node running the following &lt;span style="color:#111">command&lt;/span> on each as root:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> kubeadm join 43.135.64.117:443 --token 3639bw.3f5i3dooplnd982i &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> --discovery-token-ca-cert-hash sha256:e66819320b79ccab1ca6f570db82fd67d1d17c2f59e8091779a4c99a3c0f37c6 &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> --control-plane --certificate-key 30c003d1c1d480f0c4c6df6bdba9d097b2e771013e11430bec4a4151afd730fc
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Please note that the certificate-key gives access to cluster sensitive data, keep it secret!
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>As a safeguard, uploaded-certs will be deleted in two hours&lt;span style="color:#111">;&lt;/span> If necessary, you can use
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">&amp;#34;kubeadm init phase upload-certs --upload-certs&amp;#34;&lt;/span> to reload certs afterward.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Then you can join any number of worker nodes by running the following on each as root:
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>kubeadm join 43.135.64.117:443 --token 3639bw.3f5i3dooplnd982i &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> --discovery-token-ca-cert-hash sha256:e66819320b79ccab1ca6f570db82fd67d1d17c2f59e8091779a4c99a3c0f37c6
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>要重新上传证书并生成新的解密密钥，请在已加入集群节点的控制平面上使用以下命令：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kubeadm token create --print-join-command
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ul>
&lt;h3 id="初始化其它-master">初始化其它 master&lt;/h3>
&lt;p>命令来自于前面初始化得到的输出：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>kubeadm join 43.135.64.117:443 --token 3639bw.3f5i3dooplnd982i &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> --discovery-token-ca-cert-hash sha256:e66819320b79ccab1ca6f570db82fd67d1d17c2f59e8091779a4c99a3c0f37c6 &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> --control-plane --certificate-key 30c003d1c1d480f0c4c6df6bdba9d097b2e771013e11430bec4a4151afd730fc
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h1 id="创建计算节点">创建计算节点&lt;/h1>
&lt;h2 id="配置-worker-运行时">配置 worker 运行时&lt;/h2>
&lt;h3 id="查看默认-cgroup-驱动-1">查看默认 cgroup 驱动&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>stat -fc %T /sys/fs/cgroup/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="安装-containerd">安装 containerd&lt;/h3>
&lt;ol>
&lt;li>
&lt;p>安装 containerd&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get install &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> ca-certificates &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> curl &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> gnupg &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> lsb-release
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo mkdir -m &lt;span style="color:#ae81ff">0755&lt;/span> -p /etc/apt/keyrings
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>curl -fsSL https://download.docker.com/linux/ubuntu/gpg &lt;span style="color:#111">|&lt;/span> sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">echo&lt;/span> &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> &lt;span style="color:#d88200">&amp;#34;deb [arch=&lt;/span>&lt;span style="color:#00a8c8">$(&lt;/span>dpkg --print-architecture&lt;span style="color:#00a8c8">)&lt;/span>&lt;span style="color:#d88200"> signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &lt;/span>&lt;span style="color:#00a8c8">$(&lt;/span>lsb_release -cs&lt;span style="color:#00a8c8">)&lt;/span>&lt;span style="color:#d88200"> stable&amp;#34;&lt;/span> &lt;span style="color:#111">|&lt;/span> sudo tee /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo chmod a+r /etc/apt/keyrings/docker.gpg
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get update
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt-get install containerd.io
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>安装 cni&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>wget https://github.com/containernetworking/plugins/releases/download/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo mkdir -p /opt/cni/bin
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.2.0.tgz
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>安装 containerd&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>wget https://github.com/containerd/containerd/releases/download/v1.6.16/containerd-1.6.16-linux-amd64.tar.gz
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo tar Cxzvf /usr/local/ containerd-1.6.16-linux-amd64.tar.gz
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>配置 containerd&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>containerd config default &amp;gt; /etc/containerd/config.toml
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>结合 &lt;code>runc&lt;/code> 使用 &lt;code>systemd&lt;/code> cgroup 驱动，在 &lt;code>/etc/containerd/config.toml&lt;/code> 中设置：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-toml" data-lang="toml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#111">[&lt;/span>&lt;span style="color:#75af00">plugins&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#d88200">&amp;#34;io.containerd.grpc.v1.cri&amp;#34;&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">containerd&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">runtimes&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">runc&lt;/span>&lt;span style="color:#111">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#111">...&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#111">[&lt;/span>&lt;span style="color:#75af00">plugins&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#d88200">&amp;#34;io.containerd.grpc.v1.cri&amp;#34;&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">containerd&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">runtimes&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">runc&lt;/span>&lt;span style="color:#111">.&lt;/span>&lt;span style="color:#75af00">options&lt;/span>&lt;span style="color:#111">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#75af00">SystemdCgroup&lt;/span> &lt;span style="color:#111">=&lt;/span> &lt;span style="color:#00a8c8">true&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>安装 CNI&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>wget https://github.com/containernetworking/plugins/releases/download/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo mkdir -p /opt/cni/bin
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.2.0.tgz
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>配置 CNI&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo mkdir /etc/cni/net.d/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo cat &lt;span style="color:#d88200">&amp;lt;&amp;lt; EOF &amp;gt; /etc/cni/net.d/100-containerd-bridge.conflist
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">{
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;cniVersion&amp;#34;: &amp;#34;1.0.0&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;name&amp;#34;: &amp;#34;containerd&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;plugins&amp;#34;: [
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;type&amp;#34;: &amp;#34;bridge&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;bridge&amp;#34;: &amp;#34;cni0&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;isGateway&amp;#34;: true,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;ipMasq&amp;#34;: true,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;hairpinMode&amp;#34;: true,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;ipam&amp;#34;: {
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;type&amp;#34;: &amp;#34;host-local&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;routes&amp;#34;: [
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> { &amp;#34;dst&amp;#34;: &amp;#34;0.0.0.0/0&amp;#34; },
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> { &amp;#34;dst&amp;#34;: &amp;#34;::/0&amp;#34; }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> ],
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> &amp;#34;ranges&amp;#34;: [
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> [{ &amp;#34;subnet&amp;#34;: &amp;#34;10.85.0.0/16&amp;#34; }],
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> [{ &amp;#34;subnet&amp;#34;: &amp;#34;1100:200::/24&amp;#34; }]
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> ]
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> }
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200"> ]
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">}
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#d88200">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>systemd 启动&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>systemctl &lt;span style="color:#111">enable&lt;/span> containerd
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>systemctl start containerd
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;h3 id="加入集群">加入集群&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#272822;background-color:#fafafa;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo kubeadm join 43.135.64.117:443 --token 3639bw.3f5i3dooplnd982i &lt;span style="color:#8045ff">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8045ff">&lt;/span> --discovery-token-ca-cert-hash sha256:e66819320b79ccab1ca6f570db82fd67d1d17c2f59e8091779a4c99a3c0f37c6
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item></channel></rss>