How is the order of executing pods decided in k8s?

8/20/2018

I would like to know how the order of consecutive 'pending' pods changing to 'running' is decided in k8s.

When I tried creating 25 pods with the same condition sequentially, the order that these pods became 'running' status was different from the one. I mean that, I created pods named pod-01~05, pod-11~15 and pod-21~25, two pods immediately moved to 'running' status and rest pods were going 'pending' status. The order of issuing creation command was

01 -> 02 -> 03 -> 04 -> 05 -> 21 -> 22 -> 23 -> 24 -> 25 -> 11 -> 12 -> 13 -> 14 -> 15

while the order of actually running was

(01 & 02) -> 21 -> 23 -> 13 -> 15 -> 12 -> 03 -> 11 -> 24 -> 04 -> 05 -> 22 -> 14 -> 25

The following is what I did.

1. Pods creation

    $ kubectl create -f req-1CPU-01.yaml
    job.batch "pod-01" created
    $ kubectl create -f req-1CPU-02.yaml
    job.batch "pod-02" created
    $ kubectl create -f req-1CPU-03.yaml
    job.batch "pod-03" created
    $ kubectl create -f req-1CPU-04.yaml
    job.batch "pod-04" created
    $ kubectl create -f req-1CPU-05.yaml
    job.batch "pod-05" created
    $ kubectl create -f req-1CPU-21.yaml
    job.batch "pod-21" created
    $ kubectl create -f req-1CPU-22.yaml
    job.batch "pod-22" created
    $ kubectl create -f req-1CPU-23.yaml
    job.batch "pod-23" created
    $ kubectl create -f req-1CPU-24.yaml
    job.batch "pod-24" created
    $ kubectl create -f req-1CPU-25.yaml
    job.batch "pod-25" created
    $ kubectl create -f req-1CPU-11.yaml
    job.batch "pod-11" created
    $ kubectl create -f req-1CPU-12.yaml
    job.batch "pod-12" created
    $ kubectl create -f req-1CPU-13.yaml
    job.batch "pod-13" created
    $ kubectl create -f req-1CPU-14.yaml
    job.batch "pod-14" created
    $ kubectl create -f req-1CPU-15.yaml
    job.batch "pod-15" created

2. Checking Pods status

    $ kubectl get pods
    NAME           READY     STATUS    RESTARTS   AGE
    pod-01-wc4p6   1/1       Running   0          37s
    pod-02-849dj   1/1       Running   0          34s
    pod-03-lzlsz   0/1       Pending   0          32s
    pod-04-zxbhw   0/1       Pending   0          30s
    pod-05-dk7nw   0/1       Pending   0          28s
    pod-11-p47rz   0/1       Pending   0          13s
    pod-12-q2zsn   0/1       Pending   0          11s
    pod-13-pptjc   0/1       Pending   0          9s
    pod-14-qsldr   0/1       Pending   0          7s
    pod-15-llg6l   0/1       Pending   0          5s
    pod-21-dvz2n   0/1       Pending   0          24s
    pod-22-4hwng   0/1       Pending   0          22s
    pod-23-68kns   0/1       Pending   0          20s
    pod-24-wpb8d   0/1       Pending   0          18s
    pod-25-7vpt6   0/1       Pending   0          16s

    $ kubectl get pods | grep Running
    pod-01-wc4p6   1/1       Running   0          53s
    pod-02-849dj   1/1       Running   0          50s

    $ kubectl get pods | grep Running
    pod-02-849dj   1/1       Running     0          2m
    pod-21-dvz2n   1/1       Running     0          2m

    $ kubectl get pods | grep Running
    pod-21-dvz2n   1/1       Running     0          3m
    pod-23-68kns   1/1       Running     0          3m

    $ kubectl get pods | grep Running
    pod-13-pptjc   1/1       Running     0          4m
    pod-23-68kns   1/1       Running     0          4m

    $ kubectl get pods | grep Running
    pod-13-pptjc   1/1       Running     0          5m
    pod-15-llg6l   1/1       Running     0          5m

    $ kubectl get pods | grep Running
    pod-12-q2zsn   1/1       Running     0          6m
    pod-15-llg6l   1/1       Running     0          6m

    $ kubectl get pods | grep Running
    pod-03-lzlsz   1/1       Running     0          8m
    pod-12-q2zsn   1/1       Running     0          8m

    $ kubectl get pods | grep Running
    pod-03-lzlsz   1/1       Running     0          9m
    pod-11-p47rz   1/1       Running     0          8m

    $ kubectl get pods | grep Running
    pod-11-p47rz   1/1       Running     0          10m
    pod-24-wpb8d   1/1       Running     0          10m

    $ kubectl get pods | grep Running
    pod-04-zxbhw   1/1       Running     0          11m
    pod-24-wpb8d   1/1       Running     0          11m

    $ kubectl get pods | grep Running
    pod-04-zxbhw   1/1       Running     0          13m
    pod-05-dk7nw   1/1       Running     0          13m

    $ kubectl get pods | grep Running
    pod-05-dk7nw   1/1       Running     0          13m
    pod-22-4hwng   1/1       Running     0          13m

    $ kubectl get pods | grep Running
    pod-14-qsldr   1/1       Running     0          15m
    pod-22-4hwng   1/1       Running     0          15m

    $ kubectl get pods | grep Running
    pod-14-qsldr   1/1       Running     0          16m
    pod-25-7vpt6   1/1       Running     0          16m

    $ kubectl get pods
    NAME           READY     STATUS      RESTARTS   AGE
    pod-01-wc4p6   0/1       Completed   0          19m
    pod-02-849dj   0/1       Completed   0          19m
    pod-03-lzlsz   0/1       Completed   0          19m
    pod-04-zxbhw   0/1       Completed   0          19m
    pod-05-dk7nw   0/1       Completed   0          18m
    pod-11-p47rz   0/1       Completed   0          18m
    pod-12-q2zsn   0/1       Completed   0          18m
    pod-13-pptjc   0/1       Completed   0          18m
    pod-14-qsldr   0/1       Completed   0          18m
    pod-15-llg6l   0/1       Completed   0          18m
    pod-21-dvz2n   0/1       Completed   0          18m
    pod-22-4hwng   0/1       Completed   0          18m
    pod-23-68kns   0/1       Completed   0          18m
    pod-24-wpb8d   0/1       Completed   0          18m
    pod-25-7vpt6   0/1       Completed   0          18m

And the following is the sample pod manifest req-1CPU-01.yaml

apiVersion: batch/v1 kind: Job metadata: name: pod-01 spec: template: metadata: annotations: networks: '[ { "name": "vlan10" } ]' spec: containers: - name: ubuntu image: juamorous/ubuntu-ifconfig-ping command: ["sleep", "120"] resources: requests: cpu: 1 restartPolicy: Never

-- kshiro
kubernetes

0 Answers