如何在k8s中确定执行Pod的顺序?

时间:2018-08-20 10:10:17

标签: kubernetes

我想知道在k8s中如何确定连续的“待定”吊舱更改为“运行”的顺序。

当我尝试按顺序创建25个具有相同条件的Pod时,这些Pod变为“运行”状态的顺序与此不同。 我的意思是,我创建了名为pod-01〜05,pod-11〜15和pod-21〜25的Pod,两个Pod立即移至“运行”状态,其余Pod变为“待定”状态。发出创建命令的顺序为

  

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

实际运行顺序为

  

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

以下是我的工作。

1。吊舱创建

    $ 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。检查Pod状态

    $ 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

以下是示例pod清单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

0 个答案:

没有答案