Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/fixtures/example_kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ExampleKubevirtOptions struct {
BaseDomainPassthrough bool
InfraKubeConfig []byte
InfraNamespace string
CacheStrategyType string
}

func ExampleKubeVirtTemplate(o *ExampleKubevirtOptions) *hyperv1.KubevirtNodePoolPlatform {
Expand Down Expand Up @@ -69,5 +70,12 @@ func ExampleKubeVirtTemplate(o *ExampleKubevirtOptions) *hyperv1.KubevirtNodePoo
}
}

strategyType := hyperv1.KubevirtCachingStrategyType(o.CacheStrategyType)
if strategyType == hyperv1.KubevirtCachingStrategyNone || strategyType == hyperv1.KubevirtCachingStrategyPVC {
exampleTemplate.RootVolume.CacheStrategy = &hyperv1.KubevirtCachingStrategy{
Type: strategyType,
}
}

return exampleTemplate
}
2 changes: 2 additions & 0 deletions api/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer/json"
kasv1beta1 "k8s.io/apiserver/pkg/apis/apiserver/v1beta1"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
capiaws "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
capiazure "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
capiibm "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta1"
Expand Down Expand Up @@ -71,4 +72,5 @@ func init() {
capiazure.AddToScheme(Scheme)
snapshotv1.AddToScheme(Scheme)
imagev1.AddToScheme(Scheme)
cdiv1beta1.AddToScheme(Scheme)
}
45 changes: 45 additions & 0 deletions api/v1alpha1/nodepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ type NodePoolStatus struct {
// +kubebuilder:validation:Optional
Version string `json:"version,omitempty"`

// Platform hols the specific statuses
Platform *NodePoolPlatformStatus `json:"platform,omitempty"`

// Conditions represents the latest available observations of the node pool's
// current state.
// +optional
Expand Down Expand Up @@ -552,6 +555,26 @@ type KubevirtPersistentVolume struct {
AccessModes []PersistentVolumeAccessMode `json:"accessModes,omitempty"`
}

// KubevirtCachingStrategyType is the type of the boot image caching mechanism for the KubeVirt provider
type KubevirtCachingStrategyType string

const (
// KubevirtCachingStrategyNone means that hypershift will not cache the boot image
KubevirtCachingStrategyNone KubevirtCachingStrategyType = "None"

// KubevirtCachingStrategyPVC means that hypershift will cache the boot image into a PVC; only relevant when using
// a QCOW boot image, and is ignored when using a container image
KubevirtCachingStrategyPVC KubevirtCachingStrategyType = "PVC"
)

// KubevirtCachingStrategy defines the boot image caching strategy
type KubevirtCachingStrategy struct {
// Type is the type of the caching strategy
// +kubebuilder:default=None
Comment on lines +572 to +573
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss this. We need to add validation here on the api

// +kubebuilder:validation:Enum=None;PVC

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not fixed

// +kubebuilder:validation:Enum=None;PVC
Type KubevirtCachingStrategyType `json:"type"`
}

// KubevirtRootVolume represents the volume that the rhcos disk will be stored and run from.
type KubevirtRootVolume struct {
// Image represents what rhcos image to use for the node pool
Expand All @@ -561,6 +584,10 @@ type KubevirtRootVolume struct {

// KubevirtVolume represents of type of storage to run the image on
KubevirtVolume `json:",inline"`

// CacheStrategy defines the boot image caching strategy. Default - no caching
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add // +optional

// +optional
CacheStrategy *KubevirtCachingStrategy `json:"cacheStrategy,omitempty"`
}

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

// NodePoolPlatformStatus contains specific platform statuses
type NodePoolPlatformStatus struct {
// KubeVirt contains the KubeVirt platform statuses
// +optional
KubeVirt *KubeVirtNodePoolStatus `json:"kubeVirt,omitempty"`
}

// KubeVirtNodePoolStatus contains the KubeVirt platform statuses
type KubeVirtNodePoolStatus struct {
// CacheName holds the name of the cache DataVolume, if exists
// +optional
CacheName string `json:"cacheName,omitempty"`

// RemoteNamespace holds the namespace of the remote infra cluster, if defined
// +optional
RemoteNamespace string `json:"remoteNamespace,omitempty"`
}

// Taint is as v1 Core but without TimeAdded.
// https://github.com/kubernetes/kubernetes/blob/ed8cad1e80d096257921908a52ac69cf1f41a098/staging/src/k8s.io/api/core/v1/types.go#L3037-L3053
type Taint struct {
Expand Down
60 changes: 60 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions api/v1beta1/nodepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ type NodePoolStatus struct {
// +kubebuilder:validation:Optional
Version string `json:"version,omitempty"`

// Platform hols the specific statuses
Platform *NodePoolPlatformStatus `json:"platform,omitempty"`

// Conditions represents the latest available observations of the node pool's
// current state.
// +optional
Expand Down Expand Up @@ -546,6 +549,26 @@ type KubevirtPersistentVolume struct {
AccessModes []PersistentVolumeAccessMode `json:"accessModes,omitempty"`
}

// KubevirtCachingStrategyType is the type of the boot image caching mechanism for the KubeVirt provider
type KubevirtCachingStrategyType string

const (
// KubevirtCachingStrategyNone means that hypershift will not cache the boot image
KubevirtCachingStrategyNone KubevirtCachingStrategyType = "None"

// KubevirtCachingStrategyPVC means that hypershift will cache the boot image into a PVC; only relevant when using
// a QCOW boot image, and is ignored when using a container image
KubevirtCachingStrategyPVC KubevirtCachingStrategyType = "PVC"
)

// KubevirtCachingStrategy defines the boot image caching strategy
type KubevirtCachingStrategy struct {
// Type is the type of the caching strategy
// +kubebuilder:default=None
// +kubebuilder:validation:Enum=None;PVC
Type KubevirtCachingStrategyType `json:"type"`
}

// KubevirtRootVolume represents the volume that the rhcos disk will be stored and run from.
type KubevirtRootVolume struct {
// Image represents what rhcos image to use for the node pool
Expand All @@ -555,6 +578,10 @@ type KubevirtRootVolume struct {

// KubevirtVolume represents of type of storage to run the image on
KubevirtVolume `json:",inline"`

// CacheStrategy defines the boot image caching strategy. Default - no caching
// +optional
CacheStrategy *KubevirtCachingStrategy `json:"cacheStrategy,omitempty"`
}

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

// NodePoolPlatformStatus contains specific platform statuses
type NodePoolPlatformStatus struct {
// KubeVirt contains the KubeVirt platform statuses
// +optional
KubeVirt *KubeVirtNodePoolStatus `json:"kubeVirt,omitempty"`
}

// KubeVirtNodePoolStatus contains the KubeVirt platform statuses
type KubeVirtNodePoolStatus struct {
// CacheName holds the name of the cache DataVolume, if exists
// +optional
CacheName string `json:"cacheName,omitempty"`

// RemoteNamespace holds the namespace of the remote infra cluster, if defined
// +optional
RemoteNamespace string `json:"remoteNamespace,omitempty"`
}

// Taint is as v1 Core but without TimeAdded.
// https://github.com/kubernetes/kubernetes/blob/ed8cad1e80d096257921908a52ac69cf1f41a098/staging/src/k8s.io/api/core/v1/types.go#L3037-L3053
type Taint struct {
Expand Down
60 changes: 60 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/cluster/core/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type KubevirtPlatformCreateOptions struct {
RootVolumeAccessModes string
InfraKubeConfigFile string
InfraNamespace string
CacheStrategyType string
}

type AWSPlatformOptions struct {
Expand Down
Loading