-
Notifications
You must be signed in to change notification settings - Fork 729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide default images and volume mounts to user-provided init containers #1022
Provide default images and volume mounts to user-provided init containers #1022
Conversation
…ners. This makes the user-provided init containers run after our built-ins, meaning the user-provided init containers gets the final say on what the environment is going to look like. It defaults the init container image to the ES container image for convenience. The Volume mounts for the ES container is appended to the init containers volume mounts, with the result being that a simple init container will run in the same context as Elasticsearch (with a notable exception of environment variables) This change facilitates use cases such as installing custom plugins: ```yaml apiVersion: elasticsearch.k8s.elastic.co/v1alpha1 kind: Elasticsearch metadata: name: elasticsearch-sample spec: version: "7.1.0" nodes: - podTemplate: spec: initContainers: - name: install-plugins command: - sh - -c - | bin/elasticsearch-plugin install --batch repository-azure nodeCount: 1 ```
83e3959
to
2c0af65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I think we can enforce it automatically for ES + Kibana+ APM?
// - If the init container contains an empty image field, it's inherited from the main container. | ||
// - VolumeMounts from the main container are added to the init container VolumeMounts, unless they would conflict | ||
// with a specified VolumeMount (by having the same VolumeMount.Name or VolumeMount.MountPath) | ||
func (b *PodTemplateBuilder) WithInitContainerDefaults() *PodTemplateBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be safe to execute this as part of PodTemplateBuilder.setDefaults()
, to enforce it for ES, Kibana & APM without the need to call it explicitly. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this needs to happen /after/ the Volumes and VolumeMounts have been included.
This makes the user-provided init containers run after our built-ins,
meaning the user-provided init containers gets the final say on what
the environment is going to look like.
It defaults the init container image to the ES container image for convenience.
The Volume mounts for the ES container is appended to the init containers
volume mounts, with the result being that a simple init container will
run in the same context as Elasticsearch (with a notable exception of
environment variables)
This change facilitates use cases such as installing custom plugins:
TODO (to file issue upon merging)