美文网首页
k8s NodeSelector调度失败

k8s NodeSelector调度失败

作者: 百里江山 | 来源:发表于2022-02-15 11:55 被阅读0次

错误信息

Name:           nginx-dispatch-697775dcd8-sdgbc
Namespace:      dev
Priority:       0
Node:           <none>
Labels:         app=nginx-dispatch
                pod-template-hash=697775dcd8
Annotations:    <none>
Status:         Pending
IP:             
Controlled By:  ReplicaSet/nginx-dispatch-697775dcd8
Containers:
  nginx-dispatch:
    Image:      nginx:1.9.7
    Port:       80/TCP
    Host Port:  0/TCP
    Limits:
      cpu:     100m
      memory:  100Mi
    Requests:
      cpu:      100m
      memory:   100Mi
    Liveness:   tcp-socket :80 delay=5s timeout=5s period=10s #success=1 #failure=3
    Readiness:  http-get http://:80/ delay=5s timeout=2s period=10s #success=1 #failure=3
    Environment:
      DB_HOST:  <set to the key 'DB_HOST' of config map 'nginx-dispatch'>  Optional: false
    Mounts:
      /etc/localtime from localtime (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-nwjmh (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  localtime:
    Type:          HostPath (bare host directory volume)
    Path:          /usr/share/zoneinfo/Asia/Shanghai
    HostPathType:  
  default-token-nwjmh:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-nwjmh
    Optional:    false
QoS Class:       Guaranteed
Node-Selectors:  run=pro
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age                From               Message
  ----     ------            ----               ----               -------
  Warning  FailedScheduling  20s (x2 over 32s)  default-scheduler  0/2 nodes are available: 2 node(s) didn't match node selector.

从Events 分析到,scheduler 调度失败,没有匹配的工作节点。
此时需要分析本pod 采用了什么调度方式。从以上信息可以找到 Node-Selectors: run=pro 采用了 NodeSelector 方式调度,调度到node节点标签为 run=pro的。那我们查询一下 node 上的标签信息有没有。

-> # kubectl get nodes --show-labels                              
NAME                STATUS   ROLES         AGE   VERSION   LABELS
21.host.com   Ready    master,node   32d   v1.15.9   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=hdss7-21.host.com,kubernetes.io/os=linux,node-role.kubernetes.io/master=,node-role.kubernetes.io/node=
22.host.com   Ready    master,node   32d   v1.15.9   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=hdss7-22.host.com,kubernetes.io/os=linux,node-role.kubernetes.io/master=,node-role.kubernetes.io/node=

以上node节点上并没有 run=pro 标签的。所以我们需要加上一个标签

-> # kubectl label nodes 21.host.com run=pro 
node/21.host.com labeled

再次查看pods信息。显示调度成功

-> # kubectl get pods -n dev -o wide
NAME                              READY   STATUS    RESTARTS   AGE     IP           NODE                NOMINATED NODE   READINESS GATES
nginx-dispatch-697775dcd8-sdgbc   1/1     Running   0          8m35s   172.7.21.7   21.host.com   <none>           <none>

相关文章

网友评论

      本文标题:k8s NodeSelector调度失败

      本文链接:https://www.haomeiwen.com/subject/iboklrtx.html