-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix operator upgrade issue #6483
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
Open
zhzhuang-zju
wants to merge
1
commit into
karmada-io:master
Choose a base branch
from
zhzhuang-zju:operatorupgrade
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+15
−1
Open
Changes from all commits
Commits
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
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.
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 means always use the original selector, so that it never gets a chance to change it? even when it is required in new version?
Is .spec.template.lables mutable? Why we need to keep the original labels?
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.
Yes, the selector field of Deployments/StatefulSets is immutable. Once defined, it cannot be changed. So in the operator upgrade scenarios, it should not be changed.
In fact, this selector only needs to match .spec.template.labels.
.spec.template.lablesis mutable, it can be modified according to requirements. We don't need to keep the original labels. Instead, we should add theselectorto the labels of the new version to ensure that theselectorcan match.spec.template.labels.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.
Thanks for explaining.
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.
My concern is that if we use merge here, it means we'll always carry selectors that aren't needed, right?
I haven't looked closely. What's the difference between the original selector and the new selector?
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.
Take deployment as an example. deploymentSpec.Selector is used to select pods affected by this deployment. deploymentSpec.Selector cannot be modified. Therefore, podLabels must include deploymentSpec.Selector.
For example:
From
v1.13.0tov1.14.0, the components will be from:to
The purpose is to support deploying multiple Karmada instances within the same namespace. The original pod labels cannot ensure uniqueness within the same namespace, so the Karmada instance name is newly added to the labels.
Since the selector cannot be modified, the above upgrade will fail.
After modifying:
When upgrading from v1.13.0 to v1.14.1, the components will be from:
to
The selector remains unchanged, and the podLabel is the label of the new version plus the selector of the old version.
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.
That's exactly my concern. The label
karmada-apphas essentially been deprecated since v1.13.0, but during the migration to v1.14.0, we have to keep it, and never get a chance to get rid of it. In other words, this might not be a clean migration, just a tradeoff.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.
Kubernetes subscribes to the immutable infrastructure paradigm. Immutable infrastructure refers to the concept where deployed infrastructure is never modified in place. If changes are required to a given resource, destroying the current resource and rebuilding that resource with changes is the appropriate workflow.
Therefore, when immutable fields such as
selectorchange due to functional evolution during an upgrade, the common practice is redploying, which means deleting the resource first and then recreating it.Similar behaviors:
kubectl replace --force: Force replace, delete and then re-create the resource
argo: allows users to specifically annotate
argocd.argoproj.io/sync-options: Replace=true,Force=trueon resources that they know can't be updated without being deleted first.What I'm worried about is that if the selector of the component changes during the upgrade process, the downtime of redeploying will be greater than that of updating. This also gives us a lesson: It’s so important to plan our deployments so that we prevent ourselves from making changes to the label selectors once the deployments have been created.
WDYT? @jabellard @RainbowMango