-
Notifications
You must be signed in to change notification settings - Fork 420
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 sanity check for cloudIntegrationSecret #3048
Add sanity check for cloudIntegrationSecret #3048
Conversation
Signed-off-by: chipzoller <chipzoller@gmail.com>
Signed-off-by: chipzoller <chipzoller@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for the UX improvement here!
In order to get CI working, should we remove the cloud integration secret from the following files? https://github.com/kubecost/cost-analyzer-helm-chart/tree/develop/cost-analyzer/ci |
The problem here is that the templatization will always fail if a cluster connection cannot be made ( Open to suggestions here but by attempting to improve UX comes with a cost for those users who define this value. |
Signed-off-by: chipzoller <chipzoller@gmail.com>
Signed-off-by: chipzoller <chipzoller@gmail.com>
I think might have found a neat trick/workaround. By using the |
Updated initial post with new results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, thanks Chip
I'm going to go ahead and merge this since it seems there have been enough eyes on it. Thanks to everyone. |
/cherry-pick v2.0 |
* add sanity check for cloud integration secret and key Signed-off-by: chipzoller <chipzoller@gmail.com> * use printf Signed-off-by: chipzoller <chipzoller@gmail.com> * fix name of cloud-integration to be hardcoded Signed-off-by: chipzoller <chipzoller@gmail.com> * try Capabilities Signed-off-by: chipzoller <chipzoller@gmail.com> --------- Signed-off-by: chipzoller <chipzoller@gmail.com>
* add sanity check for cloud integration secret and key * use printf * fix name of cloud-integration to be hardcoded * try Capabilities --------- Signed-off-by: chipzoller <chipzoller@gmail.com> Co-authored-by: Chip Zoller <chipzoller@gmail.com>
Signed-off-by: chipzoller chipzoller@gmail.com
What does this PR change?
Adds a sanity check that the cloudIntegrationSecret, when defined, both exists and has a key with the name
cloud-integration.json
or else fails the chart installation. This is done to prevent users from naming Secrets which don't yet exist and ensure that those Secrets have a key the chart expects. Without both, Kubecost will not be able to come into a healthy, running state.This also fixes a bug with the name of the volume holding said cloudIntegration secret enabling secrets with a custom name to be properly mounted.
Does this PR rely on any other PRs?
No
How does this PR impact users? (This is the kind of thing that goes in release notes!)
Provides a better user experience in that the chart fails and provides feedback to users rather than succeeding in installation only to fail when running.
Links to Issues or tickets this PR addresses or fixes
Fixes #3046
What risks are associated with merging this PR? What is required to fully test this PR?
The check could be wrong or it could somehow impact installations where the cloudIntegrationSecret was not specified. It could potentially impact users who use tools or generate manifests from
helm template
although this behavior was tested locally and in CI.How was this PR tested?
Various Helm templating and installation scenarios. This check should only be invoked when a "real" connection to a K8s cluster exists and not when using
helm template
with or without--dry-run=server
.Attempting to install when the Secret does not exist
$ k -n default get secret No resources found in default namespace.
Attempting to install when the Secret exists but the cloud-integration.json key does not
$ k -n default get secret mycustomsecret -o yaml | yq .data foo: YmFy
Attempting to install when the Secret exists and does contain the key cloud-integration.json
$ k -n default get secret mycustomsecret -o yaml | yq .data cloud-integration.json: YmFy
Have you made an update to documentation? If so, please provide the corresponding PR.
N/A