kubevirt

package
v0.0.0-...-bdf4f4e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ARPProxyIPv4 is a randomly chosen IPv4 link-local address that kubevirt
	// pods will have as default gateway
	ARPProxyIPv4 = "169.254.1.1"

	// ARPProxyIPv6 is a randomly chosen IPv6 link-local address that kubevirt
	// pods will have as default gateway
	ARPProxyIPv6 = "fe80::1"

	// ARPProxyMAC is a generated mac from ARPProxyIPv4, it's generated with
	// the mechanism at `util.IPAddrToHWAddr`
	ARPProxyMAC = "0a:58:a9:fe:01:01"
)
View Source
const (
	OvnZoneExternalIDKey = types.OvnK8sPrefix + "/zone"
	OvnRemoteZone        = "remote"
	OvnLocalZone         = "local"

	NamespaceExternalIDsKey      = "k8s.ovn.org/namespace"
	VirtualMachineExternalIDsKey = "k8s.ovn.org/vm"
)

Variables

This section is empty.

Functions

func AllVMPodsAreCompleted

func AllVMPodsAreCompleted(client *factory.WatchFactory, pod *corev1.Pod) (bool, error)

AllVMPodsAreCompleted return true if all the vm pods are completed

func AllocateSyncMigratablePodIPsOnZone

func AllocateSyncMigratablePodIPsOnZone(watchFactory *factory.WatchFactory, lsManager *logicalswitchmanager.LogicalSwitchManager, nadName string, pod *corev1.Pod, allocatePodIPsOnSwitch func(*corev1.Pod, *util.PodAnnotation, string, string) (string, error)) (*ktypes.NamespacedName, string, *util.PodAnnotation, error)

AllocateSyncMigratablePodIPsOnZone will refill ip pool in with pod's IPs if those IPs belong to the zone

func CleanUpLiveMigratablePod

func CleanUpLiveMigratablePod(nbClient libovsdbclient.Client, watchFactory *factory.WatchFactory, pod *corev1.Pod) error

CleanUpLiveMigratablePod remove routing and DHCP ovn related resources when all the pods for the same VM as `pod` argument are completed.

func ComposeARPProxyLSPOption

func ComposeARPProxyLSPOption() string

ComposeARPProxyLSPOption returns the "arp_proxy" field needed at router type LSP to implement stable default gw for pod ip migration, it consists of generated MAC address, a link local ipv4 and ipv6( it's the same for all the logical switches) and the cluster subnet to allow the migrated vm to ping pods for the same subnet. This is how it works step by step: For default gw:

  • VM is configured with arp proxy IPv4/IPv6 as default gw
  • when a VM access an address that do not belong to its subnet it will send an ARP asking for the default gw IP
  • This will reach the OVN flows from arp_proxy and answer back with the mac address here
  • The vm will send the packet with that mac address so it will en being route by ovn.

For vm accessing pods at the same subnet after live migration

  • Since the dst address is at the same subnet it will not use default gw and will send an ARP for dst IP
  • The logical switch do not have any LSP with that address since vm has being live migrated
  • ovn will fallback to arp_proxy flows to resolve ARP (these flows have less priority that LSPs ones so they don't collide with them)
  • The ovn flow for the cluster wide CIDR will be hit and ovn will answer back with arp_proxy mac
  • VM will send the message to that mac and it will end being route by ovn

func ComposeDHCPv4Options

func ComposeDHCPv4Options(cidr, controllerName string, vmKey ktypes.NamespacedName) *nbdb.DHCPOptions

func ComposeDHCPv6Options

func ComposeDHCPv6Options(cidr, controllerName string, vmKey ktypes.NamespacedName) *nbdb.DHCPOptions

func DeleteDHCPOptions

func DeleteDHCPOptions(nbClient libovsdbclient.Client, pod *corev1.Pod) error

func DeleteRoutingForMigratedPod

func DeleteRoutingForMigratedPod(nbClient libovsdbclient.Client, pod *corev1.Pod) error

func DeleteRoutingForMigratedPodWithZone

func DeleteRoutingForMigratedPodWithZone(nbClient libovsdbclient.Client, pod *corev1.Pod, zone string) error

func EnsureDHCPOptionsForLSP

func EnsureDHCPOptionsForLSP(controllerName string, nbClient libovsdbclient.Client, pod *corev1.Pod, ips []*net.IPNet, lsp *nbdb.LogicalSwitchPort, opts ...DHCPConfigsOpt) error

func EnsureDHCPOptionsForMigratablePod

func EnsureDHCPOptionsForMigratablePod(controllerName string, nbClient libovsdbclient.Client, watchFactory *factory.WatchFactory, pod *corev1.Pod, ips []*net.IPNet, lsp *nbdb.LogicalSwitchPort) error

func EnsureLocalZonePodAddressesToNodeRoute

func EnsureLocalZonePodAddressesToNodeRoute(watchFactory *factory.WatchFactory, nbClient libovsdbclient.Client, lsManager *logicalswitchmanager.LogicalSwitchManager, pod *corev1.Pod, nadName string) error

EnsureLocalZonePodAddressesToNodeRoute will add static routes and policies to ovn_cluster_route logical router to ensure VM traffic work as expected after live migration if the pod is running at the local/global zone.

NOTE: IC with multiple nodes per zone is not supported

Following is the list of NB logical resources created depending if it's interconnected or not:

IC (on node per zone):

  • static route with cluster wide CIDR as src-ip prefix and nexthop GR, it has less priority than route to use overlay in case of pod to pod communication

NO IC:

  • low priority policy with src VM ip and reroute GR, since it has low priority it will not override the policy to enroute pod to pod traffic using overlay

Both:

  • static route with VM ip as dst-ip prefix and output port the LRP pointing to the VM's node switch

func EnsurePodAnnotationForVM

func EnsurePodAnnotationForVM(watchFactory *factory.WatchFactory, kube *kube.KubeOVN, pod *corev1.Pod, netInfo util.NetInfo, nadName string) (*util.PodAnnotation, error)

EnsurePodAnnotationForVM will at live migration extract the ovn pod annotations from the source vm pod and copy it to the target vm pod so ip address follow vm during migration. This has to done before creating the LSP to be sure that Address field get configured correctly at the target VM pod LSP.

func EnsureRemoteZonePodAddressesToNodeRoute

func EnsureRemoteZonePodAddressesToNodeRoute(controllerName string, watchFactory *factory.WatchFactory, nbClient libovsdbclient.Client, lsManager *logicalswitchmanager.LogicalSwitchManager, pod *corev1.Pod, nadName string) error

EnsureRemoteZonePodAddressesToNodeRoute will add static routes when live migrated pod belongs to remote zone to send traffic over transwitch switch port of the node where the pod is running:

  • A dst-ip with live migrated pod ip as prefix and nexthop the pod's current node transit switch port.

func ExtractVMNameFromPod

func ExtractVMNameFromPod(pod *corev1.Pod) *ktypes.NamespacedName

ExtractVMNameFromPod returns namespace and name of vm backed up but the pod for regular pods return nil

func FindLiveMigratablePods

func FindLiveMigratablePods(watchFactory *factory.WatchFactory) ([]*corev1.Pod, error)

FindLiveMigratablePods will return all the pods with a `vm.kubevirt.io` label filtered by `kubevirt.io/allow-pod-bridge-network-live-migration` annotation

func IsMigratedSourcePodStale

func IsMigratedSourcePodStale(client *factory.WatchFactory, pod *corev1.Pod) (bool, error)

IsMigratedSourcePodStale return false if the pod is live migratable, not completed and is the running VM pod with newest creation timestamp

func IsPodAllowedForMigration

func IsPodAllowedForMigration(pod *corev1.Pod, netInfo util.NetInfo) bool

IsPodAllowedForMigration determines whether a given pod is eligible for live migration

func IsPodLiveMigratable

func IsPodLiveMigratable(pod *corev1.Pod) bool

IsPodLiveMigratable will return true if the pod belongs to kubevirt and should use the live migration features

func IsPodOwnedByVirtualMachine

func IsPodOwnedByVirtualMachine(pod *corev1.Pod) bool

IsPodOwnedByVirtualMachine returns true if the pod is own by a kubevirt virtual machine, false otherwise.

func RetrieveDNSServiceClusterIPs

func RetrieveDNSServiceClusterIPs(k8scli *factory.WatchFactory) (string, string, error)

func SyncVirtualMachines

func SyncVirtualMachines(nbClient libovsdbclient.Client, vms map[ktypes.NamespacedName]bool) error

func WithIPv4DNSServer

func WithIPv4DNSServer(dnsServer string) func(*dhcpConfigs)

func WithIPv4MTU

func WithIPv4MTU(mtu int) func(*dhcpConfigs)

func WithIPv4Router

func WithIPv4Router(router string) func(*dhcpConfigs)

func WithIPv6DNSServer

func WithIPv6DNSServer(dnsServer string) func(*dhcpConfigs)

func ZoneContainsPodSubnet

func ZoneContainsPodSubnet(lsManager *logicalswitchmanager.LogicalSwitchManager, ips []*net.IPNet) (string, bool)

ZoneContainsPodSubnet will return true if the logical switch tonains the pod subnet and also the switch name owning it, this means that this zone owns the that subnet.

func ZoneContainsPodSubnetOrUntracked

func ZoneContainsPodSubnetOrUntracked(watchFactory *factory.WatchFactory, lsManager *logicalswitchmanager.LogicalSwitchManager, hostSubnets []*net.IPNet, annotation *util.PodAnnotation) ([]*net.IPNet, bool, error)

ZoneContainsPodSubnetOrUntracked returns whether a pod with its corresponding allocated IPs as reflected on the annotation come from a subnet that is either assigned to a node of the zone or, not assigned to any node after migrating from a node that has since been deleted and the subnet originally assigned to that node has not yet been re-assigned to a different node. For convenience, the host subnets might not provided in which case they might be parsed and returned if used.

Types

type DHCPConfigsOpt

type DHCPConfigsOpt = func(*dhcpConfigs)

type LiveMigrationState

type LiveMigrationState string

LiveMigrationState represents the various states of a live migration process.

const (
	// LiveMigrationInProgress indicates that a live migration is currently ongoing.
	LiveMigrationInProgress LiveMigrationState = "InProgress"

	// LiveMigrationTargetDomainReady indicates that the target domain is ready to take over.
	LiveMigrationTargetDomainReady LiveMigrationState = "TargetDomainReady"

	// LiveMigrationFailed indicates that the live migration process has failed.
	LiveMigrationFailed LiveMigrationState = "Failed"
)

type LiveMigrationStatus

type LiveMigrationStatus struct {
	SourcePod *corev1.Pod        // SourcePod is the original pod.
	TargetPod *corev1.Pod        // TargetPod is the destination pod.
	State     LiveMigrationState // State is the current state of the live migration.
}

LiveMigrationStatus provides details about the current status of a live migration. It includes information about the source and target pods as well as the migration state.

func DiscoverLiveMigrationStatus

func DiscoverLiveMigrationStatus(client *factory.WatchFactory, pod *corev1.Pod) (*LiveMigrationStatus, error)

DiscoverLiveMigrationStatus determines the status of a live migration for a given pod. It analyzes the state of pods associated with a VirtualMachine (VM) to identify whether a live migration is in progress, the target domain is ready, or the migration has failed.

Note: The function assumes that the pod is part of a VirtualMachine resource managed by KubeVirt.

func (LiveMigrationStatus) IsTargetDomainReady

func (lm LiveMigrationStatus) IsTargetDomainReady() bool

IsTargetDomainReady returns true if the target domain in the live migration process is ready.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL