這一篇能節(jié)省你在?kubeadm init 時(shí)遇到問題的排錯(cuò)時(shí)間??。
整合了網(wǎng)上大佬的方案???♂?和官方建議??。
個(gè)人被這個(gè)問題折磨了好久??,希望總結(jié)出來能幫助到大家~
目錄
自定義配置文件初始化的建議
關(guān)注配置:?
advertiseAddress
imageRepository
nodeRegistration.criSocket
問題解決:this version of kubeadm only supports deploying clusters with the control plane version >= 1.26.3. Current version: v1.22
問題解決:failed to pull image registry.k8s.io/kube-apiserver:v1.26.3
問題解決:container runtime is not running
問題解決:?error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR Port-6443]
問題解決:[kubelet-check] Initial timeout of 40s passed
????????參考資料:
????????總結(jié)
自定義配置文件初始化的建議
生成當(dāng)前版本的初始化配置文件到 /etc/kubernetes 目錄下
kubeadm config print init-defaults > /etc/kubernetes/init-default.yaml
關(guān)注配置:?
advertiseAddress
指定kube-apiserver廣播給其他組件的IP地址。
這個(gè)參數(shù)需要設(shè)置為主節(jié)點(diǎn)的IP地址,以確保其他節(jié)點(diǎn)可以訪問到kube-apiserver
即:advertiseAddress: 1.2.3.4 -> advertiseAddress: [宿主機(jī)ip(內(nèi)網(wǎng))]
imageRepository
指定安裝鏡像的倉庫源
建議使用國內(nèi)鏡像如阿里云->?imageRepository:?registry.aliyuncs.com/google_containers
可以通過ping倉庫源看看宿主機(jī)能否正常訪問
nodeRegistration.criSocket
高版本(k8s?1.24+)使用非默認(rèn)(containerd)容器運(yùn)行時(shí)要修改socket位置
低版本無需關(guān)注
官網(wǎng):Container Runtimes | Kubernetes
nodeRegistration:
? criSocket: [Path to Unix domain socket]不同運(yùn)行時(shí)默認(rèn)到Unix域套接字的路徑
containerd?? ?unix:///var/run/containerd/containerd.sock
CRI-O?? ?unix:///var/run/crio/crio.sock
Docker Engine (using cri-dockerd)?? ?unix:///var/run/cri-dockerd.sock
this version of kubeadm only supports deploying clusters with the control plane version >= 1.26.3. Current version: v1.22
初始化時(shí)指定的版本跟安裝的版本不一致
# kubeadm version 查看的版本為1.26.3,
kubeadm version
# kubeadm init 指定的kubernetes版本為不兼容版本
kubeadm init --kubernetes-version=1.22
這個(gè)很好解決,卸載安裝的高版本或者指定版本為兼容版本
官網(wǎng)版本支持:
Version Skew Policy | Kubernetes
參考上文提到的初始化出來的配置文件對應(yīng)版本也很有
跟這個(gè)類似還有一個(gè) apiKeys不兼容問題,也直接參考初始化出來的配置文件的apiKeys。
failed to pull image registry.k8s.io/kube-apiserver:v1.26.3
問題:
拉取registry.k8s.io倉庫的鏡像源失敗
解決:
配置國內(nèi)鏡像源
配置文件修改:
-
imageRepository: registry.k8s.io -> imageRepository: registry.aliyuncs.com/google_containers
啟動命令加上:
?--image-repository=registry.aliyuncs.com/google_containers
container runtime is not running
這個(gè)問題導(dǎo)致的原因有很多
參考我的這一篇文章,有超級詳細(xì)的排查流程:【(Kubernetes)1.26.3+containerd/1.20.x + docker:container runtime is not running問題詳細(xì)排查】_mikasa_akm的博客-CSDN博客
error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR Port-6443]:
問題:
kubeadm init
初始化集群操作失敗的環(huán)境和配置遺留
解決:
重置節(jié)點(diǎn):kubeadm reset
[kubelet-check] Initial timeout of 40s passed
詳細(xì)錯(cuò)誤信息參考
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory “/etc/kubernetes/manifests”. This can take up to 4m0s
[kubelet-check] Initial timeout of 40s passed.Unfortunately, an error has occurred:
timed out waiting for the conditionThis error is likely caused by:
- The kubelet is not running
- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
首先建議查看日志:
journalctl -xeu kubelet
每行都掃一眼:留意 err、failed、cannot connet 等關(guān)鍵字獲取有用信息進(jìn)行問題定位。
常見問題:
advertiseAddress IP 配置有誤
首先將 advertiseAddress指定為你宿主機(jī)的內(nèi)網(wǎng)ip進(jìn)行排查
如果換成內(nèi)網(wǎng)IP可以成功則進(jìn)行下一步:
????????1.先查看當(dāng)前服務(wù)器公網(wǎng)IP是否可達(dá)(有些云服務(wù)器沒有公網(wǎng)ip的)
????????2.如果公網(wǎng)可達(dá)但因?yàn)閾Q成了公網(wǎng)導(dǎo)致初始化失敗
公網(wǎng)IP可達(dá)但初始化仍然失敗則:
????????查看 kubeadm 生成的 etcd 配置文件:cat /etc/kubernetes/manifests/etcd.yaml
????????關(guān)注--listen-peer-urls和--listen-client-urls后的地址是否正確
????????
--listen-peer-urls?
是etcd
節(jié)點(diǎn)監(jiān)聽對等節(jié)點(diǎn)請求的URL地址列表。
???--listen-client-urls
是 etcd 服務(wù)監(jiān)聽客戶端請求的地址。默認(rèn)情況下,
--listen-client-urls
是http://localhost:2379
,只監(jiān)聽本地回環(huán)地址,不允許遠(yuǎn)程連接。為了在集群外訪問 etcd,需要修改這個(gè)參數(shù)。常見的設(shè)置是使用內(nèi)部 IP 地址或者主機(jī)名(檢查這個(gè)是不是被換成你的公網(wǎng)ip了,如果是則修改)
Failed to create sandbox for pod :拉取 registry.k8s.io/pause:3.6 鏡像失敗
journalctl -xeu kubelet查看的日志報(bào)錯(cuò)信息
Failed to create sandbox for pod”
err="rpc error: code = Unknown desc =
failed to get sandbox image “registry.k8s.io/pause:3.6”:
failed to pull image “registry.k8s.io/pause:3.6
問題:
拉取 registry.k8s.io/pause:3.6 鏡像失敗 導(dǎo)致sandbox 創(chuàng)建不了而報(bào)錯(cuò)?
解決:
重新配置 sandbox 鏡像 倉庫,將默認(rèn)的 registry.k8s.io/pause:3.6 修改成 “k8simage/pause:3.6”
### 生成 containerd 的默認(rèn)配置文件
containerd config default > /etc/containerd/config.toml
### 查看 sandbox 的默認(rèn)鏡像倉庫在文件中的第幾行
cat /etc/containerd/config.toml | grep -n "sandbox_image"
### 使用 vim 編輯器 定位到 sandbox_image,將 倉庫地址修改成 k8simage/pause:3.6
vim /etc/containerd/config.toml
sandbox_image = "k8simage/pause:3.6"
### 重啟 containerd 服務(wù)
systemctl daemon-reload
systemctl restart containerd.service
參考:
Creating a cluster with kubeadm | Kubernetes
Kubernetes 入門 篇 Master 節(jié)點(diǎn)的安裝與部署_Robpubking的博客-CSDN博客
解決阿里云ECS下kubeadm部署k8s無法指定公網(wǎng)IP - osc_tc7vil4d的個(gè)人空間 - OSCHINA - 中文開源技術(shù)交流社區(qū)
kubeadm init初始化k8s集群時(shí)報(bào)錯(cuò),[kubelet-check] Initial timeout of 40s passed._k8s集群初始化失敗_「已注銷」的博客-CSDN博客
總結(jié)
真的使用新版本超級超級麻煩,不停試錯(cuò),找論壇,查文檔。弄了幾天時(shí)間才把問題解決 kubeadm init的的問題,長路漫漫,后續(xù)還有很長的路要走!
建議就是要文章來源:http://www.zghlxwxcb.cn/news/detail-402470.html
- 優(yōu)先考慮 機(jī)器適配和版本兼容問題
- 優(yōu)先考慮?網(wǎng)絡(luò)問題:宿主機(jī)能否ping通所需鏡像包的鏡像倉庫
- 多看官方文檔!英語不好就翻譯
這篇文章希望能幫到大家,有問題歡迎大家評論區(qū)一起討論一起解決!文章來源地址http://www.zghlxwxcb.cn/news/detail-402470.html
到了這里,關(guān)于kubernetes新版本使用kubeadm init的超全問題解決和建議的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!