当前位置: 首页 > 知识库问答 >
问题:

使用Kubeadm创建高可用性Kubernetes集群时出错

章德惠
2023-03-14

我正在使用kubeadm在VM中创建Kubernetes集群(我在VM中使用的映像是CentOS 7 CIS Hardened)。

我正在遵循这个用Kubeadm创建高可用性集群的官方文档

到目前为止我已经完成的步骤:

yum update
yum install docker
sudo systemctl start docker
sudo systemctl status docker
systemctl enable docker.service

将这些值更改为1而不是0

nano /proc/sys/net/bridge/bridge-nf-call-iptables
nano /proc/sys/net/bridge/bridge-nf-call-ip6tables

回声 1

sestatus
setenforce 0
nano /etc/selinux/config

禁用交换:swapoff-a sed-e'/swapoff/s/^#*/#/' -i /etc/fstab挂载-a

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable kubelet && systemctl start kubelet
systemctl daemon-reload

这样做之后,我创建了一个名为kubeadm-config.yaml的文件

apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
kubernetesVersion: stable
controlPlaneEndpoint: "LoadBalancerIP"

kubeadm init--config=kubeadm配置。yaml—上载证书

[init] Using Kubernetes version: v1.15.0
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [vm3 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.0.0.6 52.174                                                                           .21.65]
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [vm3 localhost] and IPs [10.0.0.6 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [vm3 localhost] and IPs [10.0.0.6 127.0.0.1 ::1]
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[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 condition

This 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)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
        - 'systemctl status kubelet'
        - 'journalctl -xeu kubelet'

但是,

systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Mon 2019-06-24 07:23:57 UTC; 1h 44min ago
     Docs: https://kubernetes.io/docs/
 Main PID: 29985 (kubelet)
   CGroup: /system.slice/kubelet.service
           └─29985 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cg...

Jun 24 09:08:21 vm3 kubelet[29985]: E0624 09:08:21.671662   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:21 vm3 kubelet[29985]: E0624 09:08:21.771927   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:21 vm3 kubelet[29985]: E0624 09:08:21.872163   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:21 vm3 kubelet[29985]: E0624 09:08:21.972355   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:22 vm3 kubelet[29985]: E0624 09:08:22.072534   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:22 vm3 kubelet[29985]: E0624 09:08:22.172783   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:22 vm3 kubelet[29985]: E0624 09:08:22.272966   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:22 vm3 kubelet[29985]: E0624 09:08:22.373141   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:22 vm3 kubelet[29985]: E0624 09:08:22.473314   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:08:22 vm3 kubelet[29985]: E0624 09:08:22.573542   29985 kubelet.go:2248] node "vm3" not found
[root@vm3 vm2]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-06-24 07:12:39 UTC; 1h 56min ago
     Docs: http://docs.docker.com
 Main PID: 28682 (dockerd-current)
   CGroup: /system.slice/docker.service
           ├─28682 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --u...
           ├─28688 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/dock...
           ├─30073 /usr/bin/docker-containerd-shim-current 6873dad40999d42255b3ffb78f1212409b8ae01450853e33b928f67a3b5f9116 /var/run/docker/libcontainerd/6873dad40999d42255b3ffb78f12...
           ├─30109 /usr/bin/docker-containerd-shim-current eb3945f99d1a5b7aa1c07086a2fed12a60afa7ffec3a89127fe51615f11a9621 /var/run/docker/libcontainerd/eb3945f99d1a5b7aa1c07086a2fe...
           ├─30170 /usr/bin/docker-containerd-shim-current 930354300ef22146adf972f098562336ec2dcf274808cc18d8db6d22ec425673 /var/run/docker/libcontainerd/930354300ef22146adf972f09856...
           ├─30237 /usr/bin/docker-containerd-shim-current dfdb99a011f6762d86986c211663b162c43dd1c20f99f63fd855d87242f2f617 /var/run/docker/libcontainerd/dfdb99a011f6762d86986c211663...
           └─30366 /usr/bin/docker-containerd-shim-current 7f13a2b265d9733d8db34aa7acfe7f320c3ef2b5d523146b2ffeefa6b3bf666c /var/run/docker/libcontainerd/7f13a2b265d9733d8db34aa7acfe...

Jun 24 09:09:26 vm3 dockerd-current[28682]: E0624 09:09:26.396927       1 reflector.go:125] k8s.io/client-go/informers/factory.go:133: Failed to list *v1.Service: Get htt... i/o timeout
Jun 24 09:09:26 vm3 dockerd-current[28682]: I0624 09:09:26.398140       1 trace.go:81] Trace[922903595]: "Reflector k8s.io/client-go/informers/factory.go:133 ListAndWatch...000377891s):
Jun 24 09:09:26 vm3 dockerd-current[28682]: Trace[922903595]: [30.000377891s] [30.000377891s] END
Jun 24 09:09:26 vm3 dockerd-current[28682]: E0624 09:09:26.398164       1 reflector.go:125] k8s.io/client-go/informers/factory.go:133: Failed to list *v1.PersistentVolume... i/o timeout
Jun 24 09:09:26 vm3 dockerd-current[28682]: I0624 09:09:26.399536       1 trace.go:81] Trace[1309975098]: "Reflector k8s.io/client-go/informers/factory.go:133 ListAndWatc...000249191s):
Jun 24 09:09:26 vm3 dockerd-current[28682]: Trace[1309975098]: [30.000249191s] [30.000249191s] END
Jun 24 09:09:26 vm3 dockerd-current[28682]: E0624 09:09:26.399556       1 reflector.go:125] k8s.io/client-go/informers/factory.go:133: Failed to list *v1.ReplicationContr... i/o timeout
Jun 24 09:09:26 vm3 dockerd-current[28682]: I0624 09:09:26.400806       1 trace.go:81] Trace[1990792995]: "Reflector k8s.io/client-go/informers/factory.go:133 ListAndWatc...000302791s):
Jun 24 09:09:26 vm3 dockerd-current[28682]: Trace[1990792995]: [30.000302791s] [30.000302791s] END
Jun 24 09:09:26 vm3 dockerd-current[28682]: E0624 09:09:26.400824       1 reflector.go:125] k8s.io/client-go/informers/factory.go:133: Failed to list *v1.StorageClass: Ge... i/o timeout
Hint: Some lines were ellipsized, use -l to show in full.


----


journalctl -xeu kubelet
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.173524   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.273712   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.373946   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.474120   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.574342   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.674566   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.774791   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.874989   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:47 vm3 kubelet[29985]: E0624 09:10:47.975152   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: I0624 09:10:48.032756   29985 kubelet_node_status.go:286] Setting node annotation to enable volume controller attach/detach
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.037735   29985 pod_workers.go:190] Error syncing pod aadedc1082b1437c80407350a8e8e7da ("etcd-vm3_kube-system(aadedc1082b1437c80407350a8e8e7da)"), skipping: failed to "StartContainer" for "etcd" with CrashLoopB
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.075398   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.175561   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.275773   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.375943   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.476103   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.576329   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: I0624 09:10:48.640424   29985 kubelet_node_status.go:286] Setting node annotation to enable volume controller attach/detach
Jun 24 09:10:48 vm3 kubelet[29985]: I0624 09:10:48.644654   29985 kubelet_node_status.go:72] Attempting to register node vm3
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.676515   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.776713   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.876884   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:48 vm3 kubelet[29985]: E0624 09:10:48.977079   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.077281   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.177529   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.277724   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: W0624 09:10:49.278257   29985 cni.go:213] Unable to update cni config: No networks found in /etc/cni/net.d
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.341494   29985 eviction_manager.go:247] eviction manager: failed to get summary stats: failed to get node info: node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.377962   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.478116   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.578271   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.678475   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.778660   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.878921   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:49 vm3 kubelet[29985]: E0624 09:10:49.979137   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.079316   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.179554   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.279752   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.379896   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.480148   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.580264   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.680496   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.780740   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.804619   29985 kubelet.go:2169] Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.880896   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:50 vm3 kubelet[29985]: E0624 09:10:50.981216   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.081409   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.181648   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.281779   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.381904   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.482159   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.582329   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.682502   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.782682   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.882868   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:51 vm3 kubelet[29985]: E0624 09:10:51.983112   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.083299   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.183510   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.283712   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.383869   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.484123   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.584315   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.684482   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.784715   29985 kubelet.go:2248] node "vm3" not found
Jun 24 09:10:52 vm3 kubelet[29985]: E0624 09:10:52.884935   29985 kubelet.go:2248] node "vm3" not found

我需要在CentOS映像中创建HA Kubnetes集群。但我坚持到了这一点。

共有1个答案

相弘和
2023-03-14

您应该将< code> - node-name与< code>kubeadm init一起使用:

$ sudo kubeadm init --node-name master1

该标志将适当的主机名覆盖值传递给kube let:https://kubernetes . io/docs/reference/setup-tools/kube ADM/kube ADM-init/# setting-the-node-name

使用配置文件时,请在初始化配置的节点注册段落中添加字段名称

apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
nodeRegistration:
  name: "master1"

您可以参考以下文档:https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2#hdr-库beadm_init_configuration_types

 类似资料:
  • 我尝试为库伯内特斯设置一个haproxd的多主节点设置,如[1]中所述。我的网络配置是: haproc=192.168.1.213 master 0|1|2=192.168.1.210|211|212 worker0|1|2=192.168.1.220|221|222(此时不感兴趣) 所有主机都能够相互连接(DNS针对每个节点进行解析)。每个节点都运行 Ubuntu 18.04.3 (LTS)。泊

  • kuberntes 系统使用 etcd 存储所有数据,本文档介绍部署一个三节点高可用 etcd 集群的步骤,这三个节点复用 kubernetes master 机器,分别命名为test-001.jimmysong.io、test-002.jimmysong.io、test-003.jimmysong.io: test-001.jimmysong.io:172.20.0.113 test-002.j

  • 我打算在 debian 9.3 上安装 kubenetes,我按照本文档中的说明 https://kubernetes.io/docs/setup/independent/install-kubeadm/,它未能创建带有超时错误的集群,我使用的命令如下: 最后一个命令挂断1小时并超时失败,我发现命令docker ps已经运行了几个容器,正在运行的容器包括库贝-Controlor-manager-a

  • 架构 上节课我们给大家讲解了 k8s 的基本概念与几个主要的组件,我们在了解了 k8s 的基本概念过后,实际上就可以去正式使用了,但是我们前面的课程都是在 katacoda 上面进行的演示,只提供给我们15分钟左右的使用时间,所以最好的方式还是我们自己来手动搭建一套 k8s 的环境,在搭建环境之前,我们再来看一张更丰富的k8s的架构图。 ​​ ​ 核心层:Kubernetes 最核心的功能,对外提

  • 本文向大家介绍使用Kubeadm在CentOS7.2上部署Kubernetes集群的方法,包括了使用Kubeadm在CentOS7.2上部署Kubernetes集群的方法的使用技巧和注意事项,需要的朋友参考一下 本文参考kubernetes官网文章Installing Kubernetes on Linux with kubeadm在CentOS7.2使用Kubeadm部署Kuebernetes集

  • 本文档提供一个可扩展、高可用的 Seafile 集群架构。这种架构主要是面向较大规模的集群环境,可以通过增加更多的服务器来提升服务性能。如果您只需要高可用特性,请参考3节点高可用集群文档。 架构" class="reference-link"> 架构 Seafile集群方案采用了3层架构: 负载均衡层:将接入的流量分配到 seafile 服务器上。并且可以通过部署多个负载均衡器来实现高可用。 Se