1.需要有一个集群,最少保证是1个master和一个node
bash
[root@k8s-ke-cloud ~]# kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-ke-cloud Ready control-plane,master 23m v1.22.2 192.168.0.177 <none> CentOS Linux 7 (Core) 3.10.0-1160.92.1.el7.x86_64 docker://24.0.6
k8s-ke-edge1 Ready <none> 20m v1.22.2 192.168.0.92 <none> CentOS Linux 7 (Core) 3.10.0-1160.92.1.el7.x86_64 docker://24.0.6
[root@k8s-ke-cloud ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-67bb5696f5-4zbmc 1/1 Running 0 22m
calico-node-9gsjl 1/1 Running 0 22m
calico-node-sg8sm 1/1 Running 0 21m
coredns-7f6cbbb7b8-472bz 1/1 Running 0 24m
coredns-7f6cbbb7b8-zmqzd 1/1 Running 0 24m
etcd-k8s-ke-cloud 1/1 Running 0 24m
kube-apiserver-k8s-ke-cloud 1/1 Running 0 24m
kube-controller-manager-k8s-ke-cloud 1/1 Running 0 24m
kube-proxy-g7zws 1/1 Running 0 24m
kube-proxy-rk8x4 1/1 Running 0 21m
kube-scheduler-k8s-ke-cloud 1/1 Running 0 24m
[root@k8s-ke-cloud ~]#
2. KubeEdge v1.10.0部署安装
在k8s 1.22.2上几乎可以装各种版本的KubeEdge,因此不想装v1.10.0的也可以自行替换版本号。
首先,我们要在准备好的所有节点上下载kubeedege相关组件:
bash
# keadm,类似kubeadm的KE部署包
cd /root/
wget https://github.com/kubeedge/kubeedge/releases/download/v1.10.0/keadm-v1.10.0-linux-amd64.tar.gz
tar -xvf keadm-v1.10.0-linux-amd64.tar.gz
cp keadm-v1.10.0-linux-amd64/keadm/keadm /usr/bin/
keadm version
bash
# 提前下载kubeedge压缩包和校验文件
mkdir -p /etc/kubeedge/ && cd /etc/kubeedge
wget https://github.com/kubeedge/kubeedge/releases/download/v1.10.0/kubeedge-v1.10.0-linux-amd64.tar.gz
wget https://github.com/kubeedge/kubeedge/releases/download/v1.10.0/checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt
bash
#然后即可在云节点进行边缘集群初始化:
keadm init --advertise-address=114.115.166.230 --kubeedge-version=1.10.0 #这个IP如果是公有云测试公网IP,其他的则是master节点的IP,这里的kubeedge-version版本一定要和你安装的版本一致
bash
#可以用下面语句查看cloudcore进程是否已经在进行:
ps -ef|grep cloudcore #必须要查询到进程
bash
#为了防止以后挂机重开之后还要再重启服务,将cloudcore相关设施也加入开机自启动:
cd /etc/kubeedge
cp /etc/kubeedge/cloudcore.service /etc/systemd/system/
systemctl daemon-reload
systemctl start cloudcore.service
systemctl enable cloudcore.service
bash
#然后可以生成云节点的token,通过Token可以让其他边缘节点加入:
keadm gettoken
bash
[root@k8s-ke-cloud ~]# keadm version
version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"3803951602f938d9d90d74957eb0fbc238142101", GitTreeState:"clean", BuildDate:"2022-03-14T02:30:42Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
[root@k8s-ke-cloud ~]# mkdir /etc/kubeedge/
[root@k8s-ke-cloud ~]# cd /etc/kubeedge/
[root@k8s-ke-cloud kubeedge]# keadm init --advertise-address=114.115.166.230 --kubeedge-version=1.10.0
Kubernetes version verification passed, KubeEdge installation will start...
Expected or Default KubeEdge version 1.10.0 is already downloaded and will checksum for it.
kubeedge-v1.10.0-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt content:
Expected or Default checksum file checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt is already downloaded.
Expected or Default KubeEdge version 1.10.0 is already downloaded
[Run as service] start to download service file for cloudcore
[Run as service] success to download service file for cloudcore
kubeedge-v1.10.0-linux-amd64/
kubeedge-v1.10.0-linux-amd64/cloud/
kubeedge-v1.10.0-linux-amd64/cloud/cloudcore/
kubeedge-v1.10.0-linux-amd64/cloud/cloudcore/cloudcore
kubeedge-v1.10.0-linux-amd64/cloud/iptablesmanager/
kubeedge-v1.10.0-linux-amd64/cloud/iptablesmanager/iptablesmanager
kubeedge-v1.10.0-linux-amd64/cloud/csidriver/
kubeedge-v1.10.0-linux-amd64/cloud/csidriver/csidriver
kubeedge-v1.10.0-linux-amd64/cloud/admission/
kubeedge-v1.10.0-linux-amd64/cloud/admission/admission
kubeedge-v1.10.0-linux-amd64/edge/
kubeedge-v1.10.0-linux-amd64/edge/edgecore
kubeedge-v1.10.0-linux-amd64/version
KubeEdge cloudcore is running, For logs visit: /var/log/kubeedge/cloudcore.log
CloudCore started
[root@k8s-ke-cloud kubeedge]# ps -ef|grep cloudcore
root 9618 1 0 15:15 pts/0 00:00:00 /usr/local/bin/cloudcore
root 9953 8676 0 15:16 pts/0 00:00:00 grep --color=auto cloudcore
[root@k8s-ke-cloud kubeedge]# ll
total 76348
-rw-r--r-- 1 root root 129 Oct 15 15:09 checksum_kubeedge-v1.10.0-linux-amd64.tar.gz.txt
-rw-r--r-- 1 root root 162 Oct 15 15:15 cloudcore.service
drwxr-xr-x 2 root root 4096 Oct 15 15:15 config
drwxr-xr-x 5 root root 4096 Oct 15 15:15 crds
-rw-r--r-- 1 root root 21404711 Oct 15 15:09 keadm-v1.10.0-linux-amd64.tar.gz
drwxr-xr-x 4 root root 4096 Mar 14 2022 kubeedge-v1.10.0-linux-amd64
-rw-r--r-- 1 root root 56751052 Oct 15 15:09 kubeedge-v1.10.0-linux-amd64.tar.gz
[root@k8s-ke-cloud kubeedge]# keadm gettoken
daaa98434f7f9c47da45d7c4f86cb8797f683e1a815ca83e2e09d3d190407a28.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTc0NDA1NTB9.5LRMzAAxW8PnBKdJdMDdELsWfl4vuTOE8avtyHULzyQ[root@k8s-ke-cloud kubeedge]#