k8s 安装部署报错解决方法

  1. hostname 和 DNS 的解析规则不匹配
nodeRegistration.name: Invalid value: "vm_0_2_centos": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

原因是 hostname 和 DNS 的解析规则不匹配, 不能有除 -和 . 之外的特殊字符存在。注意是主机名hostname,不可有-或者.
分析过程,查看当前主机的hostname

hostname
vm_0_2_centos

更改主机名,可以执行如下语句:
hostnamectl set-hostname k8s-master

  1. ip_forward not set to 1
 [ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1`

设置为1即可
echo 1 > /proc/sys/net/ipv4/ip_forward

  1. Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 这是docker服务没有起来

    1. systemctl daemon-reload
    2. service docker restart
    3. systemctl enable docker.service
    4. service docker status
[root@master yum.repos.d]# docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.18.0
Error response from daemon: Get https://registry.cn-hangzhou.aliyuncs.com/v2/: proxyconnect tcp: dial tcp 172.96.236.117:10070: connect: connection refused

这里需要注册一个阿里云的用户,然后登录阿里云的Registry
参考链接 https://blog.csdn.net/u012720518/article/details/105352451

  1. docker pull加速方法
cat /etc/docker/daemon.json							# 修改文件, 这一步骤查看自己的阿里云账户信息
{
  "registry-mirrors": ["https://rppul91c.mirror.aliyuncs.com"]
}

# 重新启动docker
 systemctl daemon-reload
 systemctl restart docker.service
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes"```

删除.kube/目录,rm -rf ./kube
参考链接 https://blog.csdn.net/woay2008/article/details/93250137

[root@master ~]# kubectl get nodes
error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

缺少 .kube/config文件

[root@master ~]# mkdir .kube
[root@master ~]# cp /etc/kubernetes/admin.conf .kube/config

8
ImagePullBackOff
利用阿里云下载相关镜像

9

No resources found in default namespace.

解决方法:

# kubectl get pods 需要指明命名空间
# kubectl get nodes 查看节点

10

coredns-66bff467f8-6bwmz             0/1     ContainerCreating   0          8m45s

查了好多,没啥好办法。kubeadm reset重置后,删除.kube目录,kube-flannel.yaml文件。在重新部署就好了。。好了。。

在添加节点执行报错时(文件已存在或者端口被占用), 可以执行kubeadm reset即可。

kubeadm join

12

error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

将当前环境删除干净,在/root目录下重新执行(或者在其他用户根目录下执行)

Unable to connect to the server: read tcp 192.168.47.128:40882->151.101.0.133:443: read: connection reset by peer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值