From d67ef2bcddd4c833b017b63685a844f896113ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= Date: Tue, 10 Sep 2019 14:56:51 +0200 Subject: [PATCH] Ceph: Use HTTP port if SSL is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using port 8443 / dashboardHTTPS when not running HTTPS is confusing, so use the dashboardHTTP port (7000 by default) instead. Also don't expose the dashboard port as "https-dashboard" when not using https, instead expose as "dashboard". Resolves #3810 Signed-off-by: Kristoffer Grönlund --- pkg/operator/ceph/cluster/mgr/config.go | 8 ++++++-- pkg/operator/ceph/cluster/mgr/mgr_test.go | 2 +- pkg/operator/ceph/cluster/mgr/spec.go | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/operator/ceph/cluster/mgr/config.go b/pkg/operator/ceph/cluster/mgr/config.go index 52ab6d25d..548fc3970 100644 --- a/pkg/operator/ceph/cluster/mgr/config.go +++ b/pkg/operator/ceph/cluster/mgr/config.go @@ -45,8 +45,12 @@ type mgrConfig struct { func (c *Cluster) dashboardPort() int { if c.dashboard.Port == 0 { - // select default port - return dashboardPortHTTPS + // default port for HTTP/HTTPS + if c.dashboard.SSL { + return dashboardPortHTTPS + } else { + return dashboardPortHTTP + } } // crd validates port >= 0 return c.dashboard.Port diff --git a/pkg/operator/ceph/cluster/mgr/mgr_test.go b/pkg/operator/ceph/cluster/mgr/mgr_test.go index bcf5d0bb2..1527ce3eb 100755 --- a/pkg/operator/ceph/cluster/mgr/mgr_test.go +++ b/pkg/operator/ceph/cluster/mgr/mgr_test.go @@ -63,7 +63,7 @@ func TestStartMGR(t *testing.T) { rookalpha.Placement{}, rookalpha.Annotations{}, cephv1.NetworkSpec{}, - cephv1.DashboardSpec{Enabled: true}, + cephv1.DashboardSpec{Enabled: true, SSL: true}, cephv1.MonitoringSpec{Enabled: true, RulesNamespace: ""}, cephv1.MgrSpec{}, v1.ResourceRequirements{}, diff --git a/pkg/operator/ceph/cluster/mgr/spec.go b/pkg/operator/ceph/cluster/mgr/spec.go index d9d85ae5d..d7274ce1d 100644 --- a/pkg/operator/ceph/cluster/mgr/spec.go +++ b/pkg/operator/ceph/cluster/mgr/spec.go @@ -309,6 +309,10 @@ func (c *Cluster) makeMetricsService(name string) *v1.Service { func (c *Cluster) makeDashboardService(name string, port int) *v1.Service { labels := opspec.AppLabels(appName, c.Namespace) + portName := "https-dashboard" + if !c.dashboard.SSL { + portName = "dashboard" + } svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("%s-dashboard", name), @@ -320,7 +324,7 @@ func (c *Cluster) makeDashboardService(name string, port int) *v1.Service { Type: v1.ServiceTypeClusterIP, Ports: []v1.ServicePort{ { - Name: "https-dashboard", + Name: portName, Port: int32(port), Protocol: v1.ProtocolTCP, },