Skip to content

Commit a617a6c

Browse files
authored
feat: Add TLS support to the Operator (feast-dev#4796)
* add tls support to the operator Signed-off-by: Tommy Hughes <[email protected]> * operator tls review fix: if statement Signed-off-by: Tommy Hughes <[email protected]> * rebase fixes Signed-off-by: Tommy Hughes <[email protected]> * authz rbac fixes Signed-off-by: Tommy Hughes <[email protected]> --------- Signed-off-by: Tommy Hughes <[email protected]>
1 parent 0ef5acc commit a617a6c

23 files changed

+2190
-205
lines changed

infra/feast-operator/api/v1alpha1/featurestore_types.go

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
OnlineStoreReadyType = "OnlineStore"
3434
RegistryReadyType = "Registry"
3535
ReadyType = "FeatureStore"
36-
AuthorizationReadyType = "AuthorizationReadyType"
36+
AuthorizationReadyType = "Authorization"
3737

3838
// Feast condition reasons:
3939
ReadyReason = "Ready"
@@ -76,6 +76,14 @@ type FeatureStoreServices struct {
7676
type OfflineStore struct {
7777
ServiceConfigs `json:",inline"`
7878
Persistence *OfflineStorePersistence `json:"persistence,omitempty"`
79+
TLS *OfflineTlsConfigs `json:"tls,omitempty"`
80+
}
81+
82+
// OfflineTlsConfigs configures server TLS for the offline feast service. in an openshift cluster, this is configured by default using service serving certificates.
83+
type OfflineTlsConfigs struct {
84+
TlsConfigs `json:",inline"`
85+
// verify the client TLS certificate.
86+
VerifyClient *bool `json:"verifyClient,omitempty"`
7987
}
8088

8189
// OfflineStorePersistence configures the persistence settings for the offline store service
@@ -119,6 +127,7 @@ var ValidOfflineStoreDBStorePersistenceTypes = []string{
119127
type OnlineStore struct {
120128
ServiceConfigs `json:",inline"`
121129
Persistence *OnlineStorePersistence `json:"persistence,omitempty"`
130+
TLS *TlsConfigs `json:"tls,omitempty"`
122131
}
123132

124133
// OnlineStorePersistence configures the persistence settings for the online store service
@@ -163,9 +172,11 @@ var ValidOnlineStoreDBStorePersistenceTypes = []string{
163172
type LocalRegistryConfig struct {
164173
ServiceConfigs `json:",inline"`
165174
Persistence *RegistryPersistence `json:"persistence,omitempty"`
175+
TLS *TlsConfigs `json:"tls,omitempty"`
166176
}
167177

168178
// RegistryPersistence configures the persistence settings for the registry service
179+
// +kubebuilder:validation:XValidation:rule="[has(self.file), has(self.store)].exists_one(c, c)",message="One selection required between file or store."
169180
type RegistryPersistence struct {
170181
FilePersistence *RegistryFilePersistence `json:"file,omitempty"`
171182
DBPersistence *RegistryDBStorePersistence `json:"store,omitempty"`
@@ -238,7 +249,8 @@ type RemoteRegistryConfig struct {
238249
// Host address of the remote registry service - <domain>:<port>, e.g. `registry.<namespace>.svc.cluster.local:80`
239250
Hostname *string `json:"hostname,omitempty"`
240251
// Reference to an existing `FeatureStore` CR in the same k8s cluster.
241-
FeastRef *FeatureStoreRef `json:"feastRef,omitempty"`
252+
FeastRef *FeatureStoreRef `json:"feastRef,omitempty"`
253+
TLS *TlsRemoteRegistryConfigs `json:"tls,omitempty"`
242254
}
243255

244256
// FeatureStoreRef defines which existing FeatureStore's registry should be used
@@ -284,6 +296,45 @@ type KubernetesAuthz struct {
284296
Roles []string `json:"roles,omitempty"`
285297
}
286298

299+
// TlsConfigs configures server TLS for a feast service. in an openshift cluster, this is configured by default using service serving certificates.
300+
// +kubebuilder:validation:XValidation:rule="(!has(self.disable) || !self.disable) ? has(self.secretRef) : true",message="`secretRef` required if `disable` is false."
301+
type TlsConfigs struct {
302+
// references the local k8s secret where the TLS key and cert reside
303+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
304+
SecretKeyNames SecretKeyNames `json:"secretKeyNames,omitempty"`
305+
// will disable TLS for the feast service. useful in an openshift cluster, for example, where TLS is configured by default
306+
Disable *bool `json:"disable,omitempty"`
307+
}
308+
309+
// `secretRef` required if `disable` is false.
310+
func (tls *TlsConfigs) IsTLS() bool {
311+
if tls != nil {
312+
if tls.Disable != nil && *tls.Disable {
313+
return false
314+
} else if tls.SecretRef == nil {
315+
return false
316+
}
317+
return true
318+
}
319+
return false
320+
}
321+
322+
// TlsRemoteRegistryConfigs configures client TLS for a remote feast registry. in an openshift cluster, this is configured by default when the remote feast registry is using service serving certificates.
323+
type TlsRemoteRegistryConfigs struct {
324+
// references the local k8s configmap where the TLS cert resides
325+
ConfigMapRef corev1.LocalObjectReference `json:"configMapRef"`
326+
// defines the configmap key name for the client TLS cert.
327+
CertName string `json:"certName"`
328+
}
329+
330+
// SecretKeyNames defines the secret key names for the TLS key and cert.
331+
type SecretKeyNames struct {
332+
// defaults to "tls.crt"
333+
TlsCrt string `json:"tlsCrt,omitempty"`
334+
// defaults to "tls.key"
335+
TlsKey string `json:"tlsKey,omitempty"`
336+
}
337+
287338
// FeatureStoreStatus defines the observed state of FeatureStore
288339
type FeatureStoreStatus struct {
289340
// Shows the currently applied feast configuration, including any pertinent defaults

infra/feast-operator/api/v1alpha1/zz_generated.deepcopy.go

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

infra/feast-operator/cmd/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838

3939
feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
4040
"github.com/feast-dev/feast/infra/feast-operator/internal/controller"
41+
"github.com/feast-dev/feast/infra/feast-operator/internal/controller/services"
4142
//+kubebuilder:scaffold:imports
4243
)
4344

@@ -132,6 +133,8 @@ func main() {
132133
os.Exit(1)
133134
}
134135

136+
services.SetIsOpenShift(mgr.GetConfig())
137+
135138
if err = (&controller.FeatureStoreReconciler{
136139
Client: mgr.GetClient(),
137140
Scheme: mgr.GetScheme(),

0 commit comments

Comments
 (0)