-
Notifications
You must be signed in to change notification settings - Fork 917
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
charts/karmada: automatically clean up the static-resource Job after it completes #5442
Conversation
…it completes Signed-off-by: Xinzhao Xu <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5442 +/- ##
=======================================
Coverage 31.14% 31.15%
=======================================
Files 640 640
Lines 44414 44414
=======================================
+ Hits 13833 13835 +2
+ Misses 29581 29579 -2
Partials 1000 1000
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thank you very much for your effort, this is exactly what I want to do, as I mentioned in #5305 (comment) What surprised me was that you considered the |
/lgtm |
## Set a TTL for the static-resource Job, the Job will be automatically cleaned up after this time. | ||
## This only works on Kubernetes version 1.23 or higher. | ||
ttlSecondsAfterFinished: 10 |
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.
What's the impact if we don't clean the job?
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.
The finished Pod holds extra resources, e.g., IP. Since this Job is useless, we need to release those resources.
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.
Do you mean the Pod IP, right? Yeah, I agree that we should try to clean up temporary resources after the installation.
I'm asking because I want to evaluate the benefit we can get from this. Thanks for the clarification.
@@ -11,6 +11,9 @@ metadata: | |||
spec: | |||
parallelism: 1 | |||
completions: 1 | |||
{{- if semverCompare ">=1.23.0-0" .Capabilities.KubeVersion.GitVersion }} |
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.
Where does the .Capabilities.KubeVersion.GitVersion
come from?
Is this version always comparable? I mean I can't assume all Kubernetes version format is x.x.y-0xxx
.
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.
Where does the
.Capabilities.KubeVersion.GitVersion
come from?
It's helm's built-in objects.
Is this version always comparable? I mean I can't assume all Kubernetes version format is
x.x.y-0xxx
.
Yes, don't worry about the Kubernetes version format, it is semantic versioning. So the -0
suffix here is used to find pre-release versions, e.g., 1.24-beta.1 will still be considered greater than 1.23, see https://masterminds.github.io/sprig/semver.html for more information.
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.
/approve
Thanks.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RainbowMango The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -1,3 +1,4 @@ | |||
{{- if semverCompare "<1.23.0-0" .Capabilities.KubeVersion.GitVersion }} |
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.
any particular reason why this was added here?
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.
❯ kubectl version
Credentials expired, trying refresh token .. success
Client Version: v1.29.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.6
This Job is no longer rendering for me
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.
We don't need this Job for K8s version higher than 1.23, the static-resource Job will be cleaned automatically by ttlSecondsAfterFinished
. Please read the description of this PR.
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 Job is no longer rendering for me
Do you mean it can't be installed on your side?
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.
It is no longer rendered (via helm template).
The explanation makes sense. I didn't realize post-install was split into static-resources and post-install, essentially making the latter useless if using ttlSecondsAfterFinished.
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.
Is there anything we need to do regarding this?
By the way, I pined you on the slack @a7i about the chart ownership thing :)
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.
Amazing ❤️
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
After #5305, we can now delete the static-resource job directly after its completion.
The new
ttlSecondsAfterFinished
feature can handle this task elegantly. However, this feature only reached GA in version 1.23. Before this version, the feature requires manually enabling the feature gate, and we cannot assume that users' clusters have this feature gate enabled. Therefore, unlike the #5305 (comment), considering that Karmada needs to run on various versions of Kubernetes, we cannot directly remove the post-install Job. The current strategy is:ttlSecondsAfterFinished
for cleanup.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
/cc @chaosi-zju @RainbowMango