Skip to content
Merged
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
8 changes: 8 additions & 0 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3296,6 +3296,14 @@ You can create a VM clone in two ways: from an existing VM or from a previously
The cloned VM will be assigned a new IP address for the cluster network and MAC addresses for additional network interfaces (if any), so you will need to reconfigure the guest OS network settings after cloning.
{{< /alert >}}

{{< alert level="info" >}}
Labels are not copied from the source VM to the clone. This prevents Service traffic (Services select VMs by labels) from being routed to the clone. If the clone should be part of a Service, add the required labels after cloning. For example:

```bash
d8 k label vm <vm-name> label-name=label-value
```
{{< /alert >}}

Cloning creates a copy of a VM, so the resources of the new VM must have unique names. To do this, use the `nameReplacements` and/or `customization` parameters:

- `nameReplacements`: Allows you to replace the names of existing resources with new ones to avoid conflicts.
Expand Down
8 changes: 8 additions & 0 deletions docs/USER_GUIDE.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -3332,6 +3332,14 @@ d8 k get vmop <vmop-name> -o json | jq '.status.resources'
Клонируемой ВМ будет назначен новый IP-адрес для кластерной сети и MAC-адреса для дополнительных сетевых интерфейсов (если они есть), поэтому после клонирования потребуется перенастроить сетевые параметры гостевой ОС.
{{< /alert >}}

{{< alert level="info" >}}
Лейблы не копируются с исходной ВМ на клон. Это предотвращает маршрутизацию трафика Service (Service выбирают ВМ по меткам) на клон. Если клон должен входить в Service, добавьте нужные лейблы после клонирования. Например:

```bash
d8 k label vm <vm-name> label-name=label-value
```
{{< /alert >}}

Клонирование создаёт копию ВМ, поэтому ресурсы новой ВМ должны иметь уникальные имена. Для этого используются параметры `nameReplacements` и/или `customization`:

- `nameReplacements` — позволяет заменить имена существующих ресурсов на новые, чтобы избежать конфликтов.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ func (v *VirtualMachineHandler) ProcessClone(ctx context.Context) error {
return err
}

// Do not clone labels due to potential issues with traffic from services.
v.vm.Labels = map[string]string{}

err = v.client.Create(ctx, v.vm)
if err != nil {
return fmt.Errorf("failed to create the `VirtualMachine`: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ func NewVirtualMachineOverrideValidator(vmTmpl *v1alpha2.VirtualMachine, client
}

func (v *VirtualMachineOverrideValidator) Override(rules []v1alpha2.NameReplacement) {
originalName := v.vm.Name
v.vm.Name = overrideName(v.vm.Kind, v.vm.Name, rules)
if v.vm.Name != originalName {
// Do not clone labels due to potential issues with traffic from services.
v.vm.Labels = map[string]string{}
}

v.vm.Spec.VirtualMachineIPAddress = overrideName(v1alpha2.VirtualMachineIPAddressKind, v.vm.Spec.VirtualMachineIPAddress, rules)

if v.vm.Spec.Provisioning != nil {
Expand Down
Loading