Skip to content

Commit f3c3d61

Browse files
committed
adding tls config for ui
Signed-off-by: Abdul Hameed <ahameed@redhat.com>
1 parent e6eb3cd commit f3c3d61

File tree

10 files changed

+1711
-1021
lines changed

10 files changed

+1711
-1021
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The "tls.disable = true" setting will disable the creation of TLS for the Feast services in an OpenShift environment.
2+
apiVersion: feast.dev/v1alpha1
3+
kind: FeatureStore
4+
metadata:
5+
name: sample-services-tls-disable
6+
spec:
7+
feastProject: my_project
8+
services:
9+
onlineStore:
10+
tls:
11+
disable : true
12+
offlineStore:
13+
tls:
14+
disable: true
15+
ui:
16+
tls:
17+
disable: true
18+
registry:
19+
local:
20+
tls:
21+
disable: true

infra/feast-operator/dist/install.yaml

Lines changed: 1606 additions & 1003 deletions
Large diffs are not rendered by default.

infra/feast-operator/internal/controller/featurestore_controller.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (r *FeatureStoreReconciler) deployFeast(ctx context.Context, cr *feastdevv1
155155

156156
// SetupWithManager sets up the controller with the Manager.
157157
func (r *FeatureStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
158-
return ctrl.NewControllerManagedBy(mgr).
158+
bldr := ctrl.NewControllerManagedBy(mgr).
159159
For(&feastdevv1alpha1.FeatureStore{}).
160160
Owns(&corev1.ConfigMap{}).
161161
Owns(&appsv1.Deployment{}).
@@ -164,9 +164,13 @@ func (r *FeatureStoreReconciler) SetupWithManager(mgr ctrl.Manager) error {
164164
Owns(&corev1.ServiceAccount{}).
165165
Owns(&rbacv1.RoleBinding{}).
166166
Owns(&rbacv1.Role{}).
167-
Owns(&routev1.Route{}).
168-
Watches(&feastdevv1alpha1.FeatureStore{}, handler.EnqueueRequestsFromMapFunc(r.mapFeastRefsToFeastRequests)).
169-
Complete(r)
167+
Watches(&feastdevv1alpha1.FeatureStore{}, handler.EnqueueRequestsFromMapFunc(r.mapFeastRefsToFeastRequests))
168+
if services.IsOpenShift() {
169+
bldr = bldr.Owns(&routev1.Route{})
170+
}
171+
172+
return bldr.Complete(r)
173+
170174
}
171175

172176
// if a remotely referenced FeatureStore is changed, reconcile any FeatureStores that reference it.

infra/feast-operator/internal/controller/services/repo_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ func minimalFeatureStoreWithAllServices() *feastdevv1alpha1.FeatureStore {
371371
OfflineStore: &feastdevv1alpha1.OfflineStore{},
372372
OnlineStore: &feastdevv1alpha1.OnlineStore{},
373373
Registry: &feastdevv1alpha1.Registry{},
374+
UI: &feastdevv1alpha1.UIService{},
374375
}
375376
return feast
376377
}

infra/feast-operator/internal/controller/services/services.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (feast *FeastServices) removeRoute(feastType FeastServiceType) error {
240240
return nil
241241
}
242242
route := feast.initRoute(feastType)
243-
if err := feast.Handler.DeleteOwnedFeastObj(route); err != nil && !apierrors.IsNotFound(err) {
243+
if err := feast.Handler.DeleteOwnedFeastObj(route); err != nil {
244244
return err
245245
}
246246
return nil
@@ -423,15 +423,11 @@ func (feast *FeastServices) setContainer(containers *[]corev1.Container, feastTy
423423
}
424424

425425
func (feast *FeastServices) setRoute(route *routev1.Route, feastType FeastServiceType) error {
426+
426427
svcName := feast.GetFeastServiceName(feastType)
427428
route.Labels = feast.getFeastTypeLabels(feastType)
428429

429430
tls := feast.getTlsConfigs(feastType)
430-
/* scheme := HttpScheme
431-
if tls.IsTLS() {
432-
scheme = HttpsScheme
433-
}*/
434-
435431
route.Spec = routev1.RouteSpec{
436432
To: routev1.RouteTargetReference{
437433
Kind: "Service",
@@ -440,9 +436,12 @@ func (feast *FeastServices) setRoute(route *routev1.Route, feastType FeastServic
440436
Port: &routev1.RoutePort{
441437
TargetPort: intstr.FromInt(int(getTargetPort(feastType, tls))),
442438
},
443-
TLS: &routev1.TLSConfig{
444-
Termination: routev1.TLSTerminationEdge,
445-
},
439+
}
440+
if tls.IsTLS() {
441+
route.Spec.TLS = &routev1.TLSConfig{
442+
Termination: routev1.TLSTerminationPassthrough,
443+
InsecureEdgeTerminationPolicy: routev1.InsecureEdgeTerminationPolicyRedirect,
444+
}
446445
}
447446

448447
return controllerutil.SetControllerReference(feast.Handler.FeatureStore, route, feast.Handler.Scheme)

infra/feast-operator/internal/controller/services/tls.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ func (feast *FeastServices) setTlsDefaults() error {
3737
if feast.isLocalRegistry() {
3838
tlsDefaults(appliedServices.Registry.Local.TLS)
3939
}
40+
if feast.isUI() {
41+
tlsDefaults(appliedServices.UI.TLS)
42+
}
4043
return nil
4144
}
4245

@@ -56,6 +59,14 @@ func (feast *FeastServices) setOpenshiftTls() error {
5659
},
5760
}
5861
}
62+
if feast.uiOpenshiftTls() {
63+
appliedServices.UI.TLS = &feastdevv1alpha1.TlsConfigs{
64+
SecretRef: &corev1.LocalObjectReference{
65+
Name: feast.initFeastSvc(UIFeastType).Name + tlsNameSuffix,
66+
},
67+
}
68+
}
69+
5970
if feast.localRegistryOpenshiftTls() {
6071
appliedServices.Registry.Local.TLS = &feastdevv1alpha1.TlsConfigs{
6172
SecretRef: &corev1.LocalObjectReference{
@@ -79,7 +90,7 @@ func (feast *FeastServices) setOpenshiftTls() error {
7990
}
8091

8192
func (feast *FeastServices) checkOpenshiftTls() (bool, error) {
82-
if feast.offlineOpenshiftTls() || feast.onlineOpenshiftTls() || feast.localRegistryOpenshiftTls() {
93+
if feast.offlineOpenshiftTls() || feast.onlineOpenshiftTls() || feast.localRegistryOpenshiftTls() || feast.uiOpenshiftTls() {
8394
return true, nil
8495
}
8596
return feast.remoteRegistryOpenshiftTls()
@@ -93,7 +104,10 @@ func (feast *FeastServices) isOpenShiftTls(feastType FeastServiceType) (isOpenSh
93104
isOpenShift = feast.onlineOpenshiftTls()
94105
case RegistryFeastType:
95106
isOpenShift = feast.localRegistryOpenshiftTls()
107+
case UIFeastType:
108+
isOpenShift = feast.uiOpenshiftTls()
96109
}
110+
97111
return
98112
}
99113

@@ -132,6 +146,12 @@ func (feast *FeastServices) onlineOpenshiftTls() bool {
132146
feast.isOnlinStore() && feast.Handler.FeatureStore.Spec.Services.OnlineStore.TLS == nil
133147
}
134148

149+
// True if running in an openshift cluster and Tls not configured in the service Spec
150+
func (feast *FeastServices) uiOpenshiftTls() bool {
151+
return isOpenShift &&
152+
feast.isUI() && feast.Handler.FeatureStore.Spec.Services.UI.TLS == nil
153+
}
154+
135155
// True if running in an openshift cluster and Tls not configured in the service Spec
136156
func (feast *FeastServices) localRegistryOpenshiftTls() bool {
137157
return isOpenShift &&
@@ -180,6 +200,7 @@ func (feast *FeastServices) mountTlsConfigs(podSpec *corev1.PodSpec) {
180200
feast.mountRegistryClientTls(podSpec)
181201
feast.mountTlsConfig(OfflineFeastType, podSpec)
182202
feast.mountTlsConfig(OnlineFeastType, podSpec)
203+
feast.mountTlsConfig(UIFeastType, podSpec)
183204
}
184205

185206
func (feast *FeastServices) mountTlsConfig(feastType FeastServiceType, podSpec *corev1.PodSpec) {

infra/feast-operator/internal/controller/services/tls_test.go

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ var _ = Describe("TLS Config", func() {
6363
Expect(feast.isOpenShiftTls(OfflineFeastType)).To(BeFalse())
6464
Expect(feast.isOpenShiftTls(OnlineFeastType)).To(BeFalse())
6565
Expect(feast.isOpenShiftTls(RegistryFeastType)).To(BeFalse())
66+
Expect(feast.isOpenShiftTls(UIFeastType)).To(BeFalse())
67+
6668
openshiftTls, err := feast.checkOpenshiftTls()
6769
Expect(err).ToNot(HaveOccurred())
6870
Expect(openshiftTls).To(BeFalse())
@@ -79,6 +81,9 @@ var _ = Describe("TLS Config", func() {
7981
tls = feast.getTlsConfigs(OnlineFeastType)
8082
Expect(tls).To(BeNil())
8183
Expect(tls.IsTLS()).To(BeFalse())
84+
tls = feast.getTlsConfigs(UIFeastType)
85+
Expect(tls).To(BeNil())
86+
Expect(tls.IsTLS()).To(BeFalse())
8287
tls = feast.getTlsConfigs(RegistryFeastType)
8388
Expect(tls).NotTo(BeNil())
8489
Expect(tls.IsTLS()).To(BeTrue())
@@ -90,7 +95,9 @@ var _ = Describe("TLS Config", func() {
9095
Expect(feast.localRegistryTls()).To(BeTrue())
9196
Expect(feast.isOpenShiftTls(OfflineFeastType)).To(BeFalse())
9297
Expect(feast.isOpenShiftTls(OnlineFeastType)).To(BeFalse())
98+
Expect(feast.isOpenShiftTls(UIFeastType)).To(BeFalse())
9399
Expect(feast.isOpenShiftTls(RegistryFeastType)).To(BeTrue())
100+
94101
openshiftTls, err = feast.checkOpenshiftTls()
95102
Expect(err).ToNot(HaveOccurred())
96103
Expect(openshiftTls).To(BeTrue())
@@ -124,12 +131,19 @@ var _ = Describe("TLS Config", func() {
124131
Expect(tls.SecretRef.Name).To(Equal("feast-test-registry-tls"))
125132
Expect(tls.SecretKeyNames).To(Equal(secretKeyNames))
126133
Expect(tls.IsTLS()).To(BeTrue())
134+
tls = feast.getTlsConfigs(UIFeastType)
135+
Expect(tls).NotTo(BeNil())
136+
Expect(tls.SecretRef).NotTo(BeNil())
137+
Expect(tls.SecretRef.Name).To(Equal("feast-test-ui-tls"))
138+
Expect(tls.SecretKeyNames).To(Equal(secretKeyNames))
139+
Expect(tls.IsTLS()).To(BeTrue())
127140

128141
Expect(feast.remoteRegistryTls()).To(BeFalse())
129142
Expect(feast.localRegistryTls()).To(BeTrue())
130143
Expect(feast.isOpenShiftTls(OfflineFeastType)).To(BeTrue())
131144
Expect(feast.isOpenShiftTls(OnlineFeastType)).To(BeTrue())
132145
Expect(feast.isOpenShiftTls(RegistryFeastType)).To(BeTrue())
146+
Expect(feast.isOpenShiftTls(UIFeastType)).To(BeTrue())
133147
openshiftTls, err = feast.checkOpenshiftTls()
134148
Expect(err).ToNot(HaveOccurred())
135149
Expect(openshiftTls).To(BeTrue())
@@ -139,18 +153,22 @@ var _ = Describe("TLS Config", func() {
139153
err = feast.setDeployment(feastDeploy)
140154
Expect(err).ToNot(HaveOccurred())
141155
Expect(feastDeploy.Spec.Template.Spec.InitContainers).To(HaveLen(1))
142-
Expect(feastDeploy.Spec.Template.Spec.Containers).To(HaveLen(3))
156+
Expect(feastDeploy.Spec.Template.Spec.Containers).To(HaveLen(4))
143157
Expect(feastDeploy.Spec.Template.Spec.Containers[0].Command).To(ContainElements(ContainSubstring("--key")))
144158
Expect(feastDeploy.Spec.Template.Spec.Containers[1].Command).To(ContainElements(ContainSubstring("--key")))
145159
Expect(feastDeploy.Spec.Template.Spec.Containers[2].Command).To(ContainElements(ContainSubstring("--key")))
146-
Expect(feastDeploy.Spec.Template.Spec.Volumes).To(HaveLen(4))
160+
Expect(feastDeploy.Spec.Template.Spec.Containers[3].Command).To(ContainElements(ContainSubstring("--key")))
161+
Expect(feastDeploy.Spec.Template.Spec.Volumes).To(HaveLen(5))
147162

148163
// registry service w/ tls and in an openshift cluster
149164
feast.Handler.FeatureStore = minimalFeatureStore()
150165
feast.Handler.FeatureStore.Spec.Services = &feastdevv1alpha1.FeatureStoreServices{
151166
OnlineStore: &feastdevv1alpha1.OnlineStore{
152167
TLS: &feastdevv1alpha1.TlsConfigs{},
153168
},
169+
UI: &feastdevv1alpha1.UIService{
170+
TLS: &feastdevv1alpha1.TlsConfigs{},
171+
},
154172
Registry: &feastdevv1alpha1.Registry{
155173
Local: &feastdevv1alpha1.LocalRegistryConfig{
156174
TLS: &feastdevv1alpha1.TlsConfigs{
@@ -171,17 +189,20 @@ var _ = Describe("TLS Config", func() {
171189
tls = feast.getTlsConfigs(OnlineFeastType)
172190
Expect(tls).NotTo(BeNil())
173191
Expect(tls.IsTLS()).To(BeFalse())
192+
tls = feast.getTlsConfigs(UIFeastType)
193+
Expect(tls).NotTo(BeNil())
194+
Expect(tls.IsTLS()).To(BeFalse())
174195
tls = feast.getTlsConfigs(RegistryFeastType)
175196
Expect(tls).NotTo(BeNil())
176197
Expect(tls.IsTLS()).To(BeTrue())
177198
Expect(tls.SecretKeyNames).NotTo(Equal(secretKeyNames))
178199
Expect(getPortStr(tls)).To(Equal("443"))
179200
Expect(GetTlsPath(RegistryFeastType)).To(Equal("/tls/registry/"))
180-
181201
Expect(feast.remoteRegistryTls()).To(BeFalse())
182202
Expect(feast.localRegistryTls()).To(BeTrue())
183203
Expect(feast.isOpenShiftTls(OfflineFeastType)).To(BeFalse())
184204
Expect(feast.isOpenShiftTls(OnlineFeastType)).To(BeFalse())
205+
Expect(feast.isOpenShiftTls(UIFeastType)).To(BeFalse())
185206
Expect(feast.isOpenShiftTls(RegistryFeastType)).To(BeFalse())
186207
openshiftTls, err = feast.checkOpenshiftTls()
187208
Expect(err).ToNot(HaveOccurred())
@@ -193,6 +214,9 @@ var _ = Describe("TLS Config", func() {
193214
feast.Handler.FeatureStore.Spec.Services.OnlineStore.TLS = &feastdevv1alpha1.TlsConfigs{
194215
Disable: &disable,
195216
}
217+
feast.Handler.FeatureStore.Spec.Services.UI.TLS = &feastdevv1alpha1.TlsConfigs{
218+
Disable: &disable,
219+
}
196220
feast.Handler.FeatureStore.Spec.Services.Registry = &feastdevv1alpha1.Registry{
197221
Local: &feastdevv1alpha1.LocalRegistryConfig{
198222
TLS: &feastdevv1alpha1.TlsConfigs{
@@ -219,6 +243,10 @@ var _ = Describe("TLS Config", func() {
219243
Expect(tls).NotTo(BeNil())
220244
Expect(tls.IsTLS()).To(BeFalse())
221245
Expect(tls.SecretKeyNames).NotTo(Equal(secretKeyNames))
246+
tls = feast.getTlsConfigs(UIFeastType)
247+
Expect(tls).NotTo(BeNil())
248+
Expect(tls.IsTLS()).To(BeFalse())
249+
Expect(tls.SecretKeyNames).NotTo(Equal(secretKeyNames))
222250
tls = feast.getTlsConfigs(RegistryFeastType)
223251
Expect(tls).NotTo(BeNil())
224252
Expect(tls.IsTLS()).To(BeFalse())
@@ -230,6 +258,7 @@ var _ = Describe("TLS Config", func() {
230258
Expect(feast.localRegistryTls()).To(BeFalse())
231259
Expect(feast.isOpenShiftTls(OfflineFeastType)).To(BeTrue())
232260
Expect(feast.isOpenShiftTls(OnlineFeastType)).To(BeFalse())
261+
Expect(feast.isOpenShiftTls(UIFeastType)).To(BeFalse())
233262
Expect(feast.isOpenShiftTls(RegistryFeastType)).To(BeFalse())
234263
openshiftTls, err = feast.checkOpenshiftTls()
235264
Expect(err).ToNot(HaveOccurred())
@@ -249,11 +278,17 @@ var _ = Describe("TLS Config", func() {
249278
Expect(onlineSvc.Annotations).To(BeEmpty())
250279
Expect(onlineSvc.Spec.Ports[0].Name).To(Equal(HttpScheme))
251280

281+
uiSvc := feast.initFeastSvc(UIFeastType)
282+
err = feast.setService(uiSvc, UIFeastType)
283+
Expect(err).ToNot(HaveOccurred())
284+
Expect(uiSvc.Annotations).To(BeEmpty())
285+
Expect(uiSvc.Spec.Ports[0].Name).To(Equal(HttpScheme))
286+
252287
// check k8s deployment objects
253288
feastDeploy = feast.initFeastDeploy()
254289
err = feast.setDeployment(feastDeploy)
255290
Expect(err).ToNot(HaveOccurred())
256-
Expect(feastDeploy.Spec.Template.Spec.Containers).To(HaveLen(3))
291+
Expect(feastDeploy.Spec.Template.Spec.Containers).To(HaveLen(4))
257292
Expect(GetOfflineContainer(*feastDeploy)).NotTo(BeNil())
258293
Expect(feastDeploy.Spec.Template.Spec.Volumes).To(HaveLen(2))
259294

@@ -263,6 +298,9 @@ var _ = Describe("TLS Config", func() {
263298
Expect(GetOfflineContainer(*feastDeploy).VolumeMounts).To(HaveLen(2))
264299
Expect(GetOnlineContainer(*feastDeploy).Command).NotTo(ContainElements(ContainSubstring("--key")))
265300
Expect(GetOnlineContainer(*feastDeploy).VolumeMounts).To(HaveLen(1))
301+
Expect(GetUIContainer(*feastDeploy).Command).NotTo(ContainElements(ContainSubstring("--key")))
302+
Expect(GetUIContainer(*feastDeploy).VolumeMounts).To(HaveLen(1))
303+
266304
})
267305
})
268306
})

infra/feast-operator/test/e2e/e2e_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func validateTheFeatureStoreCustomResource(namespace string, featureStoreName st
167167
feastK8sResourceNames := []string{
168168
feastResourceName + "-online",
169169
feastResourceName + "-offline",
170+
feastResourceName + "-ui",
170171
}
171172

172173
if !hasRemoteRegistry {

infra/feast-operator/test/testdata/feast_integration_test_crs/v1alpha1_default_featurestore.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ spec:
77
services:
88
onlineStore: {}
99
offlineStore: {}
10+
ui: {}

infra/feast-operator/test/testdata/feast_integration_test_crs/v1alpha1_remote_registry_featurestore.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ spec:
77
services:
88
onlineStore: {}
99
offlineStore: {}
10+
ui: {}
1011
registry:
1112
remote:
1213
feastRef:

0 commit comments

Comments
 (0)