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

Set EvictionStrategy to external on KubeVirt VMs #1504

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
1 change: 1 addition & 0 deletions docs/kubevirt.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ are some things you need to keep in mind:

* The machine-controller will create `VMIs` that have the same name as the underlying `machine`. To
avoid collisions, use one namespace per cluster that runs the `machine-controller`
* EvictionStratey of `VMIs` is set to external, so VMI eviction needs to handled properly by a custom external controller or manual action
* Service CIDR range: The CIDR ranges of the cluster that runs Kubevirt and the cluster that hosts the machine-controller must not overlap,
otherwise routing of services that run in the kubevirt cluster won't work anymore. This is especially important for the DNS ClusterIP.
* `clusterName` is used to [label VMs](https://github.com/kubevirt/cloud-provider-kubevirt#prerequisites) for LoadBalancer selection
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloudprovider/provider/kubevirt/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,8 @@ func (p *provider) newVirtualMachine(ctx context.Context, c *Config, pc *provide
// The secret has an ownerRef on the VMI so garbace collection will take care of cleaning up.
terminationGracePeriodSeconds := int64(30)

evictionStrategy := kubevirtv1.EvictionStrategyExternal

resourceRequirements := kubevirtv1.ResourceRequirements{}
labels := map[string]string{"kubevirt.io/vm": machine.Name}
//Add a common label to all VirtualMachines spawned by the same MachineDeployment (= MachineDeployment name).
Expand Down Expand Up @@ -652,6 +654,7 @@ func (p *provider) newVirtualMachine(ctx context.Context, c *Config, pc *provide
Labels: labels,
},
Spec: kubevirtv1.VirtualMachineInstanceSpec{
EvictionStrategy: &evictionStrategy,
Networks: []kubevirtv1.Network{
*kubevirtv1.DefaultPodNetwork(),
},
Expand Down
1 change: 1 addition & 0 deletions pkg/cloudprovider/provider/kubevirt/testdata/affinity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ spec:
name: secondary-disks-secondarydisk0
name: secondary-disks-secondarydisk0
- dataVolume:
name: secondary-disks-secondarydisk1
name: secondary-disks-secondarydisk1
name: secondary-disks-secondarydisk1
evictionStrategy: External
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ spec:
secretRef:
name: udsn
name: cloudinitdisk
evictionStrategy: External