Skip to content
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
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 @@ -515,6 +515,8 @@ type ServerConfigs struct {
// Allowed values: "debug", "info", "warning", "error", "critical".
// +kubebuilder:validation:Enum=debug;info;warning;error;critical
LogLevel *string `json:"logLevel,omitempty"`
// Metrics exposes Prometheus-compatible metrics for the Feast server when enabled.
Metrics *bool `json:"metrics,omitempty"`
// VolumeMounts defines the list of volumes that should be mounted into the feast container.
// This allows attaching persistent storage, config files, secrets, or other resources
// required by the Feast components. Ensure that each volume mount has a corresponding
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 @@ -1041,6 +1041,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -1500,6 +1504,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -1985,6 +1993,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -2484,6 +2496,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -5057,6 +5073,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -5524,6 +5544,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -6021,6 +6045,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -6530,6 +6558,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down
32 changes: 32 additions & 0 deletions infra/feast-operator/dist/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -1508,6 +1512,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -1993,6 +2001,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -2492,6 +2504,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -5065,6 +5081,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -5532,6 +5552,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -6029,6 +6053,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible
metrics for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -6538,6 +6566,10 @@ spec:
- error
- critical
type: string
metrics:
description: Metrics exposes Prometheus-compatible metrics
for the Feast server when enabled.
type: boolean
nodeSelector:
additionalProperties:
type: string
Expand Down
2 changes: 2 additions & 0 deletions infra/feast-operator/docs/api/markdown/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ _Appears in:_
| `tls` _[TlsConfigs](#tlsconfigs)_ | |
| `logLevel` _string_ | LogLevel sets the logging level for the server
Allowed values: "debug", "info", "warning", "error", "critical". |
| `metrics` _boolean_ | Metrics exposes Prometheus-compatible metrics for the Feast server when enabled. |
| `volumeMounts` _[VolumeMount](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#volumemount-v1-core) array_ | VolumeMounts defines the list of volumes that should be mounted into the feast container.
This allows attaching persistent storage, config files, secrets, or other resources
required by the Feast components. Ensure that each volume mount has a corresponding
Expand Down Expand Up @@ -765,6 +766,7 @@ _Appears in:_
| `tls` _[TlsConfigs](#tlsconfigs)_ | |
| `logLevel` _string_ | LogLevel sets the logging level for the server
Allowed values: "debug", "info", "warning", "error", "critical". |
| `metrics` _boolean_ | Metrics exposes Prometheus-compatible metrics for the Feast server when enabled. |
| `volumeMounts` _[VolumeMount](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#volumemount-v1-core) array_ | VolumeMounts defines the list of volumes that should be mounted into the feast container.
This allows attaching persistent storage, config files, secrets, or other resources
required by the Feast components. Ensure that each volume mount has a corresponding
Expand Down
36 changes: 35 additions & 1 deletion infra/feast-operator/internal/controller/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,13 @@ func (feast *FeastServices) setContainer(containers *[]corev1.Container, feastTy
ContainerPort: getTargetPort(feastType, tls),
Protocol: corev1.ProtocolTCP,
})
if feastType == OnlineFeastType && feast.isMetricsEnabled(feastType) {
container.Ports = append(container.Ports, corev1.ContainerPort{
Name: "metrics",
ContainerPort: MetricsPort,
Protocol: corev1.ProtocolTCP,
})
}
}

container.StartupProbe = &corev1.Probe{
Expand Down Expand Up @@ -565,6 +572,10 @@ func (feast *FeastServices) getContainerCommand(feastType FeastServiceType) []st
}

deploySettings := FeastServiceConstants[feastType]
deploySettings.Args = append([]string{}, deploySettings.Args...)
if feastType == OnlineFeastType && feast.isMetricsEnabled(feastType) {
deploySettings.Args = append([]string{deploySettings.Args[0], "--metrics"}, deploySettings.Args[1:]...)
}
targetPort := deploySettings.TargetHttpPort
tls := feast.getTlsConfigs(feastType)

Expand Down Expand Up @@ -732,6 +743,15 @@ func (feast *FeastServices) setService(svc *corev1.Service, feastType FeastServi
},
}

if feastType == OnlineFeastType && feast.isMetricsEnabled(feastType) {
svc.Spec.Ports = append(svc.Spec.Ports, corev1.ServicePort{
Name: "metrics",
Port: MetricsPort,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(int(MetricsPort)),
})
}

return controllerutil.SetControllerReference(feast.Handler.FeatureStore, svc, feast.Handler.Scheme)
}

Expand Down Expand Up @@ -800,6 +820,18 @@ func (feast *FeastServices) getLogLevelForType(feastType FeastServiceType) *stri
return nil
}

func (feast *FeastServices) isMetricsEnabled(feastType FeastServiceType) bool {
if feastType != OnlineFeastType {
return false
}

if serviceConfigs := feast.getServerConfigs(feastType); serviceConfigs != nil && serviceConfigs.Metrics != nil {
return *serviceConfigs.Metrics
}

return false
}

func (feast *FeastServices) getNodeSelectorForType(feastType FeastServiceType) *map[string]string {
if serviceConfigs := feast.getServerConfigs(feastType); serviceConfigs != nil {
return serviceConfigs.ContainerConfigs.OptionalCtrConfigs.NodeSelector
Expand Down Expand Up @@ -1100,7 +1132,9 @@ func (feast *FeastServices) initRoute(feastType FeastServiceType) *routev1.Route
}

func applyCtrConfigs(container *corev1.Container, containerConfigs feastdevv1alpha1.ContainerConfigs) {
container.Image = *containerConfigs.DefaultCtrConfigs.Image
if containerConfigs.DefaultCtrConfigs.Image != nil {
container.Image = *containerConfigs.DefaultCtrConfigs.Image
}
// apply optional container configs
if containerConfigs.OptionalCtrConfigs.Env != nil {
container.Env = envOverride(container.Env, *containerConfigs.OptionalCtrConfigs.Env)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -374,6 +375,49 @@ var _ = Describe("Registry Service", func() {
Expect(deployment.Spec.Template.Spec.NodeSelector).To(Equal(expectedNodeSelector))
})

It("should enable metrics on the online service when configured", func() {
featureStore.Spec.Services.OnlineStore = &feastdevv1alpha1.OnlineStore{
Server: &feastdevv1alpha1.ServerConfigs{Metrics: ptr(true)},
}

Expect(k8sClient.Update(ctx, featureStore)).To(Succeed())
Expect(feast.ApplyDefaults()).To(Succeed())
applySpecToStatus(featureStore)
feast.refreshFeatureStore(ctx, typeNamespacedName)

Expect(feast.deployFeastServiceByType(OnlineFeastType)).To(Succeed())

deployment := feast.initFeastDeploy()
Expect(deployment).NotTo(BeNil())
Expect(feast.setDeployment(deployment)).To(Succeed())

onlineContainer := GetOnlineContainer(*deployment)
Expect(onlineContainer).NotTo(BeNil())
Expect(onlineContainer.Command).To(Equal([]string{"feast", "serve", "--metrics", "-h", "0.0.0.0", "-p", "6566"}))
Expect(onlineContainer.Ports).To(ContainElement(corev1.ContainerPort{
Name: "metrics",
ContainerPort: MetricsPort,
Protocol: corev1.ProtocolTCP,
}))
metricsPortCount := 0
for _, port := range onlineContainer.Ports {
if port.Name == "metrics" {
metricsPortCount++
}
}
Expect(metricsPortCount).To(Equal(1))

svc := feast.initFeastSvc(OnlineFeastType)
Expect(svc).NotTo(BeNil())
Expect(feast.setService(svc, OnlineFeastType, false)).To(Succeed())
Expect(svc.Spec.Ports).To(ContainElement(corev1.ServicePort{
Name: "metrics",
Port: MetricsPort,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(int(MetricsPort)),
}))
})

It("should handle empty NodeSelector gracefully", func() {
// Set empty NodeSelector
emptyNodeSelector := map[string]string{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ const (
caBundleAnnotation = "config.openshift.io/inject-trusted-cabundle"
caBundleName = "odh-trusted-ca-bundle"

DefaultOfflineStorageRequest = "20Gi"
DefaultOnlineStorageRequest = "5Gi"
DefaultRegistryStorageRequest = "5Gi"
DefaultOfflineStorageRequest = "20Gi"
DefaultOnlineStorageRequest = "5Gi"
DefaultRegistryStorageRequest = "5Gi"
MetricsPort int32 = 8000

AuthzFeastType FeastServiceType = "authorization"
OfflineFeastType FeastServiceType = "offline"
Expand Down