1.准备k8s集群
1. 准备一台机器用来部署单节点kubernetes,机器地址192.168.1.10
2. 使用kubekey安装1.27.0版本的kubernetes:
apt install conntrack socat
export KKZONE=cn
kk create cluster --with-kubernetes=v1.27.0 --container-manager=containerd
2. 安装cloudcore
使用keadm安装cloudcore:
keadm init --advertise-address="192.168.1.10"
获取云端token:
# keadm gettoken
27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTAyMTYwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYE
3. 加入边缘节点
1. 准备一台机器作为边缘节点192.168.1.11,在该节点安装containerd:
创建文件/usr/local/lib/systemd/system/containerd.service内容如下:
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# 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
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
# 安装containerd runc cni
wget https://mirror.ghproxy.com/https://github.com/containerd/containerd/releases/download/v1.7.14/containerd-1.7.14-linux-amd64.tar.gz
tar Cxzvf /usr/local containerd-1.7.14-linux-amd64.tar.gz
systemctl daemon-reload
systemctl enable --now containerd
wget https://mirror.ghproxy.com/https://github.com/opencontainers/runc/releases/download/v1.1.12/runc.amd64
install -m 755 runc.amd64 /usr/local/sbin/runc
wget https://mirror.ghproxy.com/https://github.com/containernetworking/plugins/releases/download/v1.4.1/cni-plugins-linux-amd64-v1.4.1.tgz
mkdir -p /opt/cni/bin
tar Cxzvf /opt/cni/bin cni-plugins-linux-amd64-v1.4.1.tgz
配置containerd:
containerd config default > /etc/containerd/config.toml
systemctl restart containerd
修改配置文件:
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "kubeedge/pause:3.6"
重启containerd:
systemctl restart containerd
2. 加入边缘节点
keadm join --cloudcore-ipport=192.168.1.10:10000 --token=27a37ef16159f7d3be8fae95d588b79b3adaaf92727b72659eb89758c66ffda2.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTAyMTYwNzd9.JBj8LLYWXwbbvHKffJBpPd5CyxqapRQYDIXtFZErgYE
3. 边缘节点配置CNI
$ mkdir -p /etc/cni/net.d/
$ cat >/etc/cni/net.d/bridge.conf <<EOF
{
"cniVersion": "0.3.1",
"name": "containerd-net",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "10.88.0.0/16",
"routes": [
{ "dst": "0.0.0.0/0" }
]
}
}
EOF
4. 查看节点: