一次calico-kube-controllers 一直处于创建中引发的后续

news/2024/10/6 4:50:09/文章来源:https://www.cnblogs.com/Ky150/p/18288133

背景:

由于课程代码都是基于amd64架构进行编写的,这将导致我的主力机arm64架构机器无法顺利进行实验内容,因此我得在x64的机器上进行实验内容,先是需要搭建K8S环境,此处省略搭建步骤,在我进行kubeadm init操作后,发现镜像拉取一直不成功,镜像地址我写的是默认从K8S官方地址拉取镜像的(这里提一下为什么不写国内镜像地址的原因,原因在于国内镜像仓库更新速度过慢,有时候拉取一些images时会找不到),于是我在我的宿主机开启了代理启用了全局代理模式,发现我的K8S集群仍是无法拉取镜像,提示TimeOut。

于是,我将流量转发配置写在了containerd.service文件内,如以下所示:

root@Y76-Master01-16-181:~# cat /usr/lib/systemd/system/containerd.service 
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerdType=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5# 添加以下三行
Environment="HTTPS_PROXY=http://172.164.17.103:9999"
Environment="HTTP_PROXY=http://172.164.17.103:9999"
Environment="ALL_PROXY=socks5://172.164.17.103:9999"# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999[Install]
WantedBy=multi-user.target

 添加代理后,再次进行kubeadm init 操作后,K8S的镜像能顺利被拉到本地中,即通过 crictl命令查看

root@Y76-Master01-16-181:~# crictl -r unix:///var/run/containerd/containerd.sock images

 此处,集群组件状态一切正常,都处于Runing状态,于是我进行calico部署,calico-node Pod都处于Runing状态,唯独calico-kube-controllers  Pod一直处于创建中,查看Pod详细信息

root@Y76-Master01-16-181:~# kubectl describe pod -n kube-system calico-kube-controllers-9449c44c5-v8ssv Normal   Scheduled               72s    default-scheduler  Successfully assigned kube-system/calico-kube-controllers-57b57c56f-wz4wm to y76-node01-16-182
Warning  FailedCreatePodSandBox  52s               kubelet            Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "c0805304ad1009d138d00cad8b5a4d9ddfdd27b8d6a8a886d4df4690cace4452": plugin type="calico" failed (add): error getting ClusterInformation: Get "https://10.96.0.1:443/apis/crd.projectcalico.org/v1/clusterinformations/default": net/http: TLS handshake timeout
Normal   SandboxChanged          5s (x3 over 51s)  kubelet            Pod sandbox changed, it will be killed and re-created.

 到此处,我进行了一系列排查,但没能解决calico-kube-controllers 状态问题,即使我创建新的Pod也是无法成功创建出来,报错如上图一致,当百思不得其解时,我将虚拟机都还原成原先的快照,填写了国内的镜像地址后进行kubeadm init时,能成功了将所有组件的Pod都Runing起来

思考:

仅仅是镜像地址不同,但却是两个结果,这不应该。我联想到了我一开始的proxy代理操作(即在containerd.service配置了代理),于是,我将虚拟机再次还原快照,重新填写K8S官方的镜像仓库地址,再次进行kubeadm 初始化时,遇到了同样问题,我将containrd.service的配置改成如下内容:

root@Y76-Master01-16-181:~# cat /usr/lib/systemd/system/containerd.service 
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerdType=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5# 优化成以下内容
Environment="HTTPS_PROXY=http://172.164.17.103:9999"
Environment="HTTP_PROXY=http://172.164.17.103:9999"
Environment="NO_PROXY=localhost,127.0.0.1,172.16.0.0/12,10.96.0.0/12,10.244.0.0/16"# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999[Install]
WantedBy=multi-user.target


随时将配置同步给其他节点且重启containerd服务

root@Y76-Master01-16-181:~# ansible all -m copy -a "src=/usr/lib/systemd/system/containerd.service  dest=/usr/lib/systemd/system/containerd.service"root@Y76-Master01-16-181:~# ansible all -m shell -a "systemctl daemon-reload && systemctl restart containerd.service "

 果不其然,Pod状态一切正常

root@Y76-Master01-16-181:~# kubectl get pod -n kube-system 
NAME                                          READY   STATUS    RESTARTS       AGE
calico-kube-controllers-9449c44c5-v8ssv       1/1     Running   0              92m
calico-node-97qbc                             1/1     Running   3 (38m ago)    6h1m
calico-node-bl59h                             1/1     Running   2 (178m ago)   6h1m
calico-node-rzzq7                             1/1     Running   2 (178m ago)   6h1m
coredns-567c556887-8knp9                      1/1     Running   3 (51m ago)    8h
coredns-567c556887-dwg6d                      1/1     Running   2 (178m ago)   8h
etcd-y76-master01-16-181                      1/1     Running   3 (178m ago)   8h
kube-apiserver-y76-master01-16-181            1/1     Running   3 (178m ago)   8h
kube-controller-manager-y76-master01-16-181   1/1     Running   6 (46m ago)    5h46m
kube-proxy-88nd6                              1/1     Running   2 (178m ago)   5h47m
kube-proxy-vrgtp                              1/1     Running   2 (178m ago)   5h47m
kube-proxy-z5jmc                              1/1     Running   2 (178m ago)   5h47m
kube-scheduler-y76-master01-16-181            1/1     Running   6 (46m ago)    8h

 总结:

在进行排错时,应当回想操作过程中自己执行了哪些操作,再排查问题时,应当细究自己做的操作会有怎样的影响,例如此次操作,我将proxy代理给了宿主机,这意味着我的Pod会把流量转发给宿主机,通过宿主机进行通信,而Pod要通信的对端IP地址正是我定义的Pod网段(10.96.0.0/12,10.244.0.0/16),这通过宿主机进行通信肯定是找不到对端的。

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/739991.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

pandas 检查表单指定列是否有重复数据【实际业务实践】

pandas 检查表单指定列是否有重复数据,重复时返回重复的数据,实际业务实践。一、业务需求 财务系统中提报业务时,需要检查业务附件中的两列是否在当前电子表格内重复。 比如检查 票据编号 + 子票区间 是否有重复。 二、业务数据 以下是脱敏的真实业务数据。制单号 制单状态 …

Kindle电子书_使用Calibre给kindle远程传书的两种方式:网页浏览器与KOreader客户端传书

因为想使用KOreader的无框架模式,不用看书看着看着就重启KOreader,所以打算找找有什么办法使用KOreader无线传书。查到具体办法之后顺便写一下在非越狱的kindle上使用自带浏览器配合Calibre传书的方法。 使用网页浏览器点击Calibre的连接/共享中的“启动内容服务器”的选项,…

春秋杯 2024夏季

BEDTEA [题目制作过程]: 首先是通过矩阵相乘的方法来获取斐波那契数列来作为后面tea的每一轮的key,tea的轮数常数和左移右移都被魔改了,加了PEB的反调试,这个调试的作用是key从第几位取,如果正常运行则是从第三个开始取,考察师傅们面对tea的魔改的能力,然后将加密后的数…

西瓜杯 WP

RE 一个西瓜切两半你一半我一半 有点谜语,文本给的是输出和key # Visit https://www.lddgo.net/string/pyc-compile-decompile for more information # Version : Python 3.6flag= key = 一个西瓜切两半你一半我一半 # output=乃乾觅甯剏乳厡侻丨厏扝乌博丿乜规甲剌乶厝侥丿卻…

双亲委派机制和SPI的理解

双亲委派机制和SPI的理解 双亲委派机制基本原理 双亲委派机制简单的来说是JVM类加载过程的一个非强约束模型。子类加载器加载对应的Class,不会直接加载,首先会交由其父类加载器加载,若父类加载器无法加载,则由自己加载。 Java一共有三层类加载器,级别从上往下依次是:Boot…

Simple WPF: WPF 自定义按钮外形

WPF的按钮提供了Template模板,可以通过修改Template模板中的内容对按钮的样式进行自定义。结合资源字典,可以将自定义资源在xaml窗口、自定义控件或者整个App当中调用最新内容优先发布于个人博客:小虎技术分享站,随后逐步搬运到博客园。 WPF的按钮提供了Template模板,可以…

三维重建工作的一些调研

GPT关于3D-GS的回答如果我获得了一个3D高斯溅射的表达,给定任意的相机内参和外参,是不是就能生成一副2D图像Yes, given a 3D Gaussian splatting representation and the intrinsic and extrinsic camera parameters, you can generate a 2D image from any desired viewpoin…

Spark Special_杨宁远 杂题分析.md

Spark Special 图论_杨宁远 杂题分析 Date: 2024-07-03 Preface 本文基于杨宁远 @ynycoding 的课件与题单,对省选/NOIP阶段图论的建模方法和解题策略进行总结,以及本阶段常用方法、模型和 Trick。 A. [AGC056C] 0/1 Balanced [AGC056C] 01 Balanced - 洛谷 | 计算机科学教育新…

按指定日期重复

问题:根据D1指定的日期将A2:C8区域进行重复公式1(姓名)右拉下拉完成 =INDEX(A:A,MOD(ROW(A1)+COUNTA(A:A)-2,COUNTA(A:A)-1)+2) 公式2(日期)下拉完成 =SUBSTITUTE(LEFT(D$1,FIND("-",D$1)-1),".","/")+(ROW(A1)-1)/(COUNTA(A:A)-1) 公式3(…

语法2-运算符、包机制、JavaDoc

语法 运算符 运算符具有优先级-网上查(一般使用括号保证)/-除,%-取余符号-21/10二十一除十取余数,幂运算使用工具类表示Math.pow(2,3)-2的3次方 ++自加,--自减 int a =3 ; int b =a++;//输出a=4,b=3 int b =++a;//输出a=4,b=4==-等于,!=-instanceof-不等于逻辑运算符-与或…

厦门福州七日游

厦门福州七日游2024-06-30 上午被发短信告知航班延误两个半小时。 晚上八点多九点才到了厦门,湘妹 yhp yzf 已经在酒店了。厦门机场不通地铁?????于是打了个车去地铁站。 酒店就在中山路步行街上,有各种店铺。点了一份外卖,和大伙打了一会三国杀,输了几局 2024-07-01 …

SumIf的问题

问题:进销存表数据等于同货号入库表中数据 函数公式解决:=SUMIF(入库!A:A,B3,入库!C:C)