Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/core/v1alpha2/vmopcondition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ const (

// ReasonOperationCompleted is a ReasonCompleted indicating that operation is completed.
ReasonOperationCompleted ReasonCompleted = "OperationCompleted"

// ReasonMigrationNetworkUnavailable indicates that liveMigration.systemNetworkName is configured in the ModuleConfig but the source node has no resolved migration interface.
ReasonMigrationNetworkUnavailable ReasonCompleted = "MigrationNetworkUnavailable"
)

// ReasonCompleted represents specific reasons for the 'SignalSent' condition type.
Expand Down
2 changes: 1 addition & 1 deletion build/components/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ firmware:
libvirt: v10.9.0
edk2: stable202411
core:
3p-kubevirt: v1.6.2-v12n.38
3p-kubevirt: feat/network/dedicated-migration-network
3p-containerized-data-importer: v1.60.3-v12n.19
distribution: 2.8.3
package:
Expand Down
11 changes: 11 additions & 0 deletions docs/ADMIN_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,17 @@ How to start VM migration in the web interface:
- Select `Migrate` from the pop-up menu.
- Confirm or cancel the migration in the pop-up window.

#### Dedicated migration network

By default, live migration traffic flows over the node's default network and competes with workload traffic. You can also route it over a dedicated VLAN provisioned by the [`sdn`](https://deckhouse.io/modules/sdn/) module.

Prerequisites:

- The `sdn` module is enabled.
- A `SystemNetwork` resource exists and is in the `Ready` state.

To enable the feature, set `spec.settings.liveMigration.systemNetworkName` on the `virtualization` ModuleConfig to the name of the prepared `SystemNetwork`. Once configured, every VM migration in the cluster runs over the specified `SystemNetwork` VLAN.

#### Maintenance mode

When working on nodes with virtual machines running, there is a risk of disrupting their performance. To avoid this, you can put a node into the maintenance mode and migrate the virtual machines to other free nodes.
Expand Down
11 changes: 11 additions & 0 deletions docs/ADMIN_GUIDE.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,17 @@ spec:
- Во всплывающем меню выберите `Мигрировать`.
- Во всплывающем окне подтвердите или отмените миграцию.

#### Выделенная сеть для миграции

По умолчанию трафик живой миграции идёт по основной сети узла и конкурирует за полосу пропускания с пользовательскими нагрузками. Его можно направить через выделенный VLAN, предоставляемый модулем [`sdn`](https://deckhouse.ru/modules/sdn/).

Необходимые условия:

- Включён модуль `sdn`.
- Ресурс `SystemNetwork` создан и находится в состоянии `Ready`.

Чтобы включить возможность, укажите имя подготовленного `SystemNetwork` в поле `spec.settings.liveMigration.systemNetworkName` ресурса ModuleConfig `virtualization`. После настройки каждая миграция виртуальных машин в кластере выполняется по VLAN указанного `SystemNetwork`.

#### Режим обслуживания

При выполнении работ на узлах с запущенными виртуальными машинами существует риск нарушения их работоспособности. Чтобы этого избежать, узел можно перевести в режим обслуживания и мигрировать виртуальные машины на другие свободные узлы.
Expand Down
2 changes: 2 additions & 0 deletions images/virt-artifact/werf.inc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

---
image: {{ .ModuleNamePrefix }}{{ .ImageName }}-src-artifact
fromCacheVersion: "{{ now | date "Mon Jan 2 15:04:05 MST 2006" }}"
final: false
fromImage: builder/src
secrets:
Expand Down Expand Up @@ -42,6 +43,7 @@ packages:
{{ $builderDependencies := include "$name" . | fromYaml }}

image: {{ .ModuleNamePrefix }}{{ .ImageName }}
fromCacheVersion: "{{ now | date "Mon Jan 2 15:04:05 MST 2006" }}"
final: false
fromImage: {{ eq $.SVACE_ENABLED "false" | ternary "builder/golang-alt-1.25" "builder/golang-alt-svace-1.25" }}
mount:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/deckhouse/virtualization-controller/pkg/controller/evacuation"
"github.com/deckhouse/virtualization-controller/pkg/controller/indexer"
"github.com/deckhouse/virtualization-controller/pkg/controller/livemigration"
"github.com/deckhouse/virtualization-controller/pkg/controller/migrationiface"
mc "github.com/deckhouse/virtualization-controller/pkg/controller/moduleconfig"
mcapi "github.com/deckhouse/virtualization-controller/pkg/controller/moduleconfig/api"
"github.com/deckhouse/virtualization-controller/pkg/controller/nodeusbdevice"
Expand Down Expand Up @@ -96,6 +97,8 @@ const (

SdnEnabledEnv = "SDN_ENABLED"
clusterUUIDEnv = "CLUSTER_UUID"

migrationSystemNetworkNameEnv = "MIGRATION_SYSTEM_NETWORK_NAME"
)

func main() {
Expand Down Expand Up @@ -259,6 +262,11 @@ func main() {
BindAddress: metricsBindAddr,
},
HealthProbeBindAddress: healthProbeBindAddr,
// Route unstructured reads through the cache so field-index lookups are served locally
// instead of hitting the apiserver.
Client: client.Options{
Cache: &client.CacheOptions{Unstructured: true},
},
}
if pprofBindAddr != "" {
managerOpts.PprofBindAddress = pprofBindAddr
Expand Down Expand Up @@ -402,6 +410,12 @@ func main() {
os.Exit(1)
}

migrationIfaceLogger := logger.NewControllerLogger(migrationiface.ControllerName, logLevel, logOutput, logDebugVerbosity, logDebugControllerList)
if _, err = migrationiface.NewController(ctx, mgr, migrationIfaceLogger, os.Getenv(migrationSystemNetworkNameEnv)); err != nil {
log.Error(err.Error())
os.Exit(1)
}

resourceSliceLogger := logger.NewControllerLogger(resourceslice.ControllerName, logLevel, logOutput, logDebugVerbosity, logDebugControllerList)
if _, err = resourceslice.NewController(ctx, mgr, resourceSliceLogger); err != nil {
log.Error(err.Error())
Expand All @@ -427,7 +441,7 @@ func main() {
}

vmopLogger := logger.NewControllerLogger(vmop.ControllerName, logLevel, logOutput, logDebugVerbosity, logDebugControllerList)
if err = vmop.SetupController(ctx, mgr, vmopLogger); err != nil {
if err = vmop.SetupController(ctx, mgr, vmopLogger, os.Getenv(migrationSystemNetworkNameEnv)); err != nil {
log.Error(err.Error())
os.Exit(1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ const (
// AnnNetworksStatus is the annotation for view current network configuration into Pod.
AnnNetworksStatus = "network.deckhouse.io/networks-status"

// AnnMigrationIface names the kernel interface that virt-handler binds
// live-migration traffic to. Written on Nodes by the migrationiface
// controller from a SystemNetwork CR (sdn module); read by virt-handler
// on startup.
AnnMigrationIface = AnnAPIGroupV + "/migration-iface"

// AnnVirtualDiskOriginalAnnotations is the annotation for storing original VirtualDisk annotations.
AnnVirtualDiskOriginalAnnotations = AnnAPIGroupV + "/vd-original-annotations"
// AnnVirtualDiskOriginalLabels is the annotation for storing original VirtualDisk labels.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ const (

IndexFieldResourceSliceByPoolName = "spec.pool.name"
IndexFieldResourceSliceByDriver = "spec.driver"

IndexFieldSNNNIAByNodeName = "snnnia.status.nodeName"
IndexFieldSNNNIABySystemNetworkName = "snnnia.spec.systemNetworkName"
)

var IndexGetters = []IndexGetter{
Expand Down Expand Up @@ -113,6 +116,11 @@ var IndexGettersUSB = []IndexGetter{
IndexResourceSliceByDriver,
}

var IndexGettersSDN = []IndexGetter{
IndexSNNNIAByNodeName,
IndexSNNNIABySystemNetworkName,
}

type IndexGetter func() (obj client.Object, field string, extractValue client.IndexerFunc)

func IndexALL(ctx context.Context, mgr manager.Manager) error {
Expand All @@ -125,6 +133,15 @@ func IndexALL(ctx context.Context, mgr manager.Manager) error {
}
}

if featuregates.Default().Enabled(featuregates.SDN) {
for _, fn := range IndexGettersSDN {
obj, field, indexFunc := fn()
if err := mgr.GetFieldIndexer().IndexField(ctx, obj, field, indexFunc); err != nil {
return err
}
}
}

for _, fn := range IndexGetters {
obj, field, indexFunc := fn()
if err := mgr.GetFieldIndexer().IndexField(ctx, obj, field, indexFunc); err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package indexer

import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
)

var snnniaGVK = schema.GroupVersionKind{
Group: "network.deckhouse.io",
Version: "v1alpha1",
Kind: "SystemNetworkNodeNetworkInterfaceAttachment",
}

func snnniaSeed() client.Object {
u := &unstructured.Unstructured{}
u.SetGroupVersionKind(snnniaGVK)
return u
}

func snnniaIndexer(path ...string) client.IndexerFunc {
return func(o client.Object) []string {
u, ok := o.(*unstructured.Unstructured)
if !ok || u == nil {
return nil
}
v, _, _ := unstructured.NestedString(u.Object, path...)
if v == "" {
return nil
}
return []string{v}
}
}

func IndexSNNNIAByNodeName() (client.Object, string, client.IndexerFunc) {
return snnniaSeed(), IndexFieldSNNNIAByNodeName, snnniaIndexer("status", "nodeName")
}

func IndexSNNNIABySystemNetworkName() (client.Object, string, client.IndexerFunc) {
return snnniaSeed(), IndexFieldSNNNIABySystemNetworkName, snnniaIndexer("spec", "systemNetworkName")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package migrationiface annotates each Node with the kernel interface name
// of a dedicated live-migration network, resolved from sdn's
// SystemNetworkNodeNetworkInterfaceAttachment + NodeNetworkInterface.
// virt-handler reads the annotation (see pkg/common/annotations.AnnMigrationIface)
// at startup to bind migration traffic to that interface.
package migrationiface

import (
"context"
"time"

"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/deckhouse/deckhouse/pkg/log"
"github.com/deckhouse/virtualization-controller/pkg/featuregates"
"github.com/deckhouse/virtualization-controller/pkg/logger"
)

const ControllerName = "migrationiface-controller"

func NewController(
ctx context.Context,
mgr manager.Manager,
log *log.Logger,
systemNetworkName string,
) (controller.Controller, error) {
if !featuregates.Default().Enabled(featuregates.SDN) {
log.Info("SDN feature gate is disabled, migrationiface controller is disabled")
return nil, nil
}

r := NewReconciler(mgr.GetClient(), systemNetworkName, log)

c, err := controller.New(ControllerName, mgr, controller.Options{
Reconciler: r,
RecoverPanic: ptr.To(true),
LogConstructor: logger.NewConstructor(log),
CacheSyncTimeout: 10 * time.Minute,
})
if err != nil {
return nil, err
}

if err = r.SetupController(ctx, mgr, c); err != nil {
return nil, err
}

log.Info("Initialized migrationiface controller", "systemNetwork", systemNetworkName)
return c, nil
}
Loading
Loading