From b521a26e6e27ee6c0dbf352a42d1ed40a9249285 Mon Sep 17 00:00:00 2001 From: Lee Yarwood Date: Thu, 17 Nov 2022 15:32:59 +0000 Subject: [PATCH] Deploy common-instancetypes v0.0.1-rc This initial change starts to simply deploy the v0.0.1-rc bundle of VirtualMachineCluster{Instancetypes,Preferences} resources. These resources are deployed under both OpenShift and non-OpenShift environments. At present this is the only functionality enabled within the operator when deployed under non-OpenShift environments. Future changes will introduce support for removing deprecated resources and for deploying resources from a kustomize repo URI. Signed-off-by: Lee Yarwood --- config/rbac/role.yaml | 24 + controllers/setup.go | 30 +- .../common-clusterinstancetypes-bundle.yaml | 93 +++ .../common-clusterpreferences-bundle.yaml | 664 ++++++++++++++++++ .../ssp-operator.clusterserviceversion.yaml | 24 + internal/common/scheme.go | 2 + .../common-instancetypes/reconcile.go | 147 ++++ .../common-instancetypes/reconcile_test.go | 94 +++ .../kubevirt.io/api/instancetype/register.go | 37 + .../v1alpha2/deepcopy_generated.go | 627 +++++++++++++++++ .../api/instancetype/v1alpha2/doc.go | 24 + .../api/instancetype/v1alpha2/register.go | 64 ++ .../api/instancetype/v1alpha2/types.go | 463 ++++++++++++ .../v1alpha2/types_swagger_generated.go | 174 +++++ vendor/modules.txt | 2 + 15 files changed, 2458 insertions(+), 11 deletions(-) create mode 100644 data/common-instancetypes-bundle/common-clusterinstancetypes-bundle.yaml create mode 100644 data/common-instancetypes-bundle/common-clusterpreferences-bundle.yaml create mode 100644 internal/operands/common-instancetypes/reconcile.go create mode 100644 internal/operands/common-instancetypes/reconcile_test.go create mode 100644 vendor/kubevirt.io/api/instancetype/register.go create mode 100644 vendor/kubevirt.io/api/instancetype/v1alpha2/deepcopy_generated.go create mode 100644 vendor/kubevirt.io/api/instancetype/v1alpha2/doc.go create mode 100644 vendor/kubevirt.io/api/instancetype/v1alpha2/register.go create mode 100644 vendor/kubevirt.io/api/instancetype/v1alpha2/types.go create mode 100644 vendor/kubevirt.io/api/instancetype/v1alpha2/types_swagger_generated.go diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 568979d96..42a3676db 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -186,6 +186,30 @@ rules: - patch - update - watch +- apiGroups: + - instancetype.kubevirt.io + resources: + - virtualmachineclusterinstancetypes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - instancetype.kubevirt.io + resources: + - virtualmachineclusterpreferences + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - kubevirt.io resources: diff --git a/controllers/setup.go b/controllers/setup.go index 689d169d2..7953b2fc8 100644 --- a/controllers/setup.go +++ b/controllers/setup.go @@ -10,6 +10,7 @@ import ( "kubevirt.io/ssp-operator/internal/common" crd_watch "kubevirt.io/ssp-operator/internal/crd-watch" "kubevirt.io/ssp-operator/internal/operands" + common_instancetypes "kubevirt.io/ssp-operator/internal/operands/common-instancetypes" common_templates "kubevirt.io/ssp-operator/internal/operands/common-templates" data_sources "kubevirt.io/ssp-operator/internal/operands/data-sources" "kubevirt.io/ssp-operator/internal/operands/metrics" @@ -47,23 +48,30 @@ func setupManager(ctx context.Context, cancel context.CancelFunc, mgr controller return fmt.Errorf("failed to read template bundle: %w", err) } - runningOnOpenShift, err := common.RunningOnOpenshift(ctx, mgr.GetAPIReader()) + instancetypePath := common_instancetypes.BundleDir + common_instancetypes.ClusterInstancetypesBundlePrefix + ".yaml" + preferencePath := common_instancetypes.BundleDir + common_instancetypes.ClusterPreferencesBundlePrefix + ".yaml" + common_instancetypes_operand, err := common_instancetypes.New(instancetypePath, preferencePath) if err != nil { return err } - if !runningOnOpenShift { - // do nothing if not running on OpenShift - mgr.GetLogger().Info("SSP operator is running in inactive mode. The operator will not react to any event.") - return nil + sspOperands := []operands.Operand{ + common_instancetypes_operand, } - sspOperands := []operands.Operand{ - metrics.New(), - template_validator.New(), - common_templates.New(templatesBundle.Templates), - data_sources.New(templatesBundle.DataSources), - node_labeller.New(), + runningOnOpenShift, err := common.RunningOnOpenshift(ctx, mgr.GetAPIReader()) + if err != nil { + return err + } + + if runningOnOpenShift { + sspOperands = append(sspOperands, + metrics.New(), + template_validator.New(), + common_templates.New(templatesBundle.Templates), + data_sources.New(templatesBundle.DataSources), + node_labeller.New(), + ) } var requiredCrds []string diff --git a/data/common-instancetypes-bundle/common-clusterinstancetypes-bundle.yaml b/data/common-instancetypes-bundle/common-clusterinstancetypes-bundle.yaml new file mode 100644 index 000000000..92535e13d --- /dev/null +++ b/data/common-instancetypes-bundle/common-clusterinstancetypes-bundle.yaml @@ -0,0 +1,93 @@ +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: large + name: highperformance.large +spec: + cpu: + dedicatedCPUPlacement: true + guest: 2 + isolateEmulatorThread: true + ioThreadsPolicy: shared + memory: + guest: 8Gi +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: medium + name: highperformance.medium +spec: + cpu: + dedicatedCPUPlacement: true + guest: 1 + isolateEmulatorThread: true + ioThreadsPolicy: shared + memory: + guest: 4Gi +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: small + name: highperformance.small +spec: + cpu: + dedicatedCPUPlacement: true + guest: 1 + isolateEmulatorThread: true + ioThreadsPolicy: shared + memory: + guest: 2Gi +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: large + name: server.large +spec: + cpu: + guest: 2 + memory: + guest: 8Gi +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: medium + name: server.medium +spec: + cpu: + guest: 1 + memory: + guest: 4Gi +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: small + name: server.small +spec: + cpu: + guest: 1 + memory: + guest: 2Gi +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterInstancetype +metadata: + labels: + kubevirt.io/size: tiny + name: server.tiny +spec: + cpu: + guest: 1 + memory: + guest: 1.5Gi diff --git a/data/common-instancetypes-bundle/common-clusterpreferences-bundle.yaml b/data/common-instancetypes-bundle/common-clusterpreferences-bundle.yaml new file mode 100644 index 000000000..796a615fa --- /dev/null +++ b/data/common-instancetypes-bundle/common-clusterpreferences-bundle.yaml @@ -0,0 +1,664 @@ +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: alpine +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: centos.7 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: centos.7.desktop +spec: + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: centos.8 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: centos.8.desktop +spec: + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: centos.9 +spec: + devices: + preferredDiskBus: virtio + preferredDiskDedicatedIoThread: true + preferredInterfaceModel: virtio + preferredRng: {} + features: + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: centos.9.desktop +spec: + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredDiskDedicatedIoThread: true + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + preferredRng: {} + features: + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: cirros +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: fedora.35 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio + preferredNetworkInterfaceMultiQueue: true + preferredRng: {} + features: + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: fedora.36 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio + preferredNetworkInterfaceMultiQueue: true + preferredRng: {} + features: + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: rhel.7 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: rhel.7.desktop +spec: + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: rhel.8 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: rhel.8.desktop +spec: + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: rhel.9 +spec: + devices: + preferredDiskBus: virtio + preferredDiskDedicatedIoThread: true + preferredInterfaceModel: virtio + preferredRng: {} + features: + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: rhel.9.desktop +spec: + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredDiskDedicatedIoThread: true + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + preferredRng: {} + features: + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: ubuntu.18.04 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio + preferredRng: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: ubuntu.20.04 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio + preferredRng: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: ubuntu.22.04 +spec: + devices: + preferredDiskBus: virtio + preferredInterfaceModel: virtio + preferredRng: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.10 +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: sata + preferredInterfaceModel: e1000e + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.10.virtio +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.11 +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: sata + preferredInterfaceModel: e1000e + preferredTPM: {} + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.11.virtio +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + preferredTPM: {} + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} + preferredSmm: {} + firmware: + preferredUseEfi: true + preferredUseSecureBoot: true +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.2k12 +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: sata + preferredInterfaceModel: e1000e + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.2k12.virtio +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.2k16 +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: sata + preferredInterfaceModel: e1000e + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.2k16.virtio +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.2k19 +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: sata + preferredInterfaceModel: e1000e + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} +--- +apiVersion: instancetype.kubevirt.io/v1alpha2 +kind: VirtualMachineClusterPreference +metadata: + name: windows.2k19.virtio +spec: + clock: + preferredClockOffset: + utc: {} + preferredTimer: + hpet: + present: false + hyperv: {} + pit: + tickPolicy: delay + rtc: + tickPolicy: catchup + cpu: + preferredCPUTopology: preferSockets + devices: + preferredAutoattachInputDevice: true + preferredDiskBus: virtio + preferredInputBus: virtio + preferredInputType: tablet + preferredInterfaceModel: virtio + features: + preferredAcpi: {} + preferredApic: {} + preferredHyperv: + frequencies: {} + ipi: {} + reenlightenment: {} + relaxed: {} + reset: {} + runtime: {} + spinlocks: + spinlocks: 8191 + synic: {} + synictimer: + direct: {} + tlbflush: {} + vapic: {} + vpindex: {} diff --git a/data/olm-catalog/ssp-operator.clusterserviceversion.yaml b/data/olm-catalog/ssp-operator.clusterserviceversion.yaml index 03792b407..99362df3d 100644 --- a/data/olm-catalog/ssp-operator.clusterserviceversion.yaml +++ b/data/olm-catalog/ssp-operator.clusterserviceversion.yaml @@ -231,6 +231,30 @@ spec: - patch - update - watch + - apiGroups: + - instancetype.kubevirt.io + resources: + - virtualmachineclusterinstancetypes + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - instancetype.kubevirt.io + resources: + - virtualmachineclusterpreferences + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - kubevirt.io resources: diff --git a/internal/common/scheme.go b/internal/common/scheme.go index a7302c07f..0485e1af5 100644 --- a/internal/common/scheme.go +++ b/internal/common/scheme.go @@ -7,6 +7,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" + instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2" sspv1beta1 "kubevirt.io/ssp-operator/api/v1beta1" ) @@ -21,4 +22,5 @@ func init() { utilruntime.Must(internalmeta.AddToScheme(Scheme)) utilruntime.Must(sspv1beta1.AddToScheme(Scheme)) utilruntime.Must(osconfv1.Install(Scheme)) + utilruntime.Must(instancetypev1alpha2.AddToScheme(Scheme)) } diff --git a/internal/operands/common-instancetypes/reconcile.go b/internal/operands/common-instancetypes/reconcile.go new file mode 100644 index 000000000..50d8947fb --- /dev/null +++ b/internal/operands/common-instancetypes/reconcile.go @@ -0,0 +1,147 @@ +package common_instancetypes + +import ( + "bytes" + "io" + "io/ioutil" + + "k8s.io/apimachinery/pkg/util/yaml" + instancetypeapi "kubevirt.io/api/instancetype" + instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2" + "kubevirt.io/ssp-operator/internal/common" + "kubevirt.io/ssp-operator/internal/operands" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// Define RBAC rules needed by this operand: +// +kubebuilder:rbac:groups=instancetype.kubevirt.io,resources=virtualmachineclusterinstancetypes,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=instancetype.kubevirt.io,resources=virtualmachineclusterpreferences,verbs=get;list;watch;create;update;patch;delete + +const ( + operandName = "common-instancetypes" + operandComponent = common.AppComponentTemplating + BundleDir = "data/common-instancetypes-bundle/" + ClusterInstancetypesBundlePrefix = "common-clusterinstancetypes-bundle" + ClusterPreferencesBundlePrefix = "common-clusterpreferences-bundle" +) + +type commonInstancetypes struct { + virtualMachineClusterInstancetypes []instancetypev1alpha2.VirtualMachineClusterInstancetype + virtualMachineClusterPreferences []instancetypev1alpha2.VirtualMachineClusterPreference +} + +var _ operands.Operand = &commonInstancetypes{} + +type clusterType interface { + instancetypev1alpha2.VirtualMachineClusterInstancetype | instancetypev1alpha2.VirtualMachineClusterPreference +} + +func fetchClusterResources[C clusterType](bundlePath string) ([]C, error) { + file, err := ioutil.ReadFile(bundlePath) + if err != nil { + return nil, err + } + decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(file), 1024) + var bundle []C + for { + resource := new(C) + err = decoder.Decode(resource) + if err == io.EOF { + return bundle, nil + } + if err != nil { + return nil, err + } + bundle = append(bundle, *resource) + } +} + +func New(instancetypeBundlePath, preferenceBundlePath string) (operands.Operand, error) { + virtualMachineClusterInstancetypes, err := fetchClusterResources[instancetypev1alpha2.VirtualMachineClusterInstancetype](instancetypeBundlePath) + if err != nil { + return nil, err + } + virtualMachineClusterPreferences, err := fetchClusterResources[instancetypev1alpha2.VirtualMachineClusterPreference](preferenceBundlePath) + if err != nil { + return nil, err + } + return &commonInstancetypes{ + virtualMachineClusterInstancetypes: virtualMachineClusterInstancetypes, + virtualMachineClusterPreferences: virtualMachineClusterPreferences, + }, nil +} + +func (c *commonInstancetypes) Name() string { + return operandName +} + +func (c *commonInstancetypes) WatchClusterTypes() []operands.WatchType { + return []operands.WatchType{ + {Object: &instancetypev1alpha2.VirtualMachineClusterInstancetype{}, Crd: instancetypeapi.ClusterPluralResourceName, WatchFullObject: true}, + {Object: &instancetypev1alpha2.VirtualMachineClusterPreference{}, Crd: instancetypeapi.ClusterPluralPreferenceResourceName, WatchFullObject: true}, + } +} + +func (c *commonInstancetypes) WatchTypes() []operands.WatchType { + return nil +} + +func (c *commonInstancetypes) RequiredCrds() []string { + return nil +} + +func (c *commonInstancetypes) Reconcile(request *common.Request) ([]common.ReconcileResult, error) { + request.Logger.Info("Reconciling common-instancetypes") + return common.CollectResourceStatus(request, c.reconcileFuncs()...) +} + +func (c *commonInstancetypes) Cleanup(request *common.Request) ([]common.CleanupResult, error) { + return nil, nil +} + +func (c *commonInstancetypes) reconcileFuncs() []common.ReconcileFunc { + funcs := []common.ReconcileFunc{} + funcs = append(funcs, c.reconcileVirtualMachineClusterInstancetypesFuncs()...) + funcs = append(funcs, c.reconcileVirtualMachineClusterPreferencesFuncs()...) + return funcs +} + +func (c *commonInstancetypes) reconcileVirtualMachineClusterInstancetypesFuncs() []common.ReconcileFunc { + funcs := make([]common.ReconcileFunc, 0, len(c.virtualMachineClusterInstancetypes)) + for i := range c.virtualMachineClusterInstancetypes { + clusterInstancetype := &c.virtualMachineClusterInstancetypes[i] + funcs = append(funcs, func(request *common.Request) (common.ReconcileResult, error) { + return common.CreateOrUpdate(request). + ClusterResource(clusterInstancetype). + WithAppLabels(operandName, operandComponent). + UpdateFunc(func(newRes, foundRes client.Object) { + foundRes.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec = newRes.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec + }). + ImmutableSpec(func(resource client.Object) interface{} { + return resource.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec + }). + Reconcile() + }) + } + return funcs +} + +func (c *commonInstancetypes) reconcileVirtualMachineClusterPreferencesFuncs() []common.ReconcileFunc { + funcs := make([]common.ReconcileFunc, 0, len(c.virtualMachineClusterPreferences)) + for i := range c.virtualMachineClusterPreferences { + clusterPreference := &c.virtualMachineClusterPreferences[i] + funcs = append(funcs, func(request *common.Request) (common.ReconcileResult, error) { + return common.CreateOrUpdate(request). + ClusterResource(clusterPreference). + WithAppLabels(operandName, operandComponent). + UpdateFunc(func(newRes, foundRes client.Object) { + foundRes.(*instancetypev1alpha2.VirtualMachineClusterPreference).Spec = newRes.(*instancetypev1alpha2.VirtualMachineClusterPreference).Spec + }). + ImmutableSpec(func(resource client.Object) interface{} { + return resource.(*instancetypev1alpha2.VirtualMachineClusterPreference).Spec + }). + Reconcile() + }) + } + return funcs +} diff --git a/internal/operands/common-instancetypes/reconcile_test.go b/internal/operands/common-instancetypes/reconcile_test.go new file mode 100644 index 000000000..1ee330fda --- /dev/null +++ b/internal/operands/common-instancetypes/reconcile_test.go @@ -0,0 +1,94 @@ +package common_instancetypes + +import ( + "context" + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + + instancetypev1alpha2 "kubevirt.io/api/instancetype/v1alpha2" + ssp "kubevirt.io/ssp-operator/api/v1beta1" + "kubevirt.io/ssp-operator/internal/common" + "kubevirt.io/ssp-operator/internal/operands" + . "kubevirt.io/ssp-operator/internal/test-utils" +) + +var log = logf.Log.WithName("common-instancetypes-operand") + +func TestInstancetypes(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Common Instance types Suite") +} + +var _ = Describe("Common-Instancetypes operand", func() { + + var ( + err error + operand operands.Operand + request common.Request + ) + + const ( + namespace = "kubevirt" + name = "test-ssp" + instancetypePath = "../../../" + BundleDir + ClusterInstancetypesBundlePrefix + ".yaml" + preferencePath = "../../../" + BundleDir + ClusterPreferencesBundlePrefix + ".yaml" + ) + + BeforeEach(func() { + operand, err = New(instancetypePath, preferencePath) + Expect(err).ToNot(HaveOccurred()) + + client := fake.NewFakeClientWithScheme(common.Scheme) + request = common.Request{ + Request: reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: namespace, + Name: name, + }, + }, + Client: client, + Context: context.Background(), + Instance: &ssp.SSP{ + TypeMeta: metav1.TypeMeta{ + Kind: "SSP", + APIVersion: ssp.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + }, + Logger: log, + VersionCache: common.VersionCache{}, + } + }) + + It("should create common-instancetypes resources", func() { + _, err := operand.Reconcile(&request) + Expect(err).ToNot(HaveOccurred()) + + virtualMachineClusterInstancetypes, err := fetchClusterResources[instancetypev1alpha2.VirtualMachineClusterInstancetype](instancetypePath) + Expect(err).ToNot(HaveOccurred()) + Expect(virtualMachineClusterInstancetypes).ToNot(BeEmpty()) + + virtualMachineClusterPreferences, err := fetchClusterResources[instancetypev1alpha2.VirtualMachineClusterPreference](preferencePath) + Expect(err).ToNot(HaveOccurred()) + Expect(virtualMachineClusterPreferences).ToNot(BeEmpty()) + + for _, instancetype := range virtualMachineClusterInstancetypes { + ExpectResourceExists(&instancetype, request) + } + + for _, preference := range virtualMachineClusterPreferences { + ExpectResourceExists(&preference, request) + } + }) +}) diff --git a/vendor/kubevirt.io/api/instancetype/register.go b/vendor/kubevirt.io/api/instancetype/register.go new file mode 100644 index 000000000..593516664 --- /dev/null +++ b/vendor/kubevirt.io/api/instancetype/register.go @@ -0,0 +1,37 @@ +/* + * This file is part of the KubeVirt project + * + * 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. + * + * Copyright 2021 Red Hat, Inc. + * + */ + +package instancetype + +// GroupName is the group name used in this package +const ( + GroupName = "instancetype.kubevirt.io" + + SingularResourceName = "virtualmachineinstancetype" + PluralResourceName = SingularResourceName + "s" + + ClusterSingularResourceName = "virtualmachineclusterinstancetype" + ClusterPluralResourceName = ClusterSingularResourceName + "s" + + SingularPreferenceResourceName = "virtualmachinepreference" + PluralPreferenceResourceName = SingularPreferenceResourceName + "s" + + ClusterSingularPreferenceResourceName = "virtualmachineclusterpreference" + ClusterPluralPreferenceResourceName = ClusterSingularPreferenceResourceName + "s" +) diff --git a/vendor/kubevirt.io/api/instancetype/v1alpha2/deepcopy_generated.go b/vendor/kubevirt.io/api/instancetype/v1alpha2/deepcopy_generated.go new file mode 100644 index 000000000..0c35cf161 --- /dev/null +++ b/vendor/kubevirt.io/api/instancetype/v1alpha2/deepcopy_generated.go @@ -0,0 +1,627 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2022 The KubeVirt Authors. + +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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + v1 "kubevirt.io/api/core/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CPUInstancetype) DeepCopyInto(out *CPUInstancetype) { + *out = *in + if in.NUMA != nil { + in, out := &in.NUMA, &out.NUMA + *out = new(v1.NUMA) + (*in).DeepCopyInto(*out) + } + if in.Realtime != nil { + in, out := &in.Realtime, &out.Realtime + *out = new(v1.Realtime) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CPUInstancetype. +func (in *CPUInstancetype) DeepCopy() *CPUInstancetype { + if in == nil { + return nil + } + out := new(CPUInstancetype) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CPUPreferences) DeepCopyInto(out *CPUPreferences) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CPUPreferences. +func (in *CPUPreferences) DeepCopy() *CPUPreferences { + if in == nil { + return nil + } + out := new(CPUPreferences) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClockPreferences) DeepCopyInto(out *ClockPreferences) { + *out = *in + if in.PreferredClockOffset != nil { + in, out := &in.PreferredClockOffset, &out.PreferredClockOffset + *out = new(v1.ClockOffset) + (*in).DeepCopyInto(*out) + } + if in.PreferredTimer != nil { + in, out := &in.PreferredTimer, &out.PreferredTimer + *out = new(v1.Timer) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClockPreferences. +func (in *ClockPreferences) DeepCopy() *ClockPreferences { + if in == nil { + return nil + } + out := new(ClockPreferences) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevicePreferences) DeepCopyInto(out *DevicePreferences) { + *out = *in + if in.PreferredAutoattachGraphicsDevice != nil { + in, out := &in.PreferredAutoattachGraphicsDevice, &out.PreferredAutoattachGraphicsDevice + *out = new(bool) + **out = **in + } + if in.PreferredAutoattachMemBalloon != nil { + in, out := &in.PreferredAutoattachMemBalloon, &out.PreferredAutoattachMemBalloon + *out = new(bool) + **out = **in + } + if in.PreferredAutoattachPodInterface != nil { + in, out := &in.PreferredAutoattachPodInterface, &out.PreferredAutoattachPodInterface + *out = new(bool) + **out = **in + } + if in.PreferredAutoattachSerialConsole != nil { + in, out := &in.PreferredAutoattachSerialConsole, &out.PreferredAutoattachSerialConsole + *out = new(bool) + **out = **in + } + if in.PreferredAutoattachInputDevice != nil { + in, out := &in.PreferredAutoattachInputDevice, &out.PreferredAutoattachInputDevice + *out = new(bool) + **out = **in + } + if in.PreferredDisableHotplug != nil { + in, out := &in.PreferredDisableHotplug, &out.PreferredDisableHotplug + *out = new(bool) + **out = **in + } + if in.PreferredVirtualGPUOptions != nil { + in, out := &in.PreferredVirtualGPUOptions, &out.PreferredVirtualGPUOptions + *out = new(v1.VGPUOptions) + (*in).DeepCopyInto(*out) + } + if in.PreferredUseVirtioTransitional != nil { + in, out := &in.PreferredUseVirtioTransitional, &out.PreferredUseVirtioTransitional + *out = new(bool) + **out = **in + } + if in.PreferredDiskDedicatedIoThread != nil { + in, out := &in.PreferredDiskDedicatedIoThread, &out.PreferredDiskDedicatedIoThread + *out = new(bool) + **out = **in + } + if in.PreferredDiskBlockSize != nil { + in, out := &in.PreferredDiskBlockSize, &out.PreferredDiskBlockSize + *out = new(v1.BlockSize) + (*in).DeepCopyInto(*out) + } + if in.PreferredRng != nil { + in, out := &in.PreferredRng, &out.PreferredRng + *out = new(v1.Rng) + **out = **in + } + if in.PreferredBlockMultiQueue != nil { + in, out := &in.PreferredBlockMultiQueue, &out.PreferredBlockMultiQueue + *out = new(bool) + **out = **in + } + if in.PreferredNetworkInterfaceMultiQueue != nil { + in, out := &in.PreferredNetworkInterfaceMultiQueue, &out.PreferredNetworkInterfaceMultiQueue + *out = new(bool) + **out = **in + } + if in.PreferredTPM != nil { + in, out := &in.PreferredTPM, &out.PreferredTPM + *out = new(v1.TPMDevice) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevicePreferences. +func (in *DevicePreferences) DeepCopy() *DevicePreferences { + if in == nil { + return nil + } + out := new(DevicePreferences) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FeaturePreferences) DeepCopyInto(out *FeaturePreferences) { + *out = *in + if in.PreferredAcpi != nil { + in, out := &in.PreferredAcpi, &out.PreferredAcpi + *out = new(v1.FeatureState) + (*in).DeepCopyInto(*out) + } + if in.PreferredApic != nil { + in, out := &in.PreferredApic, &out.PreferredApic + *out = new(v1.FeatureAPIC) + (*in).DeepCopyInto(*out) + } + if in.PreferredHyperv != nil { + in, out := &in.PreferredHyperv, &out.PreferredHyperv + *out = new(v1.FeatureHyperv) + (*in).DeepCopyInto(*out) + } + if in.PreferredKvm != nil { + in, out := &in.PreferredKvm, &out.PreferredKvm + *out = new(v1.FeatureKVM) + **out = **in + } + if in.PreferredPvspinlock != nil { + in, out := &in.PreferredPvspinlock, &out.PreferredPvspinlock + *out = new(v1.FeatureState) + (*in).DeepCopyInto(*out) + } + if in.PreferredSmm != nil { + in, out := &in.PreferredSmm, &out.PreferredSmm + *out = new(v1.FeatureState) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeaturePreferences. +func (in *FeaturePreferences) DeepCopy() *FeaturePreferences { + if in == nil { + return nil + } + out := new(FeaturePreferences) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FirmwarePreferences) DeepCopyInto(out *FirmwarePreferences) { + *out = *in + if in.PreferredUseBios != nil { + in, out := &in.PreferredUseBios, &out.PreferredUseBios + *out = new(bool) + **out = **in + } + if in.PreferredUseBiosSerial != nil { + in, out := &in.PreferredUseBiosSerial, &out.PreferredUseBiosSerial + *out = new(bool) + **out = **in + } + if in.PreferredUseEfi != nil { + in, out := &in.PreferredUseEfi, &out.PreferredUseEfi + *out = new(bool) + **out = **in + } + if in.PreferredUseSecureBoot != nil { + in, out := &in.PreferredUseSecureBoot, &out.PreferredUseSecureBoot + *out = new(bool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirmwarePreferences. +func (in *FirmwarePreferences) DeepCopy() *FirmwarePreferences { + if in == nil { + return nil + } + out := new(FirmwarePreferences) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MachinePreferences) DeepCopyInto(out *MachinePreferences) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MachinePreferences. +func (in *MachinePreferences) DeepCopy() *MachinePreferences { + if in == nil { + return nil + } + out := new(MachinePreferences) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MemoryInstancetype) DeepCopyInto(out *MemoryInstancetype) { + *out = *in + out.Guest = in.Guest.DeepCopy() + if in.Hugepages != nil { + in, out := &in.Hugepages, &out.Hugepages + *out = new(v1.Hugepages) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MemoryInstancetype. +func (in *MemoryInstancetype) DeepCopy() *MemoryInstancetype { + if in == nil { + return nil + } + out := new(MemoryInstancetype) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineClusterInstancetype) DeepCopyInto(out *VirtualMachineClusterInstancetype) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineClusterInstancetype. +func (in *VirtualMachineClusterInstancetype) DeepCopy() *VirtualMachineClusterInstancetype { + if in == nil { + return nil + } + out := new(VirtualMachineClusterInstancetype) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachineClusterInstancetype) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineClusterInstancetypeList) DeepCopyInto(out *VirtualMachineClusterInstancetypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualMachineClusterInstancetype, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineClusterInstancetypeList. +func (in *VirtualMachineClusterInstancetypeList) DeepCopy() *VirtualMachineClusterInstancetypeList { + if in == nil { + return nil + } + out := new(VirtualMachineClusterInstancetypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachineClusterInstancetypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineClusterPreference) DeepCopyInto(out *VirtualMachineClusterPreference) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineClusterPreference. +func (in *VirtualMachineClusterPreference) DeepCopy() *VirtualMachineClusterPreference { + if in == nil { + return nil + } + out := new(VirtualMachineClusterPreference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachineClusterPreference) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineClusterPreferenceList) DeepCopyInto(out *VirtualMachineClusterPreferenceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualMachineClusterPreference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineClusterPreferenceList. +func (in *VirtualMachineClusterPreferenceList) DeepCopy() *VirtualMachineClusterPreferenceList { + if in == nil { + return nil + } + out := new(VirtualMachineClusterPreferenceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachineClusterPreferenceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineInstancetype) DeepCopyInto(out *VirtualMachineInstancetype) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineInstancetype. +func (in *VirtualMachineInstancetype) DeepCopy() *VirtualMachineInstancetype { + if in == nil { + return nil + } + out := new(VirtualMachineInstancetype) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachineInstancetype) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineInstancetypeList) DeepCopyInto(out *VirtualMachineInstancetypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualMachineInstancetype, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineInstancetypeList. +func (in *VirtualMachineInstancetypeList) DeepCopy() *VirtualMachineInstancetypeList { + if in == nil { + return nil + } + out := new(VirtualMachineInstancetypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachineInstancetypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachineInstancetypeSpec) DeepCopyInto(out *VirtualMachineInstancetypeSpec) { + *out = *in + in.CPU.DeepCopyInto(&out.CPU) + in.Memory.DeepCopyInto(&out.Memory) + if in.GPUs != nil { + in, out := &in.GPUs, &out.GPUs + *out = make([]v1.GPU, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.HostDevices != nil { + in, out := &in.HostDevices, &out.HostDevices + *out = make([]v1.HostDevice, len(*in)) + copy(*out, *in) + } + if in.IOThreadsPolicy != nil { + in, out := &in.IOThreadsPolicy, &out.IOThreadsPolicy + *out = new(v1.IOThreadsPolicy) + **out = **in + } + if in.LaunchSecurity != nil { + in, out := &in.LaunchSecurity, &out.LaunchSecurity + *out = new(v1.LaunchSecurity) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachineInstancetypeSpec. +func (in *VirtualMachineInstancetypeSpec) DeepCopy() *VirtualMachineInstancetypeSpec { + if in == nil { + return nil + } + out := new(VirtualMachineInstancetypeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachinePreference) DeepCopyInto(out *VirtualMachinePreference) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachinePreference. +func (in *VirtualMachinePreference) DeepCopy() *VirtualMachinePreference { + if in == nil { + return nil + } + out := new(VirtualMachinePreference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachinePreference) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachinePreferenceList) DeepCopyInto(out *VirtualMachinePreferenceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualMachinePreference, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachinePreferenceList. +func (in *VirtualMachinePreferenceList) DeepCopy() *VirtualMachinePreferenceList { + if in == nil { + return nil + } + out := new(VirtualMachinePreferenceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualMachinePreferenceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualMachinePreferenceSpec) DeepCopyInto(out *VirtualMachinePreferenceSpec) { + *out = *in + if in.Clock != nil { + in, out := &in.Clock, &out.Clock + *out = new(ClockPreferences) + (*in).DeepCopyInto(*out) + } + if in.CPU != nil { + in, out := &in.CPU, &out.CPU + *out = new(CPUPreferences) + **out = **in + } + if in.Devices != nil { + in, out := &in.Devices, &out.Devices + *out = new(DevicePreferences) + (*in).DeepCopyInto(*out) + } + if in.Features != nil { + in, out := &in.Features, &out.Features + *out = new(FeaturePreferences) + (*in).DeepCopyInto(*out) + } + if in.Firmware != nil { + in, out := &in.Firmware, &out.Firmware + *out = new(FirmwarePreferences) + (*in).DeepCopyInto(*out) + } + if in.Machine != nil { + in, out := &in.Machine, &out.Machine + *out = new(MachinePreferences) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachinePreferenceSpec. +func (in *VirtualMachinePreferenceSpec) DeepCopy() *VirtualMachinePreferenceSpec { + if in == nil { + return nil + } + out := new(VirtualMachinePreferenceSpec) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/kubevirt.io/api/instancetype/v1alpha2/doc.go b/vendor/kubevirt.io/api/instancetype/v1alpha2/doc.go new file mode 100644 index 000000000..6e1cb4ed0 --- /dev/null +++ b/vendor/kubevirt.io/api/instancetype/v1alpha2/doc.go @@ -0,0 +1,24 @@ +/* + * This file is part of the KubeVirt project + * + * 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. + * + * Copyright 2022 Red Hat, Inc. + * + */ + +// +k8s:deepcopy-gen=package +// +groupName=instancetype.kubevirt.io +// +k8s:openapi-gen=true + +package v1alpha2 diff --git a/vendor/kubevirt.io/api/instancetype/v1alpha2/register.go b/vendor/kubevirt.io/api/instancetype/v1alpha2/register.go new file mode 100644 index 000000000..ccde39c44 --- /dev/null +++ b/vendor/kubevirt.io/api/instancetype/v1alpha2/register.go @@ -0,0 +1,64 @@ +/* + * This file is part of the KubeVirt project + * + * 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. + * + * Copyright 2022 Red Hat, Inc. + * + */ + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "kubevirt.io/api/instancetype" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: instancetype.GroupName, Version: "v1alpha2"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder initializes a scheme builder + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a global function that registers this API group & version to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &VirtualMachineInstancetype{}, + &VirtualMachineInstancetypeList{}, + &VirtualMachineClusterInstancetype{}, + &VirtualMachineClusterInstancetypeList{}, + &VirtualMachinePreference{}, + &VirtualMachinePreferenceList{}, + &VirtualMachineClusterPreference{}, + &VirtualMachineClusterPreferenceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/kubevirt.io/api/instancetype/v1alpha2/types.go b/vendor/kubevirt.io/api/instancetype/v1alpha2/types.go new file mode 100644 index 000000000..61cf6b135 --- /dev/null +++ b/vendor/kubevirt.io/api/instancetype/v1alpha2/types.go @@ -0,0 +1,463 @@ +/* + * This file is part of the KubeVirt project + * + * 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. + * + * Copyright 2022 Red Hat, Inc. + * + */ + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v1 "kubevirt.io/api/core/v1" + + "k8s.io/apimachinery/pkg/api/resource" +) + +// VirtualMachineInstancetype resource contains quantitative and resource related VirtualMachine configuration +// that can be used by multiple VirtualMachine resources. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +type VirtualMachineInstancetype struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Required spec describing the instancetype + Spec VirtualMachineInstancetypeSpec `json:"spec"` +} + +// VirtualMachineInstancetypeList is a list of VirtualMachineInstancetype resources. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type VirtualMachineInstancetypeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VirtualMachineInstancetype `json:"items"` +} + +// VirtualMachineClusterInstancetype is a cluster scoped version of VirtualMachineInstancetype resource. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced +type VirtualMachineClusterInstancetype struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Required spec describing the instancetype + Spec VirtualMachineInstancetypeSpec `json:"spec"` +} + +// VirtualMachineClusterInstancetypeList is a list of VirtualMachineClusterInstancetype resources. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type VirtualMachineClusterInstancetypeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []VirtualMachineClusterInstancetype `json:"items"` +} + +// VirtualMachineInstancetypeSpec is a description of the VirtualMachineInstancetype or VirtualMachineClusterInstancetype. +// +// CPU and Memory are required attributes with both requiring that their Guest attribute is defined, ensuring a number of vCPUs and amount of RAM is always provided by each instancetype. +type VirtualMachineInstancetypeSpec struct { + + // Required CPU related attributes of the instancetype. + CPU CPUInstancetype `json:"cpu"` + + // Required Memory related attributes of the instancetype. + Memory MemoryInstancetype `json:"memory"` + + // Optionally defines any GPU devices associated with the instancetype. + // + // +optional + // +listType=atomic + GPUs []v1.GPU `json:"gpus,omitempty"` + + // Optionally defines any HostDevices associated with the instancetype. + // + // +optional + // +listType=atomic + HostDevices []v1.HostDevice `json:"hostDevices,omitempty"` + + // Optionally defines the IOThreadsPolicy to be used by the instancetype. + // + // +optional + IOThreadsPolicy *v1.IOThreadsPolicy `json:"ioThreadsPolicy,omitempty"` + + // Optionally defines the LaunchSecurity to be used by the instancetype. + // + // +optional + LaunchSecurity *v1.LaunchSecurity `json:"launchSecurity,omitempty"` +} + +// CPUInstancetype contains the CPU related configuration of a given VirtualMachineInstancetypeSpec. +// +// Guest is a required attribute and defines the number of vCPUs to be exposed to the guest by the instancetype. +type CPUInstancetype struct { + + // Required number of vCPUs to expose to the guest. + // + // The resulting CPU topology being derived from the optional PreferredCPUTopology attribute of CPUPreferences that itself defaults to PreferCores. + Guest uint32 `json:"guest"` + + // Model specifies the CPU model inside the VMI. + // List of available models https://github.com/libvirt/libvirt/tree/master/src/cpu_map. + // It is possible to specify special cases like "host-passthrough" to get the same CPU as the node + // and "host-model" to get CPU closest to the node one. + // Defaults to host-model. + // +optional + Model string `json:"model,omitempty"` + + // DedicatedCPUPlacement requests the scheduler to place the VirtualMachineInstance on a node + // with enough dedicated pCPUs and pin the vCPUs to it. + // +optional + DedicatedCPUPlacement bool `json:"dedicatedCPUPlacement,omitempty"` + + // NUMA allows specifying settings for the guest NUMA topology + // +optional + NUMA *v1.NUMA `json:"numa,omitempty"` + + // IsolateEmulatorThread requests one more dedicated pCPU to be allocated for the VMI to place + // the emulator thread on it. + // +optional + IsolateEmulatorThread bool `json:"isolateEmulatorThread,omitempty"` + + // Realtime instructs the virt-launcher to tune the VMI for lower latency, optional for real time workloads + // +optional + Realtime *v1.Realtime `json:"realtime,omitempty"` +} + +// MemoryInstancetype contains the Memory related configuration of a given VirtualMachineInstancetypeSpec. +// +// Guest is a required attribute and defines the amount of RAM to be exposed to the guest by the instancetype. +type MemoryInstancetype struct { + + // Required amount of memory which is visible inside the guest OS. + Guest resource.Quantity `json:"guest"` + + // Optionally enables the use of hugepages for the VirtualMachineInstance instead of regular memory. + // +optional + Hugepages *v1.Hugepages `json:"hugepages,omitempty"` +} + +// VirtualMachinePreference resource contains optional preferences related to the VirtualMachine. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +type VirtualMachinePreference struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Required spec describing the preferences + Spec VirtualMachinePreferenceSpec `json:"spec"` +} + +// VirtualMachinePreferenceList is a list of VirtualMachinePreference resources. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type VirtualMachinePreferenceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // +listType=set + Items []VirtualMachinePreference `json:"items"` +} + +// VirtualMachineClusterPreference is a cluster scoped version of the VirtualMachinePreference resource. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +genclient +// +genclient:nonNamespaced +type VirtualMachineClusterPreference struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Required spec describing the preferences + Spec VirtualMachinePreferenceSpec `json:"spec"` +} + +// VirtualMachineClusterPreferenceList is a list of VirtualMachineClusterPreference resources. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type VirtualMachineClusterPreferenceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // +listType=set + Items []VirtualMachineClusterPreference `json:"items"` +} + +// VirtualMachinePreferenceSpec is a description of the VirtualMachinePreference or VirtualMachineClusterPreference. +type VirtualMachinePreferenceSpec struct { + + // Clock optionally defines preferences associated with the Clock attribute of a VirtualMachineInstance DomainSpec + // + //+optional + Clock *ClockPreferences `json:"clock,omitempty"` + + // CPU optionally defines preferences associated with the CPU attribute of a VirtualMachineInstance DomainSpec + // + //+optional + CPU *CPUPreferences `json:"cpu,omitempty"` + + // Devices optionally defines preferences associated with the Devices attribute of a VirtualMachineInstance DomainSpec + // + //+optional + Devices *DevicePreferences `json:"devices,omitempty"` + + // Features optionally defines preferences associated with the Features attribute of a VirtualMachineInstance DomainSpec + // + //+optional + Features *FeaturePreferences `json:"features,omitempty"` + + // Firmware optionally defines preferences associated with the Firmware attribute of a VirtualMachineInstance DomainSpec + // + //+optional + Firmware *FirmwarePreferences `json:"firmware,omitempty"` + + // Machine optionally defines preferences associated with the Machine attribute of a VirtualMachineInstance DomainSpec + // + //+optional + Machine *MachinePreferences `json:"machine,omitempty"` +} + +// PreferredCPUTopology defines a preferred CPU topology to be exposed to the guest +type PreferredCPUTopology string + +const ( + + // Prefer vCPUs to be exposed as cores to the guest + PreferCores PreferredCPUTopology = "preferCores" + + // Prefer vCPUs to be exposed as sockets to the guest, this is the default for the PreferredCPUTopology attribute of CPUPreferences. + PreferSockets PreferredCPUTopology = "preferSockets" + + // Prefer vCPUs to be exposed as threads to the guest + PreferThreads PreferredCPUTopology = "preferThreads" +) + +// CPUPreferences contains various optional CPU preferences. +type CPUPreferences struct { + + // PreferredCPUTopology optionally defines the preferred guest visible CPU topology, defaults to PreferSockets. + // + //+optional + PreferredCPUTopology PreferredCPUTopology `json:"preferredCPUTopology,omitempty"` +} + +// DevicePreferences contains various optional Device preferences. +type DevicePreferences struct { + + // PreferredAutoattachGraphicsDevice optionally defines the preferred value of AutoattachGraphicsDevice + // + // +optional + PreferredAutoattachGraphicsDevice *bool `json:"preferredAutoattachGraphicsDevice,omitempty"` + + // PreferredAutoattachMemBalloon optionally defines the preferred value of AutoattachMemBalloon + // + // +optional + PreferredAutoattachMemBalloon *bool `json:"preferredAutoattachMemBalloon,omitempty"` + + // PreferredAutoattachPodInterface optionally defines the preferred value of AutoattachPodInterface + // + // +optional + PreferredAutoattachPodInterface *bool `json:"preferredAutoattachPodInterface,omitempty"` + + // PreferredAutoattachSerialConsole optionally defines the preferred value of AutoattachSerialConsole + // + // +optional + PreferredAutoattachSerialConsole *bool `json:"preferredAutoattachSerialConsole,omitempty"` + + // PreferredAutoattachInputDevice optionally defines the preferred value of AutoattachInputDevice + // + // +optional + PreferredAutoattachInputDevice *bool `json:"preferredAutoattachInputDevice,omitempty"` + + // PreferredDisableHotplug optionally defines the preferred value of DisableHotplug + // + // +optional + PreferredDisableHotplug *bool `json:"preferredDisableHotplug,omitempty"` + + // PreferredVirtualGPUOptions optionally defines the preferred value of VirtualGPUOptions + // + // +optional + PreferredVirtualGPUOptions *v1.VGPUOptions `json:"preferredVirtualGPUOptions,omitempty"` + + // PreferredSoundModel optionally defines the preferred model for Sound devices. + // + // +optional + PreferredSoundModel string `json:"preferredSoundModel,omitempty"` + + // PreferredUseVirtioTransitional optionally defines the preferred value of UseVirtioTransitional + // + // +optional + PreferredUseVirtioTransitional *bool `json:"preferredUseVirtioTransitional,omitempty"` + + // PreferredInputBus optionally defines the preferred bus for Input devices. + // + // +optional + PreferredInputBus v1.InputBus `json:"preferredInputBus,omitempty"` + + // PreferredInputType optionally defines the preferred type for Input devices. + // + // +optional + PreferredInputType v1.InputType `json:"preferredInputType,omitempty"` + + // PreferredDiskBus optionally defines the preferred bus for Disk Disk devices. + // + // +optional + PreferredDiskBus v1.DiskBus `json:"preferredDiskBus,omitempty"` + + // PreferredLunBus optionally defines the preferred bus for Lun Disk devices. + // + // +optional + PreferredLunBus v1.DiskBus `json:"preferredLunBus,omitempty"` + + // PreferredCdromBus optionally defines the preferred bus for Cdrom Disk devices. + // + // +optional + PreferredCdromBus v1.DiskBus `json:"preferredCdromBus,omitempty"` + + // PreferredDedicatedIoThread optionally enables dedicated IO threads for Disk devices. + // + // +optional + PreferredDiskDedicatedIoThread *bool `json:"preferredDiskDedicatedIoThread,omitempty"` + + // PreferredCache optionally defines the DriverCache to be used by Disk devices. + // + // +optional + PreferredDiskCache v1.DriverCache `json:"preferredDiskCache,omitempty"` + + // PreferredIo optionally defines the QEMU disk IO mode to be used by Disk devices. + // + // +optional + PreferredDiskIO v1.DriverIO `json:"preferredDiskIO,omitempty"` + + // PreferredBlockSize optionally defines the block size of Disk devices. + // + // +optional + PreferredDiskBlockSize *v1.BlockSize `json:"preferredDiskBlockSize,omitempty"` + + // PreferredInterfaceModel optionally defines the preferred model to be used by Interface devices. + // + // +optional + PreferredInterfaceModel string `json:"preferredInterfaceModel,omitempty"` + + // PreferredRng optionally defines the preferred rng device to be used. + // + // +optional + PreferredRng *v1.Rng `json:"preferredRng,omitempty"` + + // PreferredBlockMultiQueue optionally enables the vhost multiqueue feature for virtio disks. + // + // +optional + PreferredBlockMultiQueue *bool `json:"preferredBlockMultiQueue,omitempty"` + + // PreferredNetworkInterfaceMultiQueue optionally enables the vhost multiqueue feature for virtio interfaces. + // + // +optional + PreferredNetworkInterfaceMultiQueue *bool `json:"preferredNetworkInterfaceMultiQueue,omitempty"` + + // PreferredTPM optionally defines the preferred TPM device to be used. + // + // +optional + PreferredTPM *v1.TPMDevice `json:"preferredTPM,omitempty"` +} + +// FeaturePreferences contains various optional defaults for Features. +type FeaturePreferences struct { + + // PreferredAcpi optionally enables the ACPI feature + // + // +optional + PreferredAcpi *v1.FeatureState `json:"preferredAcpi,omitempty"` + + // PreferredApic optionally enables and configures the APIC feature + // + // +optional + PreferredApic *v1.FeatureAPIC `json:"preferredApic,omitempty"` + + // PreferredHyperv optionally enables and configures HyperV features + // + // +optional + PreferredHyperv *v1.FeatureHyperv `json:"preferredHyperv,omitempty"` + + // PreferredKvm optionally enables and configures KVM features + // + // +optional + PreferredKvm *v1.FeatureKVM `json:"preferredKvm,omitempty"` + + // PreferredPvspinlock optionally enables the Pvspinlock feature + // + // +optional + PreferredPvspinlock *v1.FeatureState `json:"preferredPvspinlock,omitempty"` + + // PreferredSmm optionally enables the SMM feature + // + // +optional + PreferredSmm *v1.FeatureState `json:"preferredSmm,omitempty"` +} + +// FirmwarePreferences contains various optional defaults for Firmware. +type FirmwarePreferences struct { + + // PreferredUseBios optionally enables BIOS + // + // +optional + PreferredUseBios *bool `json:"preferredUseBios,omitempty"` + + // PreferredUseBiosSerial optionally transmitts BIOS output over the serial. + // + // Requires PreferredUseBios to be enabled. + // + // +optional + PreferredUseBiosSerial *bool `json:"preferredUseBiosSerial,omitempty"` + + // PreferredUseEfi optionally enables EFI + // + // +optional + PreferredUseEfi *bool `json:"preferredUseEfi,omitempty"` + + // PreferredUseSecureBoot optionally enables SecureBoot and the OVMF roms will be swapped for SecureBoot-enabled ones. + // + // Requires PreferredUseEfi and PreferredSmm to be enabled. + // + // +optional + PreferredUseSecureBoot *bool `json:"preferredUseSecureBoot,omitempty"` +} + +// MachinePreferences contains various optional defaults for Machine. +type MachinePreferences struct { + + // PreferredMachineType optionally defines the preferred machine type to use. + // + // +optional + PreferredMachineType string `json:"preferredMachineType,omitempty"` +} + +// ClockPreferences contains various optional defaults for Clock. +type ClockPreferences struct { + + // ClockOffset allows specifying the UTC offset or the timezone of the guest clock. + // + // +optional + PreferredClockOffset *v1.ClockOffset `json:"preferredClockOffset,omitempty"` + + // Timer specifies whih timers are attached to the vmi. + // + // +optional + PreferredTimer *v1.Timer `json:"preferredTimer,omitempty"` +} diff --git a/vendor/kubevirt.io/api/instancetype/v1alpha2/types_swagger_generated.go b/vendor/kubevirt.io/api/instancetype/v1alpha2/types_swagger_generated.go new file mode 100644 index 000000000..31d187d33 --- /dev/null +++ b/vendor/kubevirt.io/api/instancetype/v1alpha2/types_swagger_generated.go @@ -0,0 +1,174 @@ +// Code generated by swagger-doc. DO NOT EDIT. + +package v1alpha2 + +func (VirtualMachineInstancetype) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineInstancetype resource contains quantitative and resource related VirtualMachine configuration\nthat can be used by multiple VirtualMachine resources.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+genclient", + "spec": "Required spec describing the instancetype", + } +} + +func (VirtualMachineInstancetypeList) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineInstancetypeList is a list of VirtualMachineInstancetype resources.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object", + } +} + +func (VirtualMachineClusterInstancetype) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineClusterInstancetype is a cluster scoped version of VirtualMachineInstancetype resource.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+genclient\n+genclient:nonNamespaced", + "spec": "Required spec describing the instancetype", + } +} + +func (VirtualMachineClusterInstancetypeList) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineClusterInstancetypeList is a list of VirtualMachineClusterInstancetype resources.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object", + } +} + +func (VirtualMachineInstancetypeSpec) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineInstancetypeSpec is a description of the VirtualMachineInstancetype or VirtualMachineClusterInstancetype.\n\nCPU and Memory are required attributes with both requiring that their Guest attribute is defined, ensuring a number of vCPUs and amount of RAM is always provided by each instancetype.", + "cpu": "Required CPU related attributes of the instancetype.", + "memory": "Required Memory related attributes of the instancetype.", + "gpus": "Optionally defines any GPU devices associated with the instancetype.\n\n+optional\n+listType=atomic", + "hostDevices": "Optionally defines any HostDevices associated with the instancetype.\n\n+optional\n+listType=atomic", + "ioThreadsPolicy": "Optionally defines the IOThreadsPolicy to be used by the instancetype.\n\n+optional", + "launchSecurity": "Optionally defines the LaunchSecurity to be used by the instancetype.\n\n+optional", + } +} + +func (CPUInstancetype) SwaggerDoc() map[string]string { + return map[string]string{ + "": "CPUInstancetype contains the CPU related configuration of a given VirtualMachineInstancetypeSpec.\n\nGuest is a required attribute and defines the number of vCPUs to be exposed to the guest by the instancetype.", + "guest": "Required number of vCPUs to expose to the guest.\n\nThe resulting CPU topology being derived from the optional PreferredCPUTopology attribute of CPUPreferences that itself defaults to PreferCores.", + "model": "Model specifies the CPU model inside the VMI.\nList of available models https://github.com/libvirt/libvirt/tree/master/src/cpu_map.\nIt is possible to specify special cases like \"host-passthrough\" to get the same CPU as the node\nand \"host-model\" to get CPU closest to the node one.\nDefaults to host-model.\n+optional", + "dedicatedCPUPlacement": "DedicatedCPUPlacement requests the scheduler to place the VirtualMachineInstance on a node\nwith enough dedicated pCPUs and pin the vCPUs to it.\n+optional", + "numa": "NUMA allows specifying settings for the guest NUMA topology\n+optional", + "isolateEmulatorThread": "IsolateEmulatorThread requests one more dedicated pCPU to be allocated for the VMI to place\nthe emulator thread on it.\n+optional", + "realtime": "Realtime instructs the virt-launcher to tune the VMI for lower latency, optional for real time workloads\n+optional", + } +} + +func (MemoryInstancetype) SwaggerDoc() map[string]string { + return map[string]string{ + "": "MemoryInstancetype contains the Memory related configuration of a given VirtualMachineInstancetypeSpec.\n\nGuest is a required attribute and defines the amount of RAM to be exposed to the guest by the instancetype.", + "guest": "Required amount of memory which is visible inside the guest OS.", + "hugepages": "Optionally enables the use of hugepages for the VirtualMachineInstance instead of regular memory.\n+optional", + } +} + +func (VirtualMachinePreference) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachinePreference resource contains optional preferences related to the VirtualMachine.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+genclient", + "spec": "Required spec describing the preferences", + } +} + +func (VirtualMachinePreferenceList) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachinePreferenceList is a list of VirtualMachinePreference resources.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object", + "items": "+listType=set", + } +} + +func (VirtualMachineClusterPreference) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineClusterPreference is a cluster scoped version of the VirtualMachinePreference resource.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+genclient\n+genclient:nonNamespaced", + "spec": "Required spec describing the preferences", + } +} + +func (VirtualMachineClusterPreferenceList) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachineClusterPreferenceList is a list of VirtualMachineClusterPreference resources.\n\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object", + "items": "+listType=set", + } +} + +func (VirtualMachinePreferenceSpec) SwaggerDoc() map[string]string { + return map[string]string{ + "": "VirtualMachinePreferenceSpec is a description of the VirtualMachinePreference or VirtualMachineClusterPreference.", + "clock": "Clock optionally defines preferences associated with the Clock attribute of a VirtualMachineInstance DomainSpec\n\n+optional", + "cpu": "CPU optionally defines preferences associated with the CPU attribute of a VirtualMachineInstance DomainSpec\n\n+optional", + "devices": "Devices optionally defines preferences associated with the Devices attribute of a VirtualMachineInstance DomainSpec\n\n+optional", + "features": "Features optionally defines preferences associated with the Features attribute of a VirtualMachineInstance DomainSpec\n\n+optional", + "firmware": "Firmware optionally defines preferences associated with the Firmware attribute of a VirtualMachineInstance DomainSpec\n\n+optional", + "machine": "Machine optionally defines preferences associated with the Machine attribute of a VirtualMachineInstance DomainSpec\n\n+optional", + } +} + +func (CPUPreferences) SwaggerDoc() map[string]string { + return map[string]string{ + "": "CPUPreferences contains various optional CPU preferences.", + "preferredCPUTopology": "PreferredCPUTopology optionally defines the preferred guest visible CPU topology, defaults to PreferSockets.\n\n+optional", + } +} + +func (DevicePreferences) SwaggerDoc() map[string]string { + return map[string]string{ + "": "DevicePreferences contains various optional Device preferences.", + "preferredAutoattachGraphicsDevice": "PreferredAutoattachGraphicsDevice optionally defines the preferred value of AutoattachGraphicsDevice\n\n+optional", + "preferredAutoattachMemBalloon": "PreferredAutoattachMemBalloon optionally defines the preferred value of AutoattachMemBalloon\n\n+optional", + "preferredAutoattachPodInterface": "PreferredAutoattachPodInterface optionally defines the preferred value of AutoattachPodInterface\n\n+optional", + "preferredAutoattachSerialConsole": "PreferredAutoattachSerialConsole optionally defines the preferred value of AutoattachSerialConsole\n\n+optional", + "preferredAutoattachInputDevice": "PreferredAutoattachInputDevice optionally defines the preferred value of AutoattachInputDevice\n\n+optional", + "preferredDisableHotplug": "PreferredDisableHotplug optionally defines the preferred value of DisableHotplug\n\n+optional", + "preferredVirtualGPUOptions": "PreferredVirtualGPUOptions optionally defines the preferred value of VirtualGPUOptions\n\n+optional", + "preferredSoundModel": "PreferredSoundModel optionally defines the preferred model for Sound devices.\n\n+optional", + "preferredUseVirtioTransitional": "PreferredUseVirtioTransitional optionally defines the preferred value of UseVirtioTransitional\n\n+optional", + "preferredInputBus": "PreferredInputBus optionally defines the preferred bus for Input devices.\n\n+optional", + "preferredInputType": "PreferredInputType optionally defines the preferred type for Input devices.\n\n+optional", + "preferredDiskBus": "PreferredDiskBus optionally defines the preferred bus for Disk Disk devices.\n\n+optional", + "preferredLunBus": "PreferredLunBus optionally defines the preferred bus for Lun Disk devices.\n\n+optional", + "preferredCdromBus": "PreferredCdromBus optionally defines the preferred bus for Cdrom Disk devices.\n\n+optional", + "preferredDiskDedicatedIoThread": "PreferredDedicatedIoThread optionally enables dedicated IO threads for Disk devices.\n\n+optional", + "preferredDiskCache": "PreferredCache optionally defines the DriverCache to be used by Disk devices.\n\n+optional", + "preferredDiskIO": "PreferredIo optionally defines the QEMU disk IO mode to be used by Disk devices.\n\n+optional", + "preferredDiskBlockSize": "PreferredBlockSize optionally defines the block size of Disk devices.\n\n+optional", + "preferredInterfaceModel": "PreferredInterfaceModel optionally defines the preferred model to be used by Interface devices.\n\n+optional", + "preferredRng": "PreferredRng optionally defines the preferred rng device to be used.\n\n+optional", + "preferredBlockMultiQueue": "PreferredBlockMultiQueue optionally enables the vhost multiqueue feature for virtio disks.\n\n+optional", + "preferredNetworkInterfaceMultiQueue": "PreferredNetworkInterfaceMultiQueue optionally enables the vhost multiqueue feature for virtio interfaces.\n\n+optional", + "preferredTPM": "PreferredTPM optionally defines the preferred TPM device to be used.\n\n+optional", + } +} + +func (FeaturePreferences) SwaggerDoc() map[string]string { + return map[string]string{ + "": "FeaturePreferences contains various optional defaults for Features.", + "preferredAcpi": "PreferredAcpi optionally enables the ACPI feature\n\n+optional", + "preferredApic": "PreferredApic optionally enables and configures the APIC feature\n\n+optional", + "preferredHyperv": "PreferredHyperv optionally enables and configures HyperV features\n\n+optional", + "preferredKvm": "PreferredKvm optionally enables and configures KVM features\n\n+optional", + "preferredPvspinlock": "PreferredPvspinlock optionally enables the Pvspinlock feature\n\n+optional", + "preferredSmm": "PreferredSmm optionally enables the SMM feature\n\n+optional", + } +} + +func (FirmwarePreferences) SwaggerDoc() map[string]string { + return map[string]string{ + "": "FirmwarePreferences contains various optional defaults for Firmware.", + "preferredUseBios": "PreferredUseBios optionally enables BIOS\n\n+optional", + "preferredUseBiosSerial": "PreferredUseBiosSerial optionally transmitts BIOS output over the serial.\n\nRequires PreferredUseBios to be enabled.\n\n+optional", + "preferredUseEfi": "PreferredUseEfi optionally enables EFI\n\n+optional", + "preferredUseSecureBoot": "PreferredUseSecureBoot optionally enables SecureBoot and the OVMF roms will be swapped for SecureBoot-enabled ones.\n\nRequires PreferredUseEfi and PreferredSmm to be enabled.\n\n+optional", + } +} + +func (MachinePreferences) SwaggerDoc() map[string]string { + return map[string]string{ + "": "MachinePreferences contains various optional defaults for Machine.", + "preferredMachineType": "PreferredMachineType optionally defines the preferred machine type to use.\n\n+optional", + } +} + +func (ClockPreferences) SwaggerDoc() map[string]string { + return map[string]string{ + "": "ClockPreferences contains various optional defaults for Clock.", + "preferredClockOffset": "ClockOffset allows specifying the UTC offset or the timezone of the guest clock.\n\n+optional", + "preferredTimer": "Timer specifies whih timers are attached to the vmi.\n\n+optional", + } +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 52d3bc5ab..99aaf7d15 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -681,6 +681,8 @@ k8s.io/utils/trace ## explicit; go 1.17 kubevirt.io/api/core kubevirt.io/api/core/v1 +kubevirt.io/api/instancetype +kubevirt.io/api/instancetype/v1alpha2 # kubevirt.io/client-go v0.58.0 ## explicit; go 1.17 kubevirt.io/client-go/log