-
Notifications
You must be signed in to change notification settings - Fork 919
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
This Job is no longer rendering for me There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do you mean it can't be installed on your side? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Amazing ❤️ |
||
{{- $name := include "karmada.name" . -}} | ||
{{- $namespace := include "karmada.namespace" . -}} | ||
{{- if eq .Values.installMode "host" }} | ||
|
@@ -51,8 +52,8 @@ spec: | |
bash <<'EOF' | ||
set -ex | ||
|
||
# The `post-install hook job` may be applied before all karmada components are ready that rely on `static-resource job` and `hook-job secret`. | ||
# So, we have to postpone the deletion of the `static-resource job` and `hook-job secret` until all karmada components are up and running. | ||
# The `post-install hook job` may be applied before all karmada components are ready that rely on `static-resource job`. | ||
# So, we have to postpone the deletion of the `static-resource job` until all karmada components are up and running. | ||
while [[ $(kubectl get pods -n {{ $namespace }} --field-selector=status.phase!=Running,status.phase!=Succeeded -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -v static-resource | wc -l) > 0 ]]; | ||
do | ||
echo "waiting for all pods of karmada control plane ready..."; sleep 1; | ||
|
@@ -61,3 +62,4 @@ spec: | |
kubectl delete job {{ $name }}-static-resource -n {{ $namespace }} | ||
EOF | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,9 @@ preInstallJob: | |
staticResourceJob: | ||
tolerations: [] | ||
nodeSelector: {} | ||
## 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 | ||
Comment on lines
+105
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
|
||
## post-install job config | ||
postInstallJob: | ||
|
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.
It's helm's built-in objects.
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.