<p>I am writing a pipeline with kubernetes in google cloud.</p>

<p>I need to activate sometimes a few pods in a second, where each pod is a task that runs inside a pod.</p>

<p>I plan to call kubectl run with Kubernetes job and wait for it to complete (poll every second all the pods running) and activate the next step in the pipeline.</p>

<p>I will also monitor the cluster size to make sure I am not exceeding the max CPU/RAM usage.</p>

<p>I can run tens of thousands of jobs at the same time.</p>

<p>I am not using standard pipelines because I need to create a dynamic number of tasks in the pipeline.</p>

<p>I am running the batch operation so I can handle the delay.</p>

<p>Is it the best approach? How long does it take to create a pod in Kubernetes?</p>

asaf
<p>If you wanna run ten thousands of jobs at the same time - you will definitely need to plan resource allocation. You need to estimate the number of nodes that you need. After that you may create all nodes at once, or use GKE cluster autoscaler for automatically adding new nodes in response to resource demand. If you preallocate all nodes at once - you will probably have high bill at the end of month. But pods can be created very quickly. If you create only small number of nodes initially and use cluster autoscaler - you will face large delays, because nodes take several minutes to start. You must decide what your approach will be.</p>

<p>If you use cluster autoscaler - do not forget to specify maximum nodes number in cluster.</p>

<p>Another important thing - you should put your jobs into Guaranteed <a href="https://kubernetes.io/docs/tasks/configure-pod-container/quality-service-pod/" rel="nofollow noreferrer">quality of service</a> in Kubernetes. Otherwise if you use Best Effort or Burstable pods - you will end up with Eviction nightmare which is really terrible and uncontrolled.</p>
