-
-
Notifications
You must be signed in to change notification settings - Fork 117
Standardize Resource Labels #351
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
32155ac
Use standard k8s+helm labels
cognifloyd 20bc328
add app.kubernetes.io/version label
cognifloyd 12d7981
update configmap and secret label tests
cognifloyd cdfc90b
add migrations/standardize-labels.sh
cognifloyd f968b25
add changelog entry
cognifloyd 7b77c87
update labels in documentation
cognifloyd 83cc034
update labels in st2sensors test
cognifloyd 5ce7059
include st2tests pod in migrations script just in case
cognifloyd b30b93f
make migration script executable
cognifloyd 3afaf8d
capture remaining resources in migration script
cognifloyd cc5a432
use labels helper in overrides-configs
cognifloyd c2229cd
fix missing arg on kubectl command in migrations script
cognifloyd 49829a1
improve migration script output
cognifloyd 658afdf
Simplify migration script: the ServiceAccount token does not have lab…
cognifloyd 9aa3fb8
Merge branch 'master' into std-labels
cognifloyd 03aea4e
put migration script in version specific dir
cognifloyd 6cb1e52
Merge branch 'master' into std-labels
cognifloyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/bin/bash | ||
cognifloyd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # We switched to the standard labels recommend in Helm's "Best Practices" doc. | ||
| # https://helm.sh/docs/chart_best_practices/labels/#standard-labels | ||
| # | ||
| # This script adds those labels to all the resources in an existing release, | ||
| # so that helm upgrade will not create duplicate resources. The new label | ||
| # selectors do not match the old labels, so this script adds the new labels | ||
| # to the old resources. Thus, the new selectors will update them. | ||
|
|
||
| # These env vars need to be set to use this script: | ||
| # RELEASE_NAME (same as .Release.Name) | ||
| # NAMESPACE (same as .Release.Namespace) | ||
| # | ||
| # For example: | ||
| # RELEASE_NAME=st2 NAMESPACE=st2 migrations/standardize-labels.sh | ||
|
|
||
| RELEASE_NAME=${RELEASE_NAME:-st2} | ||
| NAMESPACE=${NAMESPACE:-default} | ||
| CHART_NAME=${CHART_NAME:-stackstorm-ha} # see Chart.yaml | ||
|
|
||
|
|
||
| function klabel_app_instance() { | ||
| kind=${1} | ||
| kubectl label "${kind}" \ | ||
| -n "${NAMESPACE}" \ | ||
| -l "vendor=stackstorm" \ | ||
| -l "release=${RELEASE_NAME}" \ | ||
| "app.kubernetes.io/instance=${RELEASE_NAME}" | ||
| } | ||
|
|
||
| function klabel_app_name() { | ||
| kind=${1} | ||
| app=${2} | ||
| kubectl label "${kind}" \ | ||
| -n "${NAMESPACE}" \ | ||
| -l "vendor=stackstorm" \ | ||
| -l "release=${RELEASE_NAME}" \ | ||
| -l "app=${app}" \ | ||
| "app.kubernetes.io/name=${app}" | ||
| } | ||
|
|
||
| for kind in ConfigMap Secret Ingress Service ServiceAccount Deployment ReplicaSet Pod Job; do | ||
| klabel_app_instance ${kind} | ||
| done | ||
|
|
||
| klabel_app_name ConfigMap st2 | ||
| klabel_app_name Secret st2 | ||
| klabel_app_name Secret st2chatops | ||
|
|
||
| klabel_app_name Secret ${CHART_NAME} # for ServiceAccount | ||
| klabel_app_name ServiceAccount ${CHART_NAME} | ||
|
|
||
| klabel_app_name Ingress ingress | ||
|
|
||
| for app in st2actionrunner st2api st2auth st2chatops st2client st2garbagecollector st2notifier st2rulesengine st2scheduler st2stream st2timersengine st2web st2workflowengine; do | ||
| klabel_app_name Deployment ${app} | ||
| klabel_app_name ReplicaSet ${app} | ||
| klabel_app_name Pod ${app} | ||
| done | ||
|
|
||
| for app in st2api st2auth st2chatops st2stream st2web; do | ||
| klabel_app_name Service ${app} | ||
| done | ||
|
|
||
| for app in st2 st2-apply-rbac-definitions st2-register-content; do | ||
| klabel_app_name Job ${app} | ||
| klabel_app_name Pod ${app} | ||
| done | ||
|
|
||
| klabel_app_name ConfigMap st2tests | ||
| klabel_app_name Pod st2tests | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.