【问题标题】:Error trying runnning kubeadm init on Centos 7尝试在 Centos 7 上运行 kubeadm init 时出错
【发布时间】:2019-11-10 05:12:02
【问题描述】:

我是 kubeletes 的新手,我无法成功运行“kubeadm init”。

让我一步一步地告诉你我做了什么:

  1. 我按照 dockers 文档使用 yum 安装了最新版本的 dockers (我在 /etc/systemd/system/docker.service.d/http-proxy.conf 中配置了 'Environment="HTTP_PROXY=http://usuario:password@proxy:port/" "HTTPS_PROXY=http://usuario:password@proxy:port/"')。

  2. 我已禁用 SELINUXTYPE,使用命令“swapoff -a”禁用交换,并在 /etc/fstab 中注释“#/dev/mapper/centos-swap swap swap defaults 0 0”。

  3. 我使用“modprobe br_netfilter”和“echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables”来激活名为“br_netfilter”的模块。

  4. “kubernetes.repo”文件使用 yum 安装“kubelet kubeadm kubectl”:

    [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
    
  5. 打开的端口:

     firewall-cmd --permanent --add-port=6443/tcp
     firewall-cmd --permanent --add-port=2379-2380/tcp
     firewall-cmd --permanent --add-port=10250/tcp
     firewall-cmd --permanent --add-port=10251/tcp
     firewall-cmd --permanent --add-port=10252/tcp
     firewall-cmd --permanent --add-port=10255/tcp
     firewall-cmd --reload
    
  6. 我创建了“10-kubeadm.conf”文件:

     [Service]
     Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
     Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
     # This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
     EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
     # This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
     # the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
     EnvironmentFile=-/etc/sysconfig/kubelet
     ExecStart=
     ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
    
  7. 重新加载并启用服务:

     systemctl daemon-reload
     systemctl restart docker
     systemctl enable docker
     systemctl restart kubelet
     systemctl enable kubelet
    

    (两个服务的状态:活动(运行))

错误:

[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'

Additionally, a control plane component may have crashed or exited when started by the container runtime.
To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker.
Here is one example how you may list all Kubernetes containers running in docker:
    - 'docker ps -a | grep kube | grep -v pause'
    Once you have found the failing container, you can inspect its logs with:
    - 'docker logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster

提前感谢您的帮助。

最好的问候。

【问题讨论】:

    标签: docker kubernetes centos7


    【解决方案1】:

    请禁用您的交换

    swapoff -a
    
    vim /etc/fstab
    

    评论交换行 之后安装这个包

    yum install -y yum-utils device-mapper-persistent-data lvm2
    

    并以此添加回购

    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    

    你应该通过这个命令安装 docker

    yum install -y docker-ce
    
    
    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
    EOF
    
    yum install -y kubelet kubeadm kubectl
    

    然后重启

    systemctl start docker && systemctl enable docker
    systemctl start kubelet && systemctl enable kubelet
    
    
    systemctl daemon-reload
    systemctl restart kubelet
    
    kubeadm init --apiserver-advertise-address=MASTER_IP --pod-network-cidr=10.244.0.0/16
    

    不要更改 10.244.0.0/16

    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config
    

    接下来,使用 kubectl 命令将 flannel 网络部署到 kubernetes 集群。

    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
    

    我编写了运行 kubernetes 的完整方法,并通过此命令运行 kubernetes 集群 1000 次

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-24
      • 2016-08-09
      • 2014-02-02
      • 1970-01-01
      • 2018-03-13
      • 2015-06-29
      • 2021-10-09
      相关资源
      最近更新 更多