Skip to content
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

feat(vm): add live migration for nodePlacement #518

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

yaroslavborbat
Copy link
Member

@yaroslavborbat yaroslavborbat commented Nov 12, 2024

Description

Apply nodeSelector and Affinity configuration immediately to build EE.
Add patch 024-auto-migrate-if-nodeplacement-changed.patch for kubevirt.
By default, migration at kubevirt startup is performed only to puHotplug,memoryHotplug or update static volumes.
This patch startup live-migration after updating nodeSelector or affinity.
If the current node is matched to a new "nodeSelector" or "affinity", then the migration will not be started

Why do we need it, and what problem does it solve?

What is the expected result?

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Signed-off-by: yaroslavborbat <[email protected]>
Signed-off-by: yaroslavborbat <[email protected]>
Signed-off-by: yaroslavborbat <[email protected]>
Signed-off-by: yaroslavborbat <[email protected]>
Signed-off-by: yaroslavborbat <[email protected]>
@yaroslavborbat yaroslavborbat force-pushed the feat/vm/add-live-migrate-for-nodeplacement branch 2 times, most recently from 813c320 to 42ec5a0 Compare November 13, 2024 09:16
Signed-off-by: yaroslavborbat <[email protected]>
@yaroslavborbat yaroslavborbat force-pushed the feat/vm/add-live-migrate-for-nodeplacement branch from 42ec5a0 to dde4eb7 Compare November 13, 2024 09:38
Signed-off-by: yaroslavborbat <[email protected]>
@yaroslavborbat yaroslavborbat force-pushed the feat/vm/add-live-migrate-for-nodeplacement branch 2 times, most recently from 0cb3de5 to f2570ef Compare November 14, 2024 08:45
Signed-off-by: yaroslavborbat <[email protected]>
@yaroslavborbat yaroslavborbat force-pushed the feat/vm/add-live-migrate-for-nodeplacement branch from f2570ef to c75f196 Compare November 14, 2024 09:30
- task: dlv:virt-controller:print

dlv:virt-controller:print:
desc: "Print subcommands for debug"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the subcommand?

Suggested change
desc: "Print subcommands for debug"
desc: "Print commands for debug"

Comment on lines +170 to +185
cat <<EOF
kubectl -n d8-virtualization patch deploy virt-controller --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virt-controller",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
EOF
echo 'kubectl -n d8-virtualization port-forward $(kubectl -n d8-virtualization get pod -l kubevirt.internal.virtualization.deckhouse.io=virt-controller -oname | head -1) 2345:2345'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cat <<EOF
kubectl -n d8-virtualization patch deploy virt-controller --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virt-controller",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
EOF
echo 'kubectl -n d8-virtualization port-forward $(kubectl -n d8-virtualization get pod -l kubevirt.internal.virtualization.deckhouse.io=virt-controller -oname | head -1) 2345:2345'
cat <<EOF
kubectl -n d8-virtualization patch deploy virt-controller --type='strategic' -p '{
"spec": {
"template": {
"spec": {
"containers": [ {
"name": "virt-controller",
"image": "${IMAGE}",
"ports": [ { "containerPort": 2345, "name": "dlv" } ]
}]
}
}
}
}'
kubectl -n d8-virtualization port-forward deploy/virt-controller 2345:2345
EOF

Comment on lines +407 to +422
+ "k8s.io/apimachinery/pkg/labels"
"k8s.io/utils/ptr"

+ "kubevirt.io/kubevirt/pkg/indexers"
"kubevirt.io/kubevirt/pkg/virt-controller/network"

+ networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
+
+ "kubevirt.io/kubevirt/pkg/util/affinity"
+
"kubevirt.io/kubevirt/pkg/virt-controller/watch/topology"

backendstorage "kubevirt.io/kubevirt/pkg/storage/backend-storage"

- networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, disable autoformatting for kubevirt =)


#### `024-auto-migrate-if-nodeplacement-changed.patch`

Start the migration if the nodeSelector or affinity has changed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This huge patch deserves more detailed description.

Comment on lines +229 to +230
domainSpec.CPU.Sockets = uint32(cpuRequest.Value())
domainSpec.CPU.MaxSockets = uint32(cpuLimit.Value())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set values for sockets is something new. It should be explained in PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation/skip/copyright Skip copyright validation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants