Home > Software design >  Resource uses with init container in Kubernetes
Resource uses with init container in Kubernetes

Time:09-14

I have doubt regarding defined request and limit resources within init container. Does the resources declared here are released on completion of init container or these resources are kept reserved until the pod is running.

CodePudding user response:

Don't let the default request set, i'm not sur if it's 250m I always set a little amount of requested cpu with a high limit, it makes the container responding very slowly when it gets throtteled. I don't think they will stay reserved, you can try with kubectl describe pod or with

kubectl top pod --containers=true

CodePudding user response:

A Pod can have multiple containers running apps within it, but it can also have one or more init containers, which are run before the app containers are started. Init containers are exactly like regular containers, except: Init containers always run to completion. Each init container must complete successfully before the next one starts. If the Pod restarts, or is restarted, all init containers must execute again. Changes to the init container spec are limited to the container image field. Altering an init container image field is equivalent to restarting the Pod. Because init containers can be restarted, retried, or re-executed, init container code should be idempotent. In particular, code that writes to files on EmptyDirs should be prepared for the possibility that an output file already exists.

Use activeDeadlineSeconds on the Pod to prevent init containers from failing forever. The active deadline includes init containers. However it is recommended to use activeDeadlineSeconds only if teams deploy their application as a Job, because activeDeadlineSeconds has an effect even after initContainer finished. The Pod which is already running correctly would be killed by activeDeadlineSeconds if you set it.

  • Related