代码之家  ›  专栏  ›  技术社区  ›  user3398900

Kube dns始终处于挂起状态

  •  1
  • user3398900  · 技术社区  · 6 年前

    我已经按照以下链接在virt manager虚拟机上部署了kubernetes

    https://kubernetes.io/docs/setup/independent/install-kubeadm/

    当我将另一个vm加入集群时,我发现kube dns处于挂起状态。

    root@ubuntu1:~# kubectl get pods --all-namespaces 
    NAMESPACE     NAME                              READY     STATUS    RESTARTS   AGE
    kube-system   etcd-ubuntu1                      1/1       Running   0          7m
    kube-system   kube-apiserver-ubuntu1            1/1       Running   0          8m
    kube-system   kube-controller-manager-ubuntu1   1/1       Running   0          8m
    kube-system   kube-dns-86f4d74b45-br6ck         0/3       Pending   0          8m
    kube-system   kube-proxy-sh9lg                  1/1       Running   0          8m
    kube-system   kube-proxy-zwdt5                  1/1       Running   0          7m
    kube-system   kube-scheduler-ubuntu1            1/1       Running   0          8m
    
    
    root@ubuntu1:~# kubectl --namespace=kube-system describe pod kube-dns-86f4d74b45-br6ck
    Name:           kube-dns-86f4d74b45-br6ck
    Namespace:      kube-system
    Node:           <none>
    Labels:         k8s-app=kube-dns
                    pod-template-hash=4290830601
    Annotations:    <none>
    Status:         Pending
    IP:             
    Controlled By:  ReplicaSet/kube-dns-86f4d74b45
    Containers:
      kubedns:
        Image:       k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.8
        Ports:       10053/UDP, 10053/TCP, 10055/TCP
        Host Ports:  0/UDP, 0/TCP, 0/TCP
        Args:
          --domain=cluster.local.
          --dns-port=10053
          --config-dir=/kube-dns-config
          --v=2
        Limits:
          memory:  170Mi
        Requests:
          cpu:      100m
          memory:   70Mi
        Liveness:   http-get http://:10054/healthcheck/kubedns delay=60s timeout=5s period=10s #success=1 #failure=5
        Readiness:  http-get http://:8081/readiness delay=3s timeout=5s period=10s #success=1 #failure=3
        Environment:
          PROMETHEUS_PORT:  10055
        Mounts:
          /kube-dns-config from kube-dns-config (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from kube-dns-token-4fjt4 (ro)
      dnsmasq:
        Image:       k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.8
        Ports:       53/UDP, 53/TCP
        Host Ports:  0/UDP, 0/TCP
        Args:
          -v=2
          -logtostderr
          -configDir=/etc/k8s/dns/dnsmasq-nanny
          -restartDnsmasq=true
          --
          -k
          --cache-size=1000
          --no-negcache
          --log-facility=-
          --server=/cluster.local/127.0.0.1#10053
          --server=/in-addr.arpa/127.0.0.1#10053
          --server=/ip6.arpa/127.0.0.1#10053
        Requests:
          cpu:        150m
          memory:     20Mi
        Liveness:     http-get http://:10054/healthcheck/dnsmasq delay=60s timeout=5s period=10s #success=1 #failure=5
        Environment:  <none>
        Mounts:
          /etc/k8s/dns/dnsmasq-nanny from kube-dns-config (rw)
          /var/run/secrets/kubernetes.io/serviceaccount from kube-dns-token-4fjt4 (ro)
      sidecar:
        Image:      k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.8
        Port:       10054/TCP
        Host Port:  0/TCP
        Args:
          --v=2
          --logtostderr
          --probe=kubedns,127.0.0.1:10053,kubernetes.default.svc.cluster.local,5,SRV
          --probe=dnsmasq,127.0.0.1:53,kubernetes.default.svc.cluster.local,5,SRV
        Requests:
          cpu:        10m
          memory:     20Mi
        Liveness:     http-get http://:10054/metrics delay=60s timeout=5s period=10s #success=1 #failure=5
        Environment:  <none>
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from kube-dns-token-4fjt4 (ro)
    Conditions:
      Type           Status
      PodScheduled   False 
    Volumes:
      kube-dns-config:
        Type:      ConfigMap (a volume populated by a ConfigMap)
        Name:      kube-dns
        Optional:  true
      kube-dns-token-4fjt4:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  kube-dns-token-4fjt4
        Optional:    false
    QoS Class:       Burstable
    Node-Selectors:  <none>
    Tolerations:     CriticalAddonsOnly
                     node-role.kubernetes.io/master:NoSchedule
                     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s
    Events:
      Type     Reason            Age               From               Message
      ----     ------            ----              ----               -------
      Warning  FailedScheduling  6m (x7 over 7m)   default-scheduler  0/1 nodes are available: 1 node(s) were not ready.
      Warning  FailedScheduling  3s (x19 over 6m)  default-scheduler  0/2 nodes are available: 2 node(s) were not ready.
    

    谁能帮我解构一下,找出真正的问题??

    任何帮助都是无用的

    提前谢谢。

    3 回复  |  直到 6 年前
        1
  •  2
  •   dongi    6 年前

    除了@justcompile编写的内容之外,您还需要至少 2个CPU核 为了从 kube系统 命名空间没有问题。

    您需要验证该框上有多少资源,并将其与每个pod的CPU预留量进行比较。

    例如,在您提供的输出中,我可以看到您的DNS服务尝试为10%的CPU核心进行预留:

    Requests:
      cpu:      100m
    

    您可以使用以下方法检查每个已部署的POD及其CPU保留:

    kubectl describe pods --namespace=kube-system
    
        2
  •  0
  •   Se ven    6 年前

    在你的事业中 kubectl get pods --all-namespaces 输出无法看到任何关于pods网络的信息。

    因此,您可以选择一种网络实现,并且必须在kube dns完全部署之前安装一个Pod网络。有关详细信息 kube-dns is stuck in the Pending state install pod network solution

        3
  •  0
  •   justcompile    6 年前

    首先,如果你跑步 kubectl get nodes 这是否显示两个/所有节点都处于就绪状态?

    如果是,我面对这个问题,在检查时发现 kubectl get events 这表明POD出现了故障,因为它们至少需要2个CPU才能运行。

    当我最初通过VirtualBox在旧的Macbook Pro上运行此功能时,我不得不放弃并使用AWS(当然还有其他云平台可用),以便为每个节点获得多个CPU。