cdk8s-team / cdk8s-plus

A software development framework that provides high level abstractions for authoring Kubernetes applications.
https://cdk8s.io/docs/latest/plus/
Apache License 2.0
128 stars 33 forks source link

Sidecar containers cannot specify probes #4338

Open AmaranthineCodices opened 2 weeks ago

AmaranthineCodices commented 2 weeks ago

Description of the feature or enhancement:

Sidecar containers, unlike init containers, support probes. addInitContainer doesn't support this and will throw an error if liveness, readiness, or startup are specified: https://github.com/cdk8s-team/cdk8s-plus/blob/f7c11148f65084b35fb5d3273a31af387015bc8f/src/pod.ts#L124-L135

I'd like to be able to specify these probes for sidecar containers.

Use Case:

Since a sidecar container does not exit before the main container starts, probes are the only means available for delaying the startup of the main container beyond the simplest possible cases. Sidecar containers may require some time to be ready after starting, and in my case it's important that the sidecar container be ready, not just started, by the time the main container starts.

Proposed Solution:

It seems relatively straightforward to build on #3812 and disable the exceptions if restartPolicy is specified.

Other:


This is a :rocket: Feature Request

iliapolo commented 1 week ago

@AmaranthineCodices

Proposed Solution:

It seems relatively straightforward to build on https://github.com/cdk8s-team/cdk8s-plus/pull/3812 and disable the exceptions if restartPolicy is specified.

You mean if restartPolicy is set to Always right? Because that is what differentiates init containers from sidecars:

If an init container is created with its restartPolicy set to Always, it will start and remain running during the entire life of the Pod. This can be helpful for running supporting services separated from the main application containers.