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: Adding EnvFrom support for the OptionalConfigs type to the Go Operator #4909

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions infra/feast-operator/api/v1alpha1/featurestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ type DefaultConfigs struct {
// OptionalConfigs k8s container settings that are optional
type OptionalConfigs struct {
Env *[]corev1.EnvVar `json:"env,omitempty"`
EnvFrom *[]corev1.EnvFromSource `json:"envFrom,omitempty"`
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Resources *corev1.ResourceRequirements `json:"resources,omitempty"`
}
Expand Down
11 changes: 11 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.

246 changes: 246 additions & 0 deletions infra/feast-operator/config/crd/bases/feast.dev_featurestores.yaml

Large diffs are not rendered by default.

246 changes: 246 additions & 0 deletions infra/feast-operator/dist/install.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,31 @@ var _ = Describe("FeatureStore Controller - db storage services", func() {
Expect(k8sClient.Create(ctx, secret)).To(Succeed())
}

By("creating the config map and secret for envFrom")
envFromConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
Data: map[string]string{"example-key": "example-value"},
}
err = k8sClient.Create(context.TODO(), envFromConfigMap)
Expect(err).ToNot(HaveOccurred())

envFromSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
StringData: map[string]string{"secret-key": "secret-value"},
}
err = k8sClient.Create(context.TODO(), envFromSecret)
Expect(err).ToNot(HaveOccurred())

By("creating the custom resource for the Kind FeatureStore")
err = k8sClient.Get(ctx, typeNamespacedName, featurestore)
if err != nil && errors.IsNotFound(err) {
resource := createFeatureStoreResource(resourceName, image, pullPolicy, &[]corev1.EnvVar{})
resource := createFeatureStoreResource(resourceName, image, pullPolicy, &[]corev1.EnvVar{}, withEnvFrom())
resource.Spec.Services.OfflineStore.Persistence = &feastdevv1alpha1.OfflineStorePersistence{
DBPersistence: &feastdevv1alpha1.OfflineStoreDBStorePersistence{
Type: string(offlineType),
Expand Down Expand Up @@ -256,6 +277,26 @@ var _ = Describe("FeatureStore Controller - db storage services", func() {
err = k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred())

By("Deleting the configmap and secret for envFrom")
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), configMap)
Expect(err).ToNot(HaveOccurred())

// Delete Secret
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), secret)
Expect(err).ToNot(HaveOccurred())

By("Cleanup the secrets")
Expect(k8sClient.Delete(ctx, onlineSecret)).To(Succeed())
Expect(k8sClient.Delete(ctx, offlineSecret)).To(Succeed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,32 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
registryPath := "/data/registry.db"

BeforeEach(func() {
By("creating the config map and secret for envFrom")
envFromConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
Data: map[string]string{"example-key": "example-value"},
}
err := k8sClient.Create(context.TODO(), envFromConfigMap)
Expect(err).ToNot(HaveOccurred())

envFromSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
StringData: map[string]string{"secret-key": "secret-value"},
}
err = k8sClient.Create(context.TODO(), envFromSecret)
Expect(err).ToNot(HaveOccurred())

By("creating the custom resource for the Kind FeatureStore")
err := k8sClient.Get(ctx, typeNamespacedName, featurestore)
err = k8sClient.Get(ctx, typeNamespacedName, featurestore)
if err != nil && errors.IsNotFound(err) {
resource := createFeatureStoreResource(resourceName, image, pullPolicy, &[]corev1.EnvVar{{Name: testEnvVarName, Value: testEnvVarValue},
{Name: "fieldRefName", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.namespace"}}}})
{Name: "fieldRefName", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.namespace"}}}}, withEnvFrom())
resource.Spec.Services.OfflineStore.Persistence = &feastdevv1alpha1.OfflineStorePersistence{
FilePersistence: &feastdevv1alpha1.OfflineStoreFilePersistence{
Type: offlineType,
Expand Down Expand Up @@ -97,6 +118,27 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {

By("Cleanup the specific resource instance FeatureStore")
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())

// Delete ConfigMap
By("Deleting the configmap and secret for envFrom")
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), configMap)
Expect(err).ToNot(HaveOccurred())

// Delete Secret
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), secret)
Expect(err).ToNot(HaveOccurred())
})

It("should successfully reconcile the resource", func() {
Expand Down Expand Up @@ -141,6 +183,18 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.Path).To(Equal(onlineStorePath))
Expect(resource.Status.Applied.Services.OnlineStore.Env).To(Equal(&[]corev1.EnvVar{{Name: testEnvVarName, Value: testEnvVarValue}, {Name: "fieldRefName", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.namespace"}}}}))
Expect(resource.Status.Applied.Services.OnlineStore.EnvFrom).To(Equal(&[]corev1.EnvFromSource{
{
ConfigMapRef: &corev1.ConfigMapEnvSource{
LocalObjectReference: corev1.LocalObjectReference{Name: "example-configmap"},
},
},
{
SecretRef: &corev1.SecretEnvSource{
LocalObjectReference: corev1.LocalObjectReference{Name: "example-secret"},
},
},
}))
Expect(resource.Status.Applied.Services.OnlineStore.ImagePullPolicy).To(Equal(&pullPolicy))
Expect(resource.Status.Applied.Services.OnlineStore.Resources).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OnlineStore.Image).To(Equal(&image))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,31 @@ var _ = Describe("FeatureStore Controller-Kubernetes authorization", func() {
roles := []string{"reader", "writer"}

BeforeEach(func() {
By("creating the config map and secret for envFrom")
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
Data: map[string]string{"example-key": "example-value"},
}
err := k8sClient.Create(context.TODO(), configMap)
Expect(err).ToNot(HaveOccurred())

secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
StringData: map[string]string{"secret-key": "secret-value"},
}
err = k8sClient.Create(context.TODO(), secret)
Expect(err).ToNot(HaveOccurred())

By("creating the custom resource for the Kind FeatureStore")
err := k8sClient.Get(ctx, typeNamespacedName, featurestore)
err = k8sClient.Get(ctx, typeNamespacedName, featurestore)
if err != nil && errors.IsNotFound(err) {
resource := createFeatureStoreResource(resourceName, image, pullPolicy, &[]corev1.EnvVar{})
resource := createFeatureStoreResource(resourceName, image, pullPolicy, &[]corev1.EnvVar{}, withEnvFrom())
resource.Spec.AuthzConfig = &feastdevv1alpha1.AuthzConfig{KubernetesAuthz: &feastdevv1alpha1.KubernetesAuthz{
Roles: roles,
}}
Expand All @@ -75,6 +96,27 @@ var _ = Describe("FeatureStore Controller-Kubernetes authorization", func() {
err := k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred())

// Delete ConfigMap
By("Deleting the configmap and secret for envFrom")
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), configMap)
Expect(err).ToNot(HaveOccurred())

// Delete Secret
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), secret)
Expect(err).ToNot(HaveOccurred())

By("Cleanup the specific resource instance FeatureStore")
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
})
Expand Down Expand Up @@ -126,6 +168,18 @@ var _ = Describe("FeatureStore Controller-Kubernetes authorization", func() {
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OnlineStore.Persistence.FilePersistence.Path).To(Equal(services.EphemeralPath + "/" + services.DefaultOnlineStorePath))
Expect(resource.Status.Applied.Services.OnlineStore.Env).To(Equal(&[]corev1.EnvVar{}))
Expect(resource.Status.Applied.Services.OnlineStore.EnvFrom).To(Equal(&[]corev1.EnvFromSource{
{
ConfigMapRef: &corev1.ConfigMapEnvSource{
LocalObjectReference: corev1.LocalObjectReference{Name: "example-configmap"},
},
},
{
SecretRef: &corev1.SecretEnvSource{
LocalObjectReference: corev1.LocalObjectReference{Name: "example-secret"},
},
},
}))
Expect(resource.Status.Applied.Services.OnlineStore.ImagePullPolicy).To(Equal(&pullPolicy))
Expect(resource.Status.Applied.Services.OnlineStore.Resources).NotTo(BeNil())
Expect(resource.Status.Applied.Services.OnlineStore.Image).To(Equal(&image))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,32 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
}

BeforeEach(func() {
By("creating the config map and secret for envFrom")
envFromConfigMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
Data: map[string]string{"example-key": "example-value"},
}
err := k8sClient.Create(context.TODO(), envFromConfigMap)
Expect(err).ToNot(HaveOccurred())

envFromSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
StringData: map[string]string{"secret-key": "secret-value"},
}
err = k8sClient.Create(context.TODO(), envFromSecret)
Expect(err).ToNot(HaveOccurred())

By("creating the custom resource for the Kind FeatureStore")
err := k8sClient.Get(ctx, typeNamespacedName, featurestore)
err = k8sClient.Get(ctx, typeNamespacedName, featurestore)
if err != nil && errors.IsNotFound(err) {
resource := createFeatureStoreResource(resourceName, image, pullPolicy, &[]corev1.EnvVar{{Name: testEnvVarName, Value: testEnvVarValue},
{Name: "fieldRefName", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.namespace"}}}})
{Name: "fieldRefName", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.namespace"}}}}, withEnvFrom())
resource.Spec.Services.OnlineStore = nil
resource.Spec.Services.OfflineStore = nil
resource.Spec.Services.Registry = &feastdevv1alpha1.Registry{
Expand All @@ -81,7 +102,6 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
},
},
}

Expect(k8sClient.Create(ctx, resource)).To(Succeed())
}
})
Expand All @@ -90,6 +110,26 @@ var _ = Describe("FeatureStore Controller-Ephemeral services", func() {
err := k8sClient.Get(ctx, typeNamespacedName, resource)
Expect(err).NotTo(HaveOccurred())

By("Deleting the configmap and secret for envFrom")
configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "example-configmap",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), configMap)
Expect(err).ToNot(HaveOccurred())

// Delete Secret
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: "example-secret",
Namespace: "default",
},
}
err = k8sClient.Delete(context.TODO(), secret)
Expect(err).ToNot(HaveOccurred())

By("Cleanup the specific resource instance FeatureStore")
Expect(k8sClient.Delete(ctx, resource)).To(Succeed())
})
Expand Down
Loading
Loading