在社区里,看到大家对KubeSphere3.0 的系统使用上,存在着一些共性问题,这里整理汇总一些常见的开发运维问题,希望能为大家可以以最快的途径,找到答案,当然个人能力有限,也欢迎大家补充、交流。
解决集群故障的思路
一.新增外置LDAP配置方法
1.修改命令
kubectl -n kubesphere-system edit cm kubesphere-config
2.在 authentication下新增(不要删除外层的ldap默认配置否则报错)
accessTokenMaxAge: 1h accessTokenInactivityTimeout: 30m identityProviders: - name: ldap type: LDAPIdentityProvider mappingMethod: auto provider: host: 192.168.0.2:389 managerDN: uid=root,cn=users,dc=nas managerPassword: 4p4@XuP#dP6U userSearchBase: cn=users,dc=nas loginAttribute: uid mailAttribute: mail
3.重启api-server
kubectl -n kubesphere-system rollout restart deploy/ks-apiserver
二.更改容器组上限110个
1.找到需要调节容器组的节点(扩哪个节点就调整对应节点)
vi /var/lib/kubelet/config.yaml
2.自定义修改值
3.重启服务
systemctl daemon-reload && systemctl restart kubelet
四.ks添加私仓搜索不到镜像
1.检查一下你的私有镜像仓Harbor的地址是http还是https,没错这两都可以在镜像仓库密钥那里连接验证通过,但是如果和Harbor地址不符,就会搜不到镜像。
这是浏览器打开的Harbor地址
能验证通过但是是搜不到镜像的
2.检查一下搜镜像的时候你是不是忘记写项目名了,比如原本应该是 xxx项目名/xxx/xxx:版本号, 然后只写了xxx/xxx:版本号那当然搜不到
五.DevOps创建凭证用户名不支持中文,否则报错(3.1版本修复)
六.手动误删isito服务导致pod无法调度
1.需要删除干净,执行以下命令
kubectl delete mutatingwebhookconfigurations.admissionregistration.k8s.io istio-sidecar-injector
七.minio无限重启
手动停止了一个实例后重启了集群,只要是新安装kubesphere3.0必定会出现这个问题。环境:虚拟机三台centos7,自建的k8s集群,kubesphere3.0最小化安装,开启devops和告警通知两个组件会出现minio创建两个相互竞争的pod并无限重启
八.部署报错 No etcd config found
1.检查6443是否占用
netstat -apn | grep 6443
九.部署成功后登陆报错
1.检查ks-controller-manager的运行状态和日志
2.kubesphere 3.0.0 并未在1.19上进行完整的测试,目前支持的K8s 版本 1.15.5+, 1.16.2+, 1.17, 1.18
3.报错日志
x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0, requeuing
注意1.19未经过充分测试,可以通过一下命令解决证书问题
kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/2c4b479ec65110f7910f913734b3d069409d72a8/roles/ks-core/prepare/files/ks-init/users.iam.kubesphere.io.yaml
kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/2c4b479ec65110f7910f913734b3d069409d72a8/roles/ks-core/prepare/files/ks-init/webhook-secret.yaml
kubectl -n kubesphere-system rollout restart deploy ks-controller-manager
4.参考 https://kubesphere.com.cn/forum/d/2217-account-is-not-active
5.存储、网络问题
user controller 依赖的外部服务有openldap和jenkins,在依赖服务不正常的情况下controller会一直reconcile,user CRD状态无法正常维护,导致账户无法登录。 可以通过 ks-controller-manager 日志和pod运行状态定位到问题。 常见问题: 存储配置错误、数据丢失、集群网络不通。
参考:
https://kubesphere.com.cn/forum/d/2058-kk-internal-error-occurred-account-is-not-active/8 https://kubesphere.com.cn/forum/d/2202-kubesphere-v3-0-0-admin/25
十.ks3.0集群添加新节点丢失kubekey的config文件
1、执行
./kk create config –from-cluster
将生成sample.yaml,该文件即为当前集群的配置文件
2、添加节点时会检查所有节点状态,添加工作节点不会对原集群节点造成影响,部分POD可能会漂移到新添加的节点上,添加master节点可能会对当前集群造成影响。
十一.k8s或者ks重启后不能访问
症状:
kubectl get pod --all-namespaces
The connection to the server lb.kubesphere.local:6443 was refused - did you specify the right host or port?
解决:
注意,K8s 和 KubeSphere 都不存在重启一说,只有 Docker 可以重启。通常情况 K8s 和 Docker 在服务器重启后可以自愈,KubeSphere 也会自动恢复运行。 但偶尔会遇到上述问题,这个情况大概率是服务器 Docker Daemon 启动失败,我们只需要 systemctl 重启一下 Docker 就可以解决问题:
sudo systemctl daemon-reload
sudo systemctl restart docker
十二.DevOps组件重装常规步骤
1.删除旧的jenkins
helm del ks-jenkins -n kubesphere-devops-system
2.删除cc中devops的状态:
kubectl edit cc -n kubesphere-system ks-installer
删掉status.devops
3.如果cc的spec中devops.enabled为false,改为ture即可,如果devops.enabled为true,删除devops的status后重启ks-installer kubectl rollout restart deploy -n kubesphere-system ks-installer
kubectl rollout restart deploy -n kubesphere-system ks-installer
十三.minio部署失败
大部分原因是网络问题如DNS
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/
十四.验证邮件服务配置失败:
tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config
1.把端口改成465,ssl的复选框不用勾
十五.部署harbor镜像仓库密钥报错
1.不支持https的harbor私有仓库,用http
2.harbor那边要配置正确,且要让完全生效,可参考harbor官方的做法,不要带参数
3.docker客户端也要正常能使用harbor的一键拉取命令正常拉取,各个node节点及外部服务器
4.检查一下是否添加了证书,docker需要改配置,重启docker
十六.新增加节点报错
ERRO[14:28:59 CST] Failed to exec command: sudo -E /bin/sh -c “chown kube -R /usr/local/bin” chown: invalid user: ‘kube’: Process exited with status 1 node=x.x.x.x
权限不足导致的,设置报错提示里的文件夹权限(如777)后再重新执行添加即可。(生产环境谨慎用777)