Skip to content

Commit

Permalink
add proxy from UI to backend service
Browse files Browse the repository at this point in the history
Signed-off-by: Haoyu Sun <[email protected]>
  • Loading branch information
raptorsun committed Mar 19, 2024
1 parent b7becbb commit c92766c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions internal/controller/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ const (
ConsoleUIPluginDisplayName = "Lightspeed Console"
// ConsoleCRName is the name of the console custom resource
ConsoleCRName = "cluster"
// ConsoleProxyAlias is the alias of the console proxy
// The console backend exposes following proxy endpoint: /api/proxy/plugin/<plugin-name>/<proxy-alias>/<request-path>?<optional-query-parameters>
ConsoleProxyAlias = "ols"
)
14 changes: 14 additions & 0 deletions internal/controller/ols_console_ui_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ func (r *OLSConfigReconciler) generateConsoleUIPlugin(cr *olsv1alpha1.OLSConfig)
I18n: consolev1.ConsolePluginI18n{
LoadType: consolev1.Preload,
},
Proxy: []consolev1.ConsolePluginProxy{
{
Alias: ConsoleProxyAlias,
Authorization: consolev1.None,
Endpoint: consolev1.ConsolePluginProxyEndpoint{
Service: &consolev1.ConsolePluginProxyServiceConfig{
Name: OLSAppServerServiceName,
Namespace: r.Options.Namespace,
Port: OLSAppServerServicePort,
},
Type: consolev1.ProxyTypeService,
},
},
},
},
}

Expand Down
12 changes: 10 additions & 2 deletions internal/controller/ols_console_ui_assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"

logf "sigs.k8s.io/controller-runtime/pkg/log"

consolev1 "github.com/openshift/api/console/v1"
olsv1alpha1 "github.com/openshift/lightspeed-operator/api/v1alpha1"
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

var _ = Describe("Console UI assets", func() {
Expand Down Expand Up @@ -84,6 +84,14 @@ var _ = Describe("Console UI assets", func() {
Expect(plugin.Spec.Backend.Service.Namespace).To(Equal(OLSNamespaceDefault))
Expect(plugin.Spec.Backend.Service.Port).To(Equal(int32(ConsoleUIHTTPSPort)))
Expect(plugin.Spec.Backend.Service.BasePath).To(Equal("/"))
Expect(plugin.Spec.Backend.Type).To(Equal(consolev1.Service))

Expect(plugin.Spec.Proxy).To(HaveLen(1))
Expect(plugin.Spec.Proxy[0].Endpoint.Service.Name).To(Equal(OLSAppServerServiceName))
Expect(plugin.Spec.Proxy[0].Endpoint.Service.Port).To(Equal(int32(OLSAppServerServicePort)))
Expect(plugin.Spec.Proxy[0].Endpoint.Service.Namespace).To(Equal(OLSNamespaceDefault))
Expect(plugin.Spec.Proxy[0].Endpoint.Type).To(Equal(consolev1.ProxyTypeService))

})

})
Expand Down

0 comments on commit c92766c

Please sign in to comment.