Kubernetes start pods in batches for a node

10/20/2021

For some application,start or restart need more resources than running。for exapmle:es/flink。if a node have network jitter,all pods would restart at the same time in this node。When this happens,cpu usage becomes very high in this node。it would increase resource competition in this node。

now i want to start pods in batches for only one node。how to realize the function now?

-- jing
kubernetes
startup

1 Answer

10/20/2021

Kubernetes have auto-healing

You can let the POD crash and Kubernetes will auto re-start them soon as get the sufficient memory or resource requirement

Or else if you want to put the wait somehow so that deployment wait and gradually start one by one

you can use the sidecar and use the POD lifecycle hooks to start the main container, this process is not best but can resolve your issue.

Basic example :

apiVersion: v1
kind: Pod
metadata:
  name: sidecar-starts-first
spec:
  containers:
  - name: sidecar
    image: my-sidecar
    lifecycle:
      postStart:
        exec:
          command:
          - /bin/wait-until-ready.sh
  - name: application
    image: my-application

enter image description here

OR

You can also use the Init container to check the other container's health and start the main container POD once one POD is of another service.

Init container

i would also recommend to check the Priority class : https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/

-- Harsh Manvar
Source: StackOverflow