内容提要:
- 云端使用helm安装cloudcore
- 边缘端使用keadm join纳管到云端
- 修改边缘端配置使其支持IptableManger
- 把服务部署到边缘端,并体验kubeclt logs/exec
--------------------------------------------------------------------------------------------------------------
一、【云端】使用helm安装cloudcore
//给master01节点打上kubeedge=cloudcore标签
#kubectl get nodes --show-labels
#kubectl label node master01 kubeedge=cloudcore
#kubectl get nodes --show-labels
#cd /root/ke_install/kubeedge-1.12.1/manifests/charts
#vim cloudcore/values.yaml
//加入容忍度
iptablesManager:
vim cloudcore/values.yaml
cd /root/ke_install/kubeedge-1.12.1/charts/cloudcore
helm upgrade --install cloudcore ./cloudcore --namespace kubeedge --create-namespace -f ./cloudcore/values.yaml --set cloudCore.modules.cloudHub.advertiseAddress[0]=118.195.190.83
kubectl get pod -n kubeedge
#如果你不小心搞错了,可能需要下面的卸载命令:
#helm uninstall cloudcore -n kubeedge
#kubectl delete ns kubeedge
#查询token,用于后面的keadm join
keadm gettoken
二、【边缘端】使用keadm join纳管到云端
keadm join --cloudcore-ipport=118.195.190.83:10000 --token=2c258114c9d623884d63e249045c8981fca0fb5da0b1473a12340a04bafa0ad5.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NzI0MTIzNDF9.Lr7ZPZ7TalugxaYuj1kgGR5oH1TrmnjC4rx-97uauC
这时在云端要查看纳管状态:
root@master01:~/metrics_install# kubectl get node
NAME STATUS ROLES AGE VERSION
edge01 Ready agent,edge 111m v1.22.6-kubeedge-v1.12.1
master01 Ready control-plane,master 11d v1.21.6
node01 Ready <none> 11d v1.21.6
node02 Ready <none> 11d v1.21.6
三、【边缘端】修改配置,使开启IptableManager
kubectl logs/exec依赖于IptableManager,因此开启logs/exec实际上就是开启IptableManager。
实际按以上操作云端已经开启了iptableManager,关键配置是:
现在只要把边缘端也开启就可以了:
#边缘端:
vi /etc/kubeedge/config/edgecore.yaml
systemctl restart edgecore
四、验证
把deployment部署到边缘端
cd ~/ke_install/kubeedge-1.12.1/build
vi deployment.yaml
#创建命名空间test
kubectl create ns test
kubectl apply -f deployment.yaml
kubectl get pod -n test -owide
体验kubctl log、exec
#边缘端
docker ps
curl localhost:80 #可访问nginx页面
docker logs -f bdd #可看到nginx日志
curl localhost:80 #再次访问nginx页面
docker logs -f bdd #可看到nginx日志更新
#云端
kubectl logs -f nginx-deployment-7b5666b78b-97qv -n test
kubectl exec -it nginx-deployment-7b5666b78b-97qv bash -n test