先安装k8s
linux安装部署k8s(kubernetes)和解决遇到的坑和解决遇到的坑")
下载kubeedge需要的软件
注意:下载对应的版本和架构
keadm-v1.5.0-linux-amd64.tar.gz
下面的2个文件可以不用下载,安装kubeedge时也会自动去下载到/etc/kubeedge/目录,我这里在线github下载很慢,所以提前下载好
kubeedge-v1.6.1-linux-amd64.tar.gz
cloudcore.service
如果github访问不了,或者太慢,可以给我留言或评论,我发给大家
#创建文件夹
mkdir /etc/kubeedge/
#把下载的软件复制到/etc/kubeedge/目录,可以不下载这2个文件,安装时会自动从github上在线下载到/etc/kubeedge/目录
#因为访问github很慢,我提前下载好
cp kubeedge-v1.6.1-linux-amd64.tar.gz /etc/kubeedge/
cp cloudcore.service /etc/kubeedge/
安装kubeedge的cloudcore
--advertise-address="192.168.0.123" kubeedge的cloudcore的IP,edge边缘节点能访问的IP,如果公网访问,建议使用外网IP
--kubeedge-version=1.6.1 kubeedge的版本,会去下载指定版本的kubeedge包
#解压keadm
tar -zxvf keadm-v1.6.1-linux-amd64.tar.gz
#初始化安装kubeedge的cloudcore
./keadm-v1.6.1-linux-amd64/keadm/keadm init --advertise-address="192.168.0.123" --kubeedge-version=1.6.1
#输出如下信息成功:
version=1.6.1
Kubernetes version verification passed, KubeEdge installation will start...
W0511 14:35:30.146678 3524 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0511 14:35:30.154102 3524 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0511 14:35:30.159650 3524 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
W0511 14:35:30.164732 3524 warnings.go:67] apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition
Expected or Default KubeEdge version 1.6.1 is already downloaded and will checksum for it.
kubeedge-v1.6.1-linux-amd64.tar.gz checksum:
checksum_kubeedge-v1.6.1-linux-amd64.tar.gz.txt content:
Expected or Default KubeEdge version 1.6.1 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.6.1-linux-amd64/
kubeedge-v1.6.1-linux-amd64/edge/
kubeedge-v1.6.1-linux-amd64/edge/edgecore
kubeedge-v1.6.1-linux-amd64/cloud/
kubeedge-v1.6.1-linux-amd64/cloud/csidriver/
kubeedge-v1.6.1-linux-amd64/cloud/csidriver/csidriver
kubeedge-v1.6.1-linux-amd64/cloud/admission/
kubeedge-v1.6.1-linux-amd64/cloud/admission/admission
kubeedge-v1.6.1-linux-amd64/cloud/cloudcore/
kubeedge-v1.6.1-linux-amd64/cloud/cloudcore/cloudcore
kubeedge-v1.6.1-linux-amd64/version
KubeEdge cloudcore is running, For logs visit: /var/log/kubeedge/cloudcore.log
CloudCore started
#查看cloudcore的日志
vim /var/log/kubeedge/cloudcore.log
配置cloudcore开机自启动服务
#查看cloudcore启动情况
ps aux|grep cloudcore
#输出如下表示启动:
root 23498 0.1 0.3 1012544 48640 ? Ssl May12 13:11 /usr/local/bin/cloudcore
#查看端口 10000 10002 端口都有了
#没有netstat命令,安装:yum install net-tools -y
netstat -tpnl
#如下:
tcp6 0 0 :::10000 :::* LISTEN 23498/cloudcore
tcp6 0 0 :::10002 :::* LISTEN 23498/cloudcore
#查看cloudcore启动状态
systemctl status cloudcore
#如果没有设置开机启动服务则设置 复制开启自启动服务文件
cp /etc/kubeedge/cloudcore.service /etc/systemd/system/cloudcore.service
#添加文件权限
chmod +x /etc/systemd/system/cloudcore.service
#重新加载配置文件
systemctl daemon-reload
#查看cloudcore启动的进程id,然后杀掉
ps aux|grep cloudcore
#输出如下:
root 23498 0.1 0.3 1012544 48640 ? Ssl May12 13:12 /usr/local/bin/cloudcore
#杀掉
kill -9 23498
#启动cloudcore
systemctl start cloudcore
#设置开机自启动
systemctl enable cloudcore.service
#查看cloudcore开机启动状态 enabled:开启, disabled:关闭
systemctl is-enabled cloudcore.service
获取kubeedge的token
./keadm-v1.6.1-linux-amd64/keadm/keadm gettoken