k8s安装部署过程中出现的错误记录

1、kubeadm init 时出现错误1:
[ERROR FileContent–proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1
解决方法:利用sysctl 修改

cat /proc/sys/net/ipv4/ip_forward

该文件内容为0,表示禁止数据包转发,1表示允许。

echo "sysctl -w net.ipv4.ip_forward=1" >> /etc/rc.d/rc.local \
&& echo "sysctl -p" >> /etc/rc.d/rc.local \
&& chmod +x /etc/rc.d/rc.local \
&& ll /etc/rc.d/rc.local \
&& cat /proc/sys/net/ipv4/ip_forward

虚拟机重启生效
参考链接:https://www.cnblogs.com/wangbaobao/p/6674464.html
2、kubeadm init 时出现错误2:
[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.18.8: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
, error: exit status 1

(1)前言:我之前是将k8s-v1.18.3安装包上传到本地的,所以我这里采取的是离线安装。
先来看我之前的init语句:

kubeadm init --apiserver-advertise-address 192.168.12.181 --apiserver-bind-port 6443  --pod-network-cidr 172.16.0.0/16 

错误原因
这里我并没有指定安装的版本,所以报错了,因为我上传的版本是v1.18.3,而此时官网的最新版本是v1.18.8,因为没有指定版本,所以默认安装最新版本,即使kubernetes拉取镜像的方式是默认先从本地找,但是版本不对,它仍然以默认版本优先

解决方法
所以如果采用离线安装,请一定要指定安装版本,命令如下:–kubernetes-version v1.18.3

init完整命令

kubeadm init --kubernetes-version v1.18.3 --apiserver-advertise-address 192.168.12.181 --apiserver-bind-port 6443  --pod-network-cidr 172.16.0.0/16 

(2)如果采用从Google镜像库拉取的方式也会报如上错误,我认为的解决方法是替换成国内镜像源,需要在init时指定。

3、查看kubernetse服务组件状态出错:
NAME STATUS MESSAGE ERROR
scheduler Unhealthy Get http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: connect: connection refused
controller-manager Unhealthy Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: connect: connection refused

controller-managerhe 和 schedule状态为Unhealthy,是因为此时还没有部署这两个组件,待后续部署好之后再查看~

4、从github上通过wget下载文件时,出现错误:The connection to the server raw.githubusercontent.com was refused - did you specify the right host or port?

解决方案:
(1)通过ip查询网查询raw.githubusercontent.com的ip地址,如下图,将ip地址复制下来
在这里插入图片描述
(2)将复制的ip地址和域名添加到hosts文件中

vim /etc/hosts

在这里插入图片描述
再次wget,可能出现如下错误:
ERROR: cannot verify raw.githubusercontent.com’s certificate, issued by ‘/CN=H3C-HTTPS-Self-Signed-Certificate-71ee4d869d81f297’:
Self-signed certificate encountered.
ERROR: certificate common name ‘H3C-HTTPS-Self-Signed-Certificate-71ee4d869d81f297’ doesn’t match requested host name ‘raw.githubusercontent.com’.
To connect to raw.githubusercontent.com insecurely, use `–no-check-certificate’.

解决方案:给下载语句添加参数’–no-check-certificate’进行下载

5、删除docker镜像遇到错误:Error response from daemon: conflict: unable to delete 08a76921e28c (must be forced) - image is being used by stopped container 09f25b4b0794

分析:不能删除镜像,因为该镜像正运行在一个容器中

解决方法:先停止容器,删除容器,然后再删除镜像

docker stop 09f25b4b0794   # 容器ID(09f25b4b0794)错误提示中有
docker rm 09f25b4b0794
docker rmi 08a76921e28c

6、查看pod报错: Warning BackOff 8s (x2 over 50s) kubelet, node1 Back-off restarting failed container
参考连接:http://blog.csdn.net/sqhren626232/article/details/101013390

解决方法:

(1)编辑该deployment文件:

kubectl edit deploy nest-server-admin

(2)在deployment申明镜像的后面加上命令

command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

如图所示:
在这里插入图片描述
(3)再次查看deploy和pod,状态已为running

7、用ingress发布vue服务,然后在外网访问时出错:Invalid Host header

在这里插入图片描述
参考:https://blog.csdn.net/Cookysurongbin/article/details/86077241

分析:vue-cli搭建的环境,用nginx做代理服务器,访问时显示:Invalid Host header
经查是因为新版的webpack-dev-server出于安全考虑,默认检查hostname,如果hostname不是配置内的就不能访问。这样有2中方法,一种是设置跳过host检查,一种是直接host设置成你的地址。

解决方法:
(1)关闭host检查

  • 可以在build目录下的webpack.dev.conf.js文件,devServer下添加disableHostCheck:
    true,跳过检查
  • 同样的原理,可以在package.json文件修改scripts命令:webpack-dev-server
    –disableHostCheck=true

(2)设置host

设置成你的host,加入你的host是xxx.com,同样2中方法,修改配置文件,和script命令

  • 在config目录下修改index.js文件的host,这个默认是localhost,可修改成 xxx.com
  • package.json的script语句: webpack-dev-server
    –host=xxx.com或者–public=xxx.com
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值