【问题标题】:Pod is in pending statPod 处于待处理状态
【发布时间】:2021-09-26 13:26:27
【问题描述】:

我已经制作了如下的自定义调度程序:

root@kmaster:~# cat /etc/kubernetes/manifests/my-scheduler.yaml 
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-scheduler
    tier: control-plane
  name: my-scheduler
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-scheduler
    - --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
    - --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
    - --bind-address=127.0.0.1
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=false
    - --port=10261
    - --secure-port=10269
    env:
    - name: no_proxy
      value: ',10.74.46.2,10.74.46.3,10.74.46.4'
    - name: NO_PROXY
      value: ',10.74.46.2,10.74.46.3,10.74.46.4'
    - name: HTTPS_PROXY
      value: http://127.0.0.1:3129
    - name: HTTP_PROXY
      value: http://127.0.0.1:3129
    image: k8s.gcr.io/kube-scheduler:v1.22.0
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 127.0.0.1
        path: /healthz
        port: 10269
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15
    name: my-scheduler
    resources:
      requests:
        cpu: 100m
    startupProbe:
      failureThreshold: 24
      httpGet:
        host: 127.0.0.1
        path: /healthz
        port: 10269
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15
    volumeMounts:
    - mountPath: /etc/kubernetes/scheduler.conf
      name: kubeconfig
      readOnly: true
  hostNetwork: true
  priorityClassName: system-node-critical
  securityContext:
    seccompProfile:
      type: RuntimeDefault
  volumes:
  - hostPath:
      path: /etc/kubernetes/scheduler.conf
      type: FileOrCreate
    name: kubeconfig
status: {}
root@kmaster:~# 

我的客户调度程序 pod 正在成功运行:

root@kmaster:~# kubectl get pods -n kube-system
NAME                              READY   STATUS    RESTARTS         AGE
coredns-78fcd69978-6dcft          1/1     Running   10 (2d19h ago)   47d
coredns-78fcd69978-8224d          1/1     Running   10 (2d19h ago)   47d
etcd-kmaster                      1/1     Running   4 (21h ago)      15d
kube-apiserver-kmaster            1/1     Running   68 (2d19h ago)   47d
kube-controller-manager-kmaster   1/1     Running   33 (21h ago)     47d
kube-flannel-ds-nvpgz             1/1     Running   11 (2d19h ago)   47d
kube-flannel-ds-xnvvw             1/1     Running   11 (2d19h ago)   47d
kube-flannel-ds-ztgql             1/1     Running   4 (2d19h ago)    47d
kube-proxy-h2t7s                  1/1     Running   4 (2d19h ago)    47d
kube-proxy-pq9t4                  1/1     Running   10 (2d19h ago)   47d
kube-proxy-vgcw7                  1/1     Running   8 (2d19h ago)    47d
kube-scheduler-kmaster            1/1     Running   0                21h
my-scheduler-kmaster              1/1     Running   0                7h17m

然后使用该调度程序创建一个 pod:

root@kmaster:~# cat my_pod.yaml 
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: webapp-color
  name: webapp-color
spec:
  containers:
  - image: 10.74.46.13:5000/webapp-color:v1
    name: webapp-color
  schedulerName: my-scheduler
root@kmaster:~# 

但我的 pod 处于待处理状态:

root@kmaster:~# kubectl get pod
NAME           READY   STATUS    RESTARTS   AGE
webapp-color   0/1     Pending   0          4h12m
root@kmaster:~# 

描述 pod:

root@kmaster:~# kubectl describe pod webapp-color
Name:         webapp-color
Namespace:    default
Priority:     0
Node:         <none>
Labels:       run=webapp-color
Annotations:  <none>
Status:       Pending
IP:           
IPs:          <none>
Containers:
  webapp-color:
    Image:        10.74.46.13:5000/webapp-color:v1
    Port:         <none>
    Host Port:    <none>
    Environment:  <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mkh4z (ro)
Volumes:
  kube-api-access-mkh4z:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>
root@kmaster:~# 

Kubernetes 版本:

root@kmaster:~# kubectl version --short
Client Version: v1.22.0
Server Version: v1.22.0
root@kmaster:~# 

请帮助我找出 pod 处于待处理状态的原因。 没有得到任何线索。

待定意味着自定义调度程序不工作。但没有得到任何理由。

问候

【问题讨论】:

  • 您的调度程序有任何日志吗?

标签: kubernetes kubernetes-pod


【解决方案1】:

调度器的工作是决定一个 pod 将在哪个节点上运行。在调度程序决定之前,pod 将处于挂起状态。您的调度程序似乎无法正常工作。

尝试通过以下方式查看日志:kubectl logs kube-scheduler-kmaster -n kube-system

查看调度程序是否正在做出任何决定。

【讨论】:

    猜你喜欢
    • 2019-04-28
    • 1970-01-01
    • 2014-06-21
    • 2018-03-31
    • 2019-03-30
    • 2021-10-12
    • 2014-09-20
    • 1970-01-01
    • 2018-11-19
    相关资源
    最近更新 更多