王子
K8S快速搭建单机集群操作手册
一、系统要求
1C2G+
二、依赖条件
(请联系作者获取依赖安装文件)
执行bash setup_env.sh文件 等待完成
执行 kubez-ansible 有正常回显
kubez-ansible -h
工作目录(通常是 setup_env.sh 存放目录)下自动生成 multinode
三、部署步骤
1.检查虚拟机默认网卡配置
默认网卡为 eth0, 如果环境实际网卡不是 eth0,则需要手动指定网卡名称:
编辑 /etc/kubez/globals.yml 文件, 取消 network_interface: "eth0" 的注解, 并修改为实际网卡名称
2.确认集群环境连接地址
- 内网连接: 无需更改
- 公网连接:
编辑 /etc/kubez/globals.yml 文件, 取消 #kube_vip_address: "" 的注解,并修改为实际公网地址 云平台环境需要放通公网ip到后面节点的6443端口
3.(可选) 修改默认的 cri
默认的 cri 为 containerd, 如果期望修改为 docker, 则
Centos 修改 /usr/share/kubez-ansible/ansible/inventory/all-in-one
Ubuntu 修改 /usr/local/share/kubez-ansible/ansible/inventory/all-in-one
4.(可选)移除containerd-master和containerd-node的主机信息
并添加在 docker 分组中, 调整后效果如下:
[docker-master]
localhost ansible_connection=local
[docker-node]
localhost ansible_connection=local
[containerd-master]
[containerd-node]
5.(可选)修改 kubernetes 镜像仓库
编辑 /etc/kubez/globals.yml 文件,修改 image_repository: "" 为期望镜像仓库,默认是阿里云 registry.cn-hangzhou.aliyuncs.com/google_containers
6.(可选)修改基础应用镜像仓库
编辑 /etc/kubez/globals.yml 文件,修改 app_image_repository: "" 为期望镜像仓库,默认是 pixiu镜像仓库 harbor.cloud.pixiuio.com/pixiuio
7.进行 kubernetes 的依赖安装
kubez-ansible bootstrap-servers
8.进行 kubernetes 的集群安装
kubez-ansible deploy
9.验证环境
kubectl get node
查看节点是否为Ready状态,如不是,请看后面的问题排查
10.(可选)启用 kubectl 命令行补全
kubez-ansible post-deploy
四、安装部署dashboard
1.开启dashboard组件
编辑 /etc/kubez/globals.yml
取消 enable_dashboard: "no" 的注释,并设置为 "yes"
enable_dashboard: "yes"
dashboard_chart_version: 6.0.0
2.执行安装命令(根据实际情况选择)
单节点集群场景
kubez-ansible apply
高可用集群场景
kubez-ansible -i multinode apply
3.修改 service 的服务类型
[root@master01 ~]# kubectl edit svc -n pixiu-system kubernetes-dashboard
...
spec:
type: NodePort #此处添加一种访问方式,选用NodePort
ports:
- name: https
port: 443
targetPort: https
nodePort: 30666 # 对应 Nodeport,端口范围30000-32767
protocol: TCP
4.添加 rbac 的权限
创建用户
kubectl create serviceaccount dashboard-admin -n pixiu-system
将dashboard-admin用户授cluster-admin权限(clusterrole为集群管理权限)
kubectl create clusterrolebinding dashboard-admin-rb --clusterrole=cluster-admin --serviceaccount=pixiu-system:dashboard-admin
部署完验证
查看 pod 状态及暴露的端口
[root@9eavmhsbs9eghuaa ~]# kubectl get pod,svc -n pixiu-system
5.访问 dashboard
浏览器访问:https://<ip>:30666
页面访问后我们选择 token,回到终端根据下面操作获取 token
6.获取 token
查询dashboard-token名称
kubectl get secrets -n pixiu-system |grep dashboard-admin
# 获取该 token 密钥进行登录验证
kubectl describe secrets dashboard-admin-token-p8jlr -n pixiu-system
7.填入token,愉快的登录访问吧
五、问题排查
1.coredns pedding状态
检查是否是镜像拉取不了
2.检查网络插件配置文件是否存在
cat /etc/cni/net.d/10-flannel.conflist
3.检查containerd
systemctl status containerd
4.重启containerd
systemctl restart containerd
5.查看kubelet日志
journalctl -u kubelet > kubelet.log
6.查看containerd日志
journalctl -u containerd > containerd.log
7.dashboard镜像拉取失败
kubectl get deploy -n pixiu-system
kubectl edit deploy kubernetes-dashboard -n pixiu-system
将kubernetesui/dashboard 改为harbor.cloud.pixiuio.com/pixiuio/dashboard
8.其他问题排查
kubectl describe pods coredns-65c54cc984-24nrq -n kube-system
kubectl get pods -A
kubectl describe pods coredns-65c54cc984-sdzc7 -n kube-system
kubectl get nodes
kubectl describe nodes|grep -i taint
kubectl taint nodes master node.kubernetes.io/not-ready-
kubectl get pods -A|grep coredns
kubectl get pods coredns-65c54cc984-24nrq -n kube-system -o yaml
kubectl get pods -A|grep coredns
kubectl get pods -A
kubectl describe pods kube-flannel-ds-llw8g -n kube-flannel
kubectl describe nodes|grep -i taint
kubectl get pods -A
find / -name "coredns"
kubectl get deploy -A|grep coredns
kubectl edit deploy coredns -n kube-system
kubectl taint nodes master node-role.kubernetes.io/master-
kubectl get pods -A
kubectl logs -f kube-flannel-ds-llw8g -n kube-flannel
kubectl get nodes
kubectl get pods -A
kubectl get ds -A|grep flannel
kubectl edit ds kube-flannel-ds -n kube-flannel
kubectl get ds kube-flannel-ds -n kube-flannel -o yaml > flannel.yml
kubectl delete ds kube-flannel-ds -n kube-flannel
kubectl describe nodes master|grep -i taint
kubectl apply -f flannel.yml
kubectl get pods
kubectl get pods -A
kubectl describe pods coredns-65c54cc984-24nrq -n kube-system
kubectl get pods -A
kubectl delete pods coredns-65c54cc984-24nrq -n kube-system
kubectl get pods -A
kubectl describe pods coredns-65c54cc984-cqvbq -n kube-system
kubectl get pods -A
kubectl delete pods coredns-65c54cc984-cqvbq -n kube-system
kubectl get pods -A
kubectl describe pods coredns-65c54cc984-sdzc7 -n kube-system
cd /opt/cni/bin
journalctl -u kubelet
kubectl describe pods coredns-65c54cc984-sdzc7 -n kube-system
cat /etc/cni/net.d/10-flannel.conflist
systemctl status containerd
systemctl status containerd | more
systemctl status containerd
systemctl restart containerd
journalctl -u containerd -f | grep cni
kubectl get po -A
kubectl describe po ingress-nginx-controller-84999cdbbb-kk52s -n kube-system
kubectl get po -A
kubectl describe po ingress-nginx-controller-84999cdbbb-kk52s -n kube-system
kubectl get po -A
kubez-ansible apply
kubectl get po -A
kubectl edit deploy kubernetes-dashboard -n pixiu-system
kubectl get deploy -n pixiu-system
kubectl get po -A
kubectl edit deploy kubernetes-dashboard -n pixiu-system
kubectl get po -A
kubectl get deploy -n pixiu-system
kubectl edit deploy kubernetes-dashboard -n pixiu-system
kubectl get po -A
kubectl logs master -c kubelet
kubectl logs kubernetes-dashboard-5647dbbb64-njbwn
kubectl logs kubernetes-dashboard-5647dbbb64-njbwn -n pixiu-system
kubectl describe po kubernetes-dashboard-5647dbbb64-njbwn -n pixiu-system
kubectl get po -A
kubectl describe pod -n pixiu-system kubernetes-dashboard-5647dbbb64-njbwn
kubectl edit deploy kubernetes-dashboard -n pixiu-system
kubectl get po -A
kubectl describe pod -n pixiu-system kubernetes-dashboard-5647dbbb64-njbwn
kubectl describe pod -n pixiu-system kubernetes-dashboard-84d4cd7489-hfhdb
kubectl get po -A
kubectl logs kubernetes-dashboard-84d4cd7489-hfhdb -n pixiu-system
kubectl get po -A
kubectl edit svc -n pixiu-system kubernetes-dashboard
kubectl get po -A
kubectl create serviceaccount dashboard-admin -n pixiu-system
kubectl create clusterrolebinding dashboard-admin-rb --clusterrole=cluster-admin --serviceaccount=pixiu-system:dashboard-admin
kubectl get pod,svc -n pixiu-system
kubectl get secrets -n pixiu-system |grep dashboard-admin
kubectl get po -A
kubectl edit svc -n pixiu-system kubernetes-dashboard
kubectl get po -A
kubectl describe secrets dashboard-admin-token-p8jlr -n pixiu-system
kubectl get secrets -n pixiu-system |grep dashboard-admin
kubectl describe secrets dashboard-admin-token-d5sl4 -n pixiu-system
《党员二愣妈》国产剧高清在线免费观看:https://www.jgz518.com/xingkong/34940.html
想想你的文章写的特别好www.jiwenlaw.com
Hello,
Wondering if you accept guest posts or link inserts on existing posts on 163.174?
How much would you charge for this?
Justin