k8s集群搭建-问题总结

在部署工程中,可能会遇到一些问题,这里做一下总结

1.日志查看方式

首先,本节介绍一下查询k8s日志的方式

查看k8s错误日志:

journalctl -xe


查询具体组件状态,以查询pod为例:

kubectl describe pod <pod-name>


2.docker镜像拉取超时问题

由于一些网络原因,拉取镜像超时,我们可以从其他仓库拉取镜像到本地,然后打tag,替代远程镜像。例如,在node节点部署过程中,遇到k8s.gcr.io/pause:3.6,errImagepull问题,查日志发现是k8s.gcr.io网络不通。

用别的库拉取镜像到本地,然后打tag,本地镜像需要在所有节点下载并打tag

docker pull rancher/pause:3.6

docker tag rancher/pause:3.6 k8s.gcr.io/pause:3.6

分享在本文实践过程中拉取过的镜像

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.1.0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1

docker pull mirrorgooglecontainers/pause:3.6

docker pull k8s.gcr.io/pause:3.6

docker pull mirrorgooglecontainers/pause:3.6

docker pull rancher/pause:3.6

docker pull gotok8s/kube-proxy:v1.23.1

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.1.0

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1


3.The connection to the server localhost:8080 was refused

The connection to the server localhost:8080 was refused - did you specify the right host or port?


解决方法,执行以下命令:

export KUBECONFIG=/etc/kubernetes/admin.conf


4.cgroups driver问题

docker的默认cgroups driver可能有误,一般需要设置成systemd,修改k8s启动参数

docker info命令查看当前cgourp driver


查看cgroup driver属性


编辑/etc/systemd/system/kubelet.service.d/10-kubeadm.conf,增加环境变量参数


增加启动环境变量


重启docker服务

sudo systemctl restart docker

sudo systemctl daemon-reload

5.hostname未知警告

在/etc/hosts中设置映射

127.0.0.1 master-node

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容