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

Add lifecycle configuration for main deployment #30

Merged
merged 1 commit into from
Feb 26, 2023

Conversation

tomaszkiewicz
Copy link
Collaborator

Hello,

Sometimes it doesn't make sense to build new docker image just to add some stuff to the main container.
In K8S we can use lifecycle parameter for container to inject some kind of actions.

This PR adds a configuration parameter "lifecycle" to the template to accomplish that.

Sample usage (values.yaml):

lifecycle:
  postStart:
    exec:
      command: ["/bin/sh", "-c", "apk add mysql-client"]

@Vad1mo
Copy link
Member

Vad1mo commented Feb 26, 2023

Thank you for your contribution, I like it. I wonder if it would make more sense to do it in pre, instead of post, as there might be dependencies that n8n would need to start.

@tomaszkiewicz
Copy link
Collaborator Author

Current K8S version has only postStart and preStop lifecycle hooks (https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/), so the only way to run it before n8n is to change entrypoint or command which I think can break some stuff when base container changes.

Lifecycle hook is not perfect, but relatively safe to make cases like package addition into the container.

@Vad1mo
Copy link
Member

Vad1mo commented Feb 26, 2023

Ok, didn't know that.

@Vad1mo
Copy link
Member

Vad1mo commented Feb 26, 2023

Since what K8s version is it supported? If it's older then 1.21 we might need to do a check for api version

@Vad1mo
Copy link
Member

Vad1mo commented Feb 26, 2023

Or a comment in the values yaml file

@tomaszkiewicz
Copy link
Collaborator Author

It's available as long as I remember, so a couple years at least :)

@Vad1mo Vad1mo merged commit c3338bb into 8gears:master Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants