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

[prometheus-operator] feat: add scripts to make upgrading easier #742

Merged
merged 10 commits into from
Aug 18, 2020

Conversation

samvantran
Copy link
Contributor

@samvantran samvantran commented Aug 17, 2020

What type of PR is this?
Feature

What this PR does/ why we need it:
Upgrading prometheus has been problematic because we have a bunch of patches we apply on top of the upstream chart. Each time has been manual and sometimes we've missed something during an upgrade.

This PR adds all the mesosphere-specific files & changes (templates, hooks, etc) to the /patches folder. There are also scripts that apply those patches as a set. This should make it easy to follow which files are added/amended after copying the upstream chart. This is somewhat akin to how DB migrations work in Rails (this was years ago though, things may have changed).

Now we can run ./upgrade_operator.sh and it should take care of all the rest.

Here are the files that are mesophere-specific:

 > tree patch/mesosphere
patch/mesosphere
└── templates
    ├── grafana
    │   ├── cronjob-home-dashboard.yaml
    │   └── dashboards
    │       ├── autoscalerdashboard.yaml
    │       ├── calicodashboard.yaml
    │       ├── elasticsearchdashboard.yaml
    │       ├── fluentbitdashboard.yaml
    │       ├── grafanadashboard.yaml
    │       ├── kibanadashboard.yaml
    │       ├── localvolumeprovisioner.yaml
    │       ├── opsportaldashboard.yaml
    │       ├── traefikdashboard.yaml
    │       └── velerodashboard.yaml
    ├── hooks
    │   └── prometheus-cluster-id-hooks.yaml
    ├── ingress-rbac
    │   ├── alertmanager.yaml
    │   ├── grafana.yaml
    │   └── prometheus.yaml
    └── rules
        ├── etcd-rules.yaml
        └── velero-rules.yaml

6 directories, 17 files

Which issue(s) this PR fixes:
https://jira.d2iq.com/browse/D2IQ-67095

Special notes for your reviewer:
I mostly did this from the diff of copying the latest chart and trying to follow PR #619. It's possible I missed some files so definitely would appreciate anyone who's done a prometheus upgrade to make doubly sure I got everything.

Does this PR introduce a user-facing change?:

NONE

Checklist

  • The commit message explains the changes and why are needed.
  • The documentation is updated where needed.

This moves all the mesosphere-related templates to the patch folder.
This makes it easier to update the operator with a copy and replace as
none of the mesosphere files will get lost.

Signed-off-by: Sam Tran <[email protected]>
This adds patch files that copy all the mesosphere files into the
templates/ folder. This way they get deployed as part of the chart.

It makes it easier to keep all the patches in one place and know what
changes are needed/differ from upstream.

Signed-off-by: Sam Tran <[email protected]>
This adds a helper file so that all the patch files can use the
git_add_and_commit function which adds and commits all the files that
were changed as part of the patch script. This should make it easy to
see the commit history of what changed.

Signed-off-by: Sam Tran <[email protected]>
This commit updates the patch script to use a docker image as the
previous code did not run on OSX.

Also, due to the underlying go-parser lib used in the yq docker image,
updating a yaml file automatically reformats the yaml removing empty
newlines and converting multiline strings into one line[1]. This makes
it hard to see the actual needed change for patch7 which is just to
update the crd volumeClaimTemplate.metadata stanza.

Thus, patch7 is changed to apply two commits, one to simply let yq
format the file with no new changes and a second commit with the needed
change. Similar to what we do with chart revision changes.

Also updated the helper script to accept a commit message.

[1] mikefarah/yq#465 (comment)

Signed-off-by: Sam Tran <[email protected]>
This script does a sparse clone of helm/stable/prometheus-operator and
replaces all the files in our fork with latest upstream.

Then it applies all the patches in the /patch folder which should now
make updating our prometheus chart a bit easier.

Signed-off-by: Sam Tran <[email protected]>
Copy link
Contributor

@joejulian joejulian left a comment

Choose a reason for hiding this comment

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

👍 I wish we did this with all our forks.

@alejandroEsc
Copy link
Contributor

wow nice. Could we get a quick readme about how these scripts are run?

Copy link
Contributor

@gracedo gracedo left a comment

Choose a reason for hiding this comment

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

Amazing 🙌 the only other thing i can think of is this change here that we often forget to apply: https://github.com/mesosphere/charts/pull/486/files cc @alejandroEsc

@samvantran
Copy link
Contributor Author

samvantran commented Aug 17, 2020

wow nice. Could we get a quick readme about how these scripts are run?

@alejandroEsc oh yeah for sure. I'll add in comments to the scripts as well so it's easier to understand

Amazing 🙌 the only other thing i can think of is this change here that we often forget to apply:

@gracedo i knew there was something missing! I thought it was this fix but yes, there's more. Okay I'll add a patch for that. Thanks for catching 🙏

Add an UPGRADING doc so users know what to do to upgrade.
Add comments to the patch scripts so users know what each one does.
crd patch script needed explaining.

Signed-off-by: Sam Tran <[email protected]>
This adds back the check for `monitoring.coreos.com/v1` that was removed
from upstream.

Signed-off-by: Sam Tran <[email protected]>
@samvantran samvantran force-pushed the svt/prom-operator-upgrade branch from e695427 to 57af579 Compare August 18, 2020 00:26
@samvantran samvantran requested a review from gracedo August 18, 2020 00:36
@samvantran samvantran merged commit dcdf015 into master Aug 18, 2020
@samvantran samvantran deleted the svt/prom-operator-upgrade branch August 18, 2020 23:04
d2iq-dispatch added a commit that referenced this pull request Aug 18, 2020
… * chore: move all mesosphere files to patch This moves all the mesosphere-related templates to the patch folder. This makes it easier to update the operator with a copy and replace as none of the mesosphere files will get lost. Signed-off-by: Sam Tran <[email protected]> * feat: add patch files This adds patch files that copy all the mesosphere files into the templates/ folder. This way they get deployed as part of the chart. It makes it easier to keep all the patches in one place and know what changes are needed/differ from upstream. Signed-off-by: Sam Tran <[email protected]> * feat: add helpers script for git commands This adds a helper file so that all the patch files can use the git_add_and_commit function which adds and commits all the files that were changed as part of the patch script. This should make it easy to see the commit history of what changed. Signed-off-by: Sam Tran <[email protected]> * chore: update prometheus crd patch script This commit updates the patch script to use a docker image as the previous code did not run on OSX. Also, due to the underlying go-parser lib used in the yq docker image, updating a yaml file automatically reformats the yaml removing empty newlines and converting multiline strings into one line[1]. This makes it hard to see the actual needed change for patch7 which is just to update the crd volumeClaimTemplate.metadata stanza. Thus, patch7 is changed to apply two commits, one to simply let yq format the file with no new changes and a second commit with the needed change. Similar to what we do with chart revision changes. Also updated the helper script to accept a commit message. [1] mikefarah/yq#465 (comment)  Signed-off-by: Sam Tran <[email protected]>  * feat: add update_operator script  This script does a sparse clone of helm/stable/prometheus-operator and replaces all the files in our fork with latest upstream.  Then it applies all the patches in the /patch folder which should now make updating our prometheus chart a bit easier.  Signed-off-by: Sam Tran <[email protected]>  * chore: add newlines from PR review  Signed-off-by: Sam Tran <[email protected]>  * chore: add doc for upgrading + patch comments  Add an UPGRADING doc so users know what to do to upgrade. Add comments to the patch scripts so users know what each one does. crd patch script needed explaining.  Signed-off-by: Sam Tran <[email protected]>  * chore: add patch for checking CRD exists again  This adds back the check for  that was removed from upstream.  Signed-off-by: Sam Tran <[email protected]>  * chore: fixup shellcheck errors  Co-authored-by: Joe Julian <[email protected]>
gracedo added a commit that referenced this pull request Aug 19, 2020
…ier (#742)  * chore: move all mesosphere files to patch  This moves all the mesosphere-related templates to the patch folder. This makes it easier to update the operator with a copy and replace as none of the mesosphere files will get lost.  Signed-off-by: Sam Tran <[email protected]>  * feat: add patch files  This adds patch files that copy all the mesosphere files into the templates/ folder. This way they get deployed as part of the chart.  It makes it easier to keep all the patches in one place and know what changes are needed/differ from upstream.  Signed-off-by: Sam Tran <[email protected]>  * feat: add helpers script for git commands  This adds a helper file so that all the patch files can use the git_add_and_commit function which adds and commits all the files that were changed as part of the patch script. This should make it easy to see the commit history of what changed.  Signed-off-by: Sam Tran <[email protected]>  * chore: update prometheus crd patch script  This commit updates the patch script to use a docker image as the previous code did not run on OSX.  Also, due to the underlying go-parser lib used in the yq docker image, updating a yaml file automatically reformats the yaml removing empty newlines and converting multiline strings into one line[1]. This makes it hard to see the actual needed change for patch7 which is just to update the crd volumeClaimTemplate.metadata stanza.  Thus, patch7 is changed to apply two commits, one to simply let yq format the file with no new changes and a second commit with the needed change. Similar to what we do with chart revision changes.  Also updated the helper script to accept a commit message.  [1] mikefarah/yq#465 (comment)  Signed-off-by: Sam Tran <[email protected]>  * feat: add update_operator script  This script does a sparse clone of helm/stable/prometheus-operator and replaces all the files in our fork with latest upstream.  Then it applies all the patches in the /patch folder which should now make updating our prometheus chart a bit easier.  Signed-off-by: Sam Tran <[email protected]>  * chore: add newlines from PR review  Signed-off-by: Sam Tran <[email protected]>  * chore: add doc for upgrading + patch comments  Add an UPGRADING doc so users know what to do to upgrade. Add comments to the patch scripts so users know what each one does. crd patch script needed explaining.  Signed-off-by: Sam Tran <[email protected]>  * chore: add patch for checking CRD exists again  This adds back the check for  that was removed from upstream.  Signed-off-by: Sam Tran <[email protected]>  * chore: fixup shellcheck errors  Co-authored-by: Joe Julian <[email protected]>"

This reverts commit 54b4815.
gracedo added a commit that referenced this pull request Aug 19, 2020
* Revert "[prometheus-operator] chore: upgrade to v9.3.1 (#743)  * chore: copy upstream chart version: 9.3.1  * chore: apply patch_1_mesosphere_dashboards.sh  * chore: apply patch_2_mesosphere_cron_jobs.sh  * chore: apply patch_3_mesosphere_hooks.sh  * chore: apply patch_4_ingress_rbac.sh  * chore: apply patch_5_mesosphere_rules.sh  * chore: apply patch_6_mesosphere_values.sh  * chore: apply patch_7_prometheus_crd.sh - reformat yaml with yq (no new changes)  * chore: apply patch_7_prometheus_crd.sh - update volumeClaimTemplate  * chore: apply patch_8_prometheus_operator_crd.sh"

This reverts commit b88c046.

* Revert "[prometheus-operator] feat: add scripts to make upgrading easier (#742)  * chore: move all mesosphere files to patch  This moves all the mesosphere-related templates to the patch folder. This makes it easier to update the operator with a copy and replace as none of the mesosphere files will get lost.  Signed-off-by: Sam Tran <[email protected]>  * feat: add patch files  This adds patch files that copy all the mesosphere files into the templates/ folder. This way they get deployed as part of the chart.  It makes it easier to keep all the patches in one place and know what changes are needed/differ from upstream.  Signed-off-by: Sam Tran <[email protected]>  * feat: add helpers script for git commands  This adds a helper file so that all the patch files can use the git_add_and_commit function which adds and commits all the files that were changed as part of the patch script. This should make it easy to see the commit history of what changed.  Signed-off-by: Sam Tran <[email protected]>  * chore: update prometheus crd patch script  This commit updates the patch script to use a docker image as the previous code did not run on OSX.  Also, due to the underlying go-parser lib used in the yq docker image, updating a yaml file automatically reformats the yaml removing empty newlines and converting multiline strings into one line[1]. This makes it hard to see the actual needed change for patch7 which is just to update the crd volumeClaimTemplate.metadata stanza.  Thus, patch7 is changed to apply two commits, one to simply let yq format the file with no new changes and a second commit with the needed change. Similar to what we do with chart revision changes.  Also updated the helper script to accept a commit message.  [1] mikefarah/yq#465 (comment)  Signed-off-by: Sam Tran <[email protected]>  * feat: add update_operator script  This script does a sparse clone of helm/stable/prometheus-operator and replaces all the files in our fork with latest upstream.  Then it applies all the patches in the /patch folder which should now make updating our prometheus chart a bit easier.  Signed-off-by: Sam Tran <[email protected]>  * chore: add newlines from PR review  Signed-off-by: Sam Tran <[email protected]>  * chore: add doc for upgrading + patch comments  Add an UPGRADING doc so users know what to do to upgrade. Add comments to the patch scripts so users know what each one does. crd patch script needed explaining.  Signed-off-by: Sam Tran <[email protected]>  * chore: add patch for checking CRD exists again  This adds back the check for  that was removed from upstream.  Signed-off-by: Sam Tran <[email protected]>  * chore: fixup shellcheck errors  Co-authored-by: Joe Julian <[email protected]>"

This reverts commit 54b4815.
gracedo added a commit to gracedo/charts that referenced this pull request Aug 19, 2020
gracedo added a commit that referenced this pull request Aug 19, 2020
* Revert "[prometheus-operator] chore: upgrade to v9.3.1 (#743)"

This reverts commit 9a2b458.

* Revert "[prometheus-operator] feat: add scripts to make upgrading easier (#742)"

This reverts commit dcdf015.

* chore: Bump chart version
alejandroEsc pushed a commit that referenced this pull request Aug 19, 2020
* Revert [prometheus-operator] chore: upgrade to v9.3.1 (#743)

This reverts commit b88c046.

* Revert [prometheus-operator] feat: add scripts to make upgrading easier (#742)

This reverts commit 54b4815.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants