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

Enable extra post-install and post-upgrade helm-hook jobs for environment-specific config #265

Merged
merged 7 commits into from
Mar 24, 2022

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Nov 11, 2021

Resolves #234

There is a lot of boilerplate for custom StackStorm hook-jobs. That boilerplate is likely to become out-of-date as we refine the chart, so managing that boilerplate within this chart alongside our other jobs would be ideal.

Since there is so much chart-specific boilerplate, parent charts would have to depend on a lot of implementation details making them very brittle. Parent charts are much better suited to jobs that don't need access to most of the packs, configs, configmaps, and secrets that this chart provides.

These hook-jobs can be used for st2 installation-specific jobs like:

  • running a pre-upgrade st2 workflow that notifies on various channels that the upgrade is happening,
  • running post-upgrade smoke tests to ensure st2 can connect to vital services (vault, kubernetes, aws, etc),
  • running a pre-upgrade st2 workflow that pauses long-running workflows,
  • running a post-upgrade st2 workflow that resumes long-running workflows,
  • running one-time post-install configuration (such as generating dynamic secrets in the st2kv datastore),
  • etc.

@cognifloyd cognifloyd self-assigned this Nov 11, 2021
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines. Requires some effort to review. label Nov 11, 2021
Copy link
Contributor

@ericreeves ericreeves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great PR that can resolve a lot of automation use cases.

Very clear implementation.

Thanks!

@cognifloyd
Copy link
Member Author

Rebased on master

@cognifloyd
Copy link
Member Author

cognifloyd commented Mar 2, 2022

Well that was nice. Adding unit tests caught a few issues with this PR. I think we need unit tests for env and volumes before merging this. Once I've prepared those, I'll push a PR. edit: those tests are merged, I just rebased this PR on top, and added the extra_hooks jobs to those tests. That uncovered an issue with jobs.env which is now fixed

@cognifloyd
Copy link
Member Author

rebased and squashed into a logical set of commits.

Like other jobs, the extra_hooks jobs include:
annotations, securityContext, pullSecrets, st2client config,
envFromSecrets, resources, dnsPolicy/dnsConfig, nodeSelector, affinity,
tolerations, init containers, and packs volumes.

add securityContext to extra_hooks jobs
use range over command
@cognifloyd
Copy link
Member Author

Rebased and added extra_hooks jobs to existing tests to ensure this is working correctly. That uncovered a few issues that are now resolved.

Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

I think it is worth a release after merging this PR and looking at how many features already accumulated.

Comment on lines +899 to +902
# Advanced: Add extra Helm hook Jobs
# These hook jobs will use the same settings (eg image, annotations, pod placement) as the other jobs.
# They will have st2 cli configured, st2.conf files, and packs volumes mounted.
# See available hooks list: https://helm.sh/docs/topics/charts_hooks/#the-available-hooks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is powerful, but I think the use case examples would be nice to include somewhere. Otherwise, very few would know about it and use it.
Perhaps a Readme section describing this feature with some examples?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I will add a README section.

@arm4b
Copy link
Member

arm4b commented Mar 21, 2022

Also good to know that new tests already caught some issues 👍

@cognifloyd
Copy link
Member Author

K. README updated in e4b72dc

@cognifloyd
Copy link
Member Author

I'll merge now. We can revise the README in a follow-up if needed.

@cognifloyd cognifloyd merged commit 5060b0f into StackStorm:master Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Helm size/L PR that changes 100-499 lines. Requires some effort to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Allow users to define custom helm hook jobs to run on install/upgrade/etc
3 participants