先创建k8s集群
https://blog.csdn.net/weixin_44371237/article/details/123974335
环境准备
一台linux主机,4G内存
通过Docker部署rancher
启动rancher
docker run --privileged -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:stable
查看本地镜像 docker images
查看运行容器 docker ps
登录页面 https://服务器IP/ (证书问题,清除浏览器重试)
查看密码
docker logs container-id 2>&1 | grep "Bootstrap Password:"
登录后提示先修改密码
导入K8S集群
查找kubelet配置文件
ps -ef | grep kubelet
查看kubelet配置中的USER_ACCOUNT
cat /etc/kubernetes/kubelet.conf | grep user
执行
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user system:node:k8s-1
结果
访问截图以上yaml,查出来image镜像
提前在所有的node节点节点上下载这个rancher/rancher-agent:v2.6.3镜像
docker pull rancher/rancher-agent:v2.6.3
在master执行上面截图中的
curl --insecure -sfL https://192.168.56.201/v3/import/vg984cdxh9h4zspkctddhlzbjkwk84zfknx9d8x8pprhrkql8pf79c_c-m-4ffpn2qv.yaml | kubectl apply -f -
检查
检查会发现k8s中多了一个cattle-system的命名空间
[root@k8s-master01 work]# kubectl get ns
NAME STATUS AGE
cattle-system Active 18m
default Active 3d19h
kube-node-lease Active 3d19h
kube-public Active 3d19h
kube-system Active 3d19h
cattle-system的命名空间下创建了cattle-cluster-agent和cattle-node-agent的pod
[root@k8s-master01 work]# kubectl get pods -n cattle-system
NAME READY STATUS RESTARTS AGE
cattle-cluster-agent-87944bb89-9l8vn 1/1 Running 0 18m
cattle-node-agent-24vnp 1/1 Running 0 18m
cattle-node-agent-86hdx 1/1 Running 0 18m
cattle-node-agent-qz59v 1/1 Running 0 18m
[root@k8s-master01 work]# kubectl get deployment -n cattle-system
NAME READY UP-TO-DATE AVAILABLE AGE
cattle-cluster-agent 1/1 1 1 19m
[root@k8s-master01 work]# kubectl get daemonset -n cattle-system
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
cattle-node-agent 3 3 3 3 3 <none> 19m