Skip to content
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

Merged
merged 1 commit into from Jun 10, 2019

Conversation

nkvoll
Copy link
Member

@nkvoll nkvoll commented Jun 7, 2019

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:

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

TODO (to file issue upon merging)

  • Init containers are ignore for comparison purposes, so changes to the init container definitions only apply to new pods, and no rolling etc. changes are performed as a result.

…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
```
@nkvoll nkvoll force-pushed the facilitate-custom-init-containers branch from 83e3959 to 2c0af65 Compare June 7, 2019 20:27
Copy link
Contributor

@sebgl sebgl left a 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 {
Copy link
Contributor

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?

Copy link
Member Author

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.

@nkvoll nkvoll merged commit 1924952 into elastic:master Jun 10, 2019
@nkvoll nkvoll deleted the facilitate-custom-init-containers branch June 10, 2019 09:48
@pebrc pebrc added >enhancement Enhancement of existing functionality v0.9.0 labels Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality v0.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants