Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added pvc accessModes support #4851

Merged
merged 4 commits into from
Dec 20, 2024
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
2 changes: 2 additions & 0 deletions infra/feast-operator/api/v1alpha1/featurestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ type PvcConfig struct {
// The PVC name is the same as the associated deployment name.
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="PvcCreate is immutable"
type PvcCreate struct {
// AccessModes k8s persistent volume access modes. Defaults to ["ReadWriteOnce"].
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty"`
// StorageClassName is the name of an existing StorageClass to which this persistent volume belongs. Empty value
// means that this volume does not belong to any StorageClass and the cluster default will be used.
StorageClassName *string `json:"storageClassName,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent volume
access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -622,6 +628,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent volume
access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -1006,6 +1018,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -1506,6 +1524,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -1879,6 +1903,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -2272,6 +2302,13 @@ spec:
description: Settings for creating a new
PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to
["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down
37 changes: 37 additions & 0 deletions infra/feast-operator/dist/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent volume
access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -630,6 +636,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent volume
access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -1014,6 +1026,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -1514,6 +1532,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -1887,6 +1911,12 @@ spec:
create:
description: Settings for creating a new PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to ["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down Expand Up @@ -2280,6 +2310,13 @@ spec:
description: Settings for creating a new
PVC
properties:
accessModes:
description: AccessModes k8s persistent
volume access modes. Defaults to
["ReadWriteOnce"].
items:
type: string
type: array
resources:
description: |-
Resources describes the storage resource requirements for a volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
onlineStoreMountPath := "/online"
registryMountPath := "/registry"

accessModes := []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce, corev1.ReadWriteMany}
storageClassName := "test"

onlineStoreMountedPath := path.Join(onlineStoreMountPath, onlineStorePath)
Expand All @@ -85,6 +86,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
Type: offlineType,
PvcConfig: &feastdevv1alpha1.PvcConfig{
Create: &feastdevv1alpha1.PvcCreate{
AccessModes: accessModes,
StorageClassName: &storageClassName,
},
MountPath: offlineStoreMountPath,
Expand Down Expand Up @@ -162,6 +164,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.Type).To(Equal(offlineType))
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(accessModes))
Expect(resource.Status.Applied.Services.OfflineStore.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(Equal(&storageClassName))
expectedResources := corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand All @@ -179,6 +182,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.Path).To(Equal(onlineStorePath))
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(services.DefaultPVCAccessModes))
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(BeNil())
expectedResources = corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand All @@ -198,6 +202,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.Path).To(Equal(registryPath))
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig).NotTo(BeNil())
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create).NotTo(BeNil())
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create.AccessModes).To(Equal(services.DefaultPVCAccessModes))
Expect(resource.Status.Applied.Services.Registry.Local.Persistence.FilePersistence.PvcConfig.Create.StorageClassName).To(BeNil())
expectedResources = corev1.VolumeResourceRequirements{
Requests: corev1.ResourceList{
Expand Down Expand Up @@ -283,6 +288,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
Expect(err).NotTo(HaveOccurred())
Expect(pvc.Name).To(Equal(deploy.Name))
Expect(pvc.Spec.StorageClassName).To(Equal(&storageClassName))
Expect(pvc.Spec.AccessModes).To(Equal(accessModes))
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultOfflineStorageRequest))
Expect(pvc.DeletionTimestamp).To(BeNil())

Expand Down Expand Up @@ -313,6 +319,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
pvc)
Expect(err).NotTo(HaveOccurred())
Expect(pvc.Name).To(Equal(deploy.Name))
Expect(pvc.Spec.AccessModes).To(Equal(services.DefaultPVCAccessModes))
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultOnlineStorageRequest))
Expect(pvc.DeletionTimestamp).To(BeNil())

Expand Down Expand Up @@ -343,6 +350,7 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
pvc)
Expect(err).NotTo(HaveOccurred())
Expect(pvc.Name).To(Equal(deploy.Name))
Expect(pvc.Spec.AccessModes).To(Equal(services.DefaultPVCAccessModes))
Expect(pvc.Spec.Resources.Requests.Storage().String()).To(Equal(services.DefaultRegistryStorageRequest))
Expect(pvc.DeletionTimestamp).To(BeNil())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func (feast *FeastServices) createNewPVC(pvcCreate *feastdevv1alpha1.PvcCreate,
pvc := feast.initPVC(feastType)

pvc.Spec = corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteMany},
AccessModes: pvcCreate.AccessModes,
Resources: pvcCreate.Resources,
}
if pvcCreate.StorageClassName != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/feast-dev/feast/infra/feast-operator/api/feastversion"
feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
handler "github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -80,10 +81,11 @@ const (
)

var (
DefaultImage = "feastdev/feature-server:" + feastversion.FeastVersion
DefaultReplicas = int32(1)
NameLabelKey = feastdevv1alpha1.GroupVersion.Group + "/name"
ServiceTypeLabelKey = feastdevv1alpha1.GroupVersion.Group + "/service-type"
DefaultImage = "feastdev/feature-server:" + feastversion.FeastVersion
DefaultReplicas = int32(1)
DefaultPVCAccessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}
NameLabelKey = feastdevv1alpha1.GroupVersion.Group + "/name"
ServiceTypeLabelKey = feastdevv1alpha1.GroupVersion.Group + "/service-type"

FeastServiceConstants = map[FeastServiceType]deploymentSettings{
OfflineFeastType: {
Expand Down
30 changes: 21 additions & 9 deletions infra/feast-operator/internal/controller/services/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {

if services.Registry.Local.Persistence.FilePersistence.PvcConfig != nil {
pvc := services.Registry.Local.Persistence.FilePersistence.PvcConfig
if pvc.Create != nil {
ensureRequestedStorage(&pvc.Create.Resources, DefaultRegistryStorageRequest)
}
ensurePVCDefaults(pvc, RegistryFeastType)
}
}

Expand All @@ -116,9 +114,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {

if services.OfflineStore.Persistence.FilePersistence.PvcConfig != nil {
pvc := services.OfflineStore.Persistence.FilePersistence.PvcConfig
if pvc.Create != nil {
ensureRequestedStorage(&pvc.Create.Resources, DefaultOfflineStorageRequest)
}
ensurePVCDefaults(pvc, OfflineFeastType)
}
}

Expand All @@ -141,9 +137,7 @@ func ApplyDefaultsToStatus(cr *feastdevv1alpha1.FeatureStore) {

if services.OnlineStore.Persistence.FilePersistence.PvcConfig != nil {
pvc := services.OnlineStore.Persistence.FilePersistence.PvcConfig
if pvc.Create != nil {
ensureRequestedStorage(&pvc.Create.Resources, DefaultOnlineStorageRequest)
}
ensurePVCDefaults(pvc, OnlineFeastType)
}
}

Expand Down Expand Up @@ -182,6 +176,24 @@ func ensureRequestedStorage(resources *v1.VolumeResourceRequirements, requestedS
}
}

func ensurePVCDefaults(pvc *feastdevv1alpha1.PvcConfig, feastType FeastServiceType) {
var storageRequest string
switch feastType {
case OnlineFeastType:
storageRequest = DefaultOnlineStorageRequest
case OfflineFeastType:
storageRequest = DefaultOfflineStorageRequest
case RegistryFeastType:
storageRequest = DefaultRegistryStorageRequest
}
tchughesiv marked this conversation as resolved.
Show resolved Hide resolved
if pvc.Create != nil {
ensureRequestedStorage(&pvc.Create.Resources, storageRequest)
if pvc.Create.AccessModes == nil {
pvc.Create.AccessModes = DefaultPVCAccessModes
}
}
}

func defaultOnlineStorePath(persistence *feastdevv1alpha1.OnlineStoreFilePersistence) string {
if persistence.PvcConfig == nil {
return DefaultOnlineStoreEphemeralPath
Expand Down
Loading