Skip to content

Commit 105c19f

Browse files
Merge pull request #1918 from nunnatsa/cache-kv-image
Cache KubeVirt Boot Image
2 parents 2bbe22d + 23aa969 commit 105c19f

28 files changed

Lines changed: 1496 additions & 234 deletions

api/fixtures/example_kubevirt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type ExampleKubevirtOptions struct {
2020
BaseDomainPassthrough bool
2121
InfraKubeConfig []byte
2222
InfraNamespace string
23+
CacheStrategyType string
2324
}
2425

2526
func ExampleKubeVirtTemplate(o *ExampleKubevirtOptions) *hyperv1.KubevirtNodePoolPlatform {
@@ -69,5 +70,12 @@ func ExampleKubeVirtTemplate(o *ExampleKubevirtOptions) *hyperv1.KubevirtNodePoo
6970
}
7071
}
7172

73+
strategyType := hyperv1.KubevirtCachingStrategyType(o.CacheStrategyType)
74+
if strategyType == hyperv1.KubevirtCachingStrategyNone || strategyType == hyperv1.KubevirtCachingStrategyPVC {
75+
exampleTemplate.RootVolume.CacheStrategy = &hyperv1.KubevirtCachingStrategy{
76+
Type: strategyType,
77+
}
78+
}
79+
7280
return exampleTemplate
7381
}

api/scheme.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"k8s.io/apimachinery/pkg/runtime/serializer/json"
2222
kasv1beta1 "k8s.io/apiserver/pkg/apis/apiserver/v1beta1"
2323
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
24+
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
2425
capiaws "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
2526
capiazure "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
2627
capiibm "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta1"
@@ -71,4 +72,5 @@ func init() {
7172
capiazure.AddToScheme(Scheme)
7273
snapshotv1.AddToScheme(Scheme)
7374
imagev1.AddToScheme(Scheme)
75+
cdiv1beta1.AddToScheme(Scheme)
7476
}

api/v1alpha1/nodepool_types.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ type NodePoolStatus struct {
184184
// +kubebuilder:validation:Optional
185185
Version string `json:"version,omitempty"`
186186

187+
// Platform hols the specific statuses
188+
Platform *NodePoolPlatformStatus `json:"platform,omitempty"`
189+
187190
// Conditions represents the latest available observations of the node pool's
188191
// current state.
189192
// +optional
@@ -552,6 +555,26 @@ type KubevirtPersistentVolume struct {
552555
AccessModes []PersistentVolumeAccessMode `json:"accessModes,omitempty"`
553556
}
554557

558+
// KubevirtCachingStrategyType is the type of the boot image caching mechanism for the KubeVirt provider
559+
type KubevirtCachingStrategyType string
560+
561+
const (
562+
// KubevirtCachingStrategyNone means that hypershift will not cache the boot image
563+
KubevirtCachingStrategyNone KubevirtCachingStrategyType = "None"
564+
565+
// KubevirtCachingStrategyPVC means that hypershift will cache the boot image into a PVC; only relevant when using
566+
// a QCOW boot image, and is ignored when using a container image
567+
KubevirtCachingStrategyPVC KubevirtCachingStrategyType = "PVC"
568+
)
569+
570+
// KubevirtCachingStrategy defines the boot image caching strategy
571+
type KubevirtCachingStrategy struct {
572+
// Type is the type of the caching strategy
573+
// +kubebuilder:default=None
574+
// +kubebuilder:validation:Enum=None;PVC
575+
Type KubevirtCachingStrategyType `json:"type"`
576+
}
577+
555578
// KubevirtRootVolume represents the volume that the rhcos disk will be stored and run from.
556579
type KubevirtRootVolume struct {
557580
// Image represents what rhcos image to use for the node pool
@@ -561,6 +584,10 @@ type KubevirtRootVolume struct {
561584

562585
// KubevirtVolume represents of type of storage to run the image on
563586
KubevirtVolume `json:",inline"`
587+
588+
// CacheStrategy defines the boot image caching strategy. Default - no caching
589+
// +optional
590+
CacheStrategy *KubevirtCachingStrategy `json:"cacheStrategy,omitempty"`
564591
}
565592

566593
// KubevirtVolumeType is a specific supported KubeVirt volumes
@@ -790,6 +817,24 @@ type NodePoolCondition struct {
790817
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
791818
}
792819

820+
// NodePoolPlatformStatus contains specific platform statuses
821+
type NodePoolPlatformStatus struct {
822+
// KubeVirt contains the KubeVirt platform statuses
823+
// +optional
824+
KubeVirt *KubeVirtNodePoolStatus `json:"kubeVirt,omitempty"`
825+
}
826+
827+
// KubeVirtNodePoolStatus contains the KubeVirt platform statuses
828+
type KubeVirtNodePoolStatus struct {
829+
// CacheName holds the name of the cache DataVolume, if exists
830+
// +optional
831+
CacheName string `json:"cacheName,omitempty"`
832+
833+
// RemoteNamespace holds the namespace of the remote infra cluster, if defined
834+
// +optional
835+
RemoteNamespace string `json:"remoteNamespace,omitempty"`
836+
}
837+
793838
// Taint is as v1 Core but without TimeAdded.
794839
// https://github.com/kubernetes/kubernetes/blob/ed8cad1e80d096257921908a52ac69cf1f41a098/staging/src/k8s.io/api/core/v1/types.go#L3037-L3053
795840
type Taint struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/nodepool_types.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ type NodePoolStatus struct {
158158
// +kubebuilder:validation:Optional
159159
Version string `json:"version,omitempty"`
160160

161+
// Platform hols the specific statuses
162+
Platform *NodePoolPlatformStatus `json:"platform,omitempty"`
163+
161164
// Conditions represents the latest available observations of the node pool's
162165
// current state.
163166
// +optional
@@ -546,6 +549,26 @@ type KubevirtPersistentVolume struct {
546549
AccessModes []PersistentVolumeAccessMode `json:"accessModes,omitempty"`
547550
}
548551

552+
// KubevirtCachingStrategyType is the type of the boot image caching mechanism for the KubeVirt provider
553+
type KubevirtCachingStrategyType string
554+
555+
const (
556+
// KubevirtCachingStrategyNone means that hypershift will not cache the boot image
557+
KubevirtCachingStrategyNone KubevirtCachingStrategyType = "None"
558+
559+
// KubevirtCachingStrategyPVC means that hypershift will cache the boot image into a PVC; only relevant when using
560+
// a QCOW boot image, and is ignored when using a container image
561+
KubevirtCachingStrategyPVC KubevirtCachingStrategyType = "PVC"
562+
)
563+
564+
// KubevirtCachingStrategy defines the boot image caching strategy
565+
type KubevirtCachingStrategy struct {
566+
// Type is the type of the caching strategy
567+
// +kubebuilder:default=None
568+
// +kubebuilder:validation:Enum=None;PVC
569+
Type KubevirtCachingStrategyType `json:"type"`
570+
}
571+
549572
// KubevirtRootVolume represents the volume that the rhcos disk will be stored and run from.
550573
type KubevirtRootVolume struct {
551574
// Image represents what rhcos image to use for the node pool
@@ -555,6 +578,10 @@ type KubevirtRootVolume struct {
555578

556579
// KubevirtVolume represents of type of storage to run the image on
557580
KubevirtVolume `json:",inline"`
581+
582+
// CacheStrategy defines the boot image caching strategy. Default - no caching
583+
// +optional
584+
CacheStrategy *KubevirtCachingStrategy `json:"cacheStrategy,omitempty"`
558585
}
559586

560587
// KubevirtVolumeType is a specific supported KubeVirt volumes
@@ -782,6 +809,24 @@ type NodePoolCondition struct {
782809
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
783810
}
784811

812+
// NodePoolPlatformStatus contains specific platform statuses
813+
type NodePoolPlatformStatus struct {
814+
// KubeVirt contains the KubeVirt platform statuses
815+
// +optional
816+
KubeVirt *KubeVirtNodePoolStatus `json:"kubeVirt,omitempty"`
817+
}
818+
819+
// KubeVirtNodePoolStatus contains the KubeVirt platform statuses
820+
type KubeVirtNodePoolStatus struct {
821+
// CacheName holds the name of the cache DataVolume, if exists
822+
// +optional
823+
CacheName string `json:"cacheName,omitempty"`
824+
825+
// RemoteNamespace holds the namespace of the remote infra cluster, if defined
826+
// +optional
827+
RemoteNamespace string `json:"remoteNamespace,omitempty"`
828+
}
829+
785830
// Taint is as v1 Core but without TimeAdded.
786831
// https://github.com/kubernetes/kubernetes/blob/ed8cad1e80d096257921908a52ac69cf1f41a098/staging/src/k8s.io/api/core/v1/types.go#L3037-L3053
787832
type Taint struct {

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/cluster/core/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type KubevirtPlatformCreateOptions struct {
121121
RootVolumeAccessModes string
122122
InfraKubeConfigFile string
123123
InfraNamespace string
124+
CacheStrategyType string
124125
}
125126

126127
type AWSPlatformOptions struct {

0 commit comments

Comments
 (0)