k8s集群断电修复

k8s集群断电修复

  • 背景,部署在虚拟机上的k8s集群,由于客户重启了虚拟机,导致我们的k8s集群出现了故障
  • 现象:kube-proxy、CoreDNS的Pod 都消失了,且get ds 也查看不到ds

  • 解决: 思路是通过kubuadm init 重新加入到集群中,但是我们不能全部init,可以选部分组件init
# 通过帮助信息我们可以查看到有addon选项、control-plane是安装这些插件的
[root@node-1 ~]# kubeadm init phase  -h
Use this command to invoke single phase of the init workflow

Usage:
  kubeadm init phase [command]

Available Commands:
  addon              Install required addons for passing conformance tests
  bootstrap-token    Generates bootstrap tokens used to join a node to a cluster
  certs              Certificate generation
  control-plane      Generate all static Pod manifest files necessary to establish the control plane
    ’
    ‘
    ’
    ‘
  
# 进一步查看帮助文档,发现我们可以init  kube-proxy的
[root@node-1 ~]# kubeadm init phase addon -h
This command is not meant to be run on its own. See list of available subcommands.

Usage:
  kubeadm init phase addon [flags]
  kubeadm init phase addon [command]

Available Commands:
  all         Install all the addons
  coredns     Install the CoreDNS addon to a Kubernetes cluster
  kube-proxy  Install the kube-proxy addon to a Kubernetes cluster
# 所以我们执行,执行成功后kube-proxy就部署出来了,但是得改一下镜像地址才能拉取
root@node-1 ~]# kubeadm init phase addon kube-proxy
W0220 15:10:45.219358  227871 version.go:102] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get "https://dl.k8s.io/release/stable-1.txt": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
W0220 15:10:45.219438  227871 version.go:103] falling back to the local client version: v1.21.11
[addons] Applied essential addon: kube-proxy

官方参考:https://kubernetes.io/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init/#control-plane-flags

posted @ 2023-02-20 15:16  taotaozh  阅读(406)  评论(0编辑  收藏  举报