diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 4642aaa98..6ee1a5855 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -112,7 +112,7 @@ type DashboardSpec struct { // The dashboard webserver port Port int `json:"port,omitempty"` // Whether SSL should be used - SSL *bool `json:"ssl,omitempty"` + SSL bool `json:"ssl,omitempty"` } // MonitoringSpec represents the settings for Prometheus based Ceph monitoring diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go index d1e534cce..74e783c01 100644 --- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go @@ -482,7 +482,7 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { out.DisruptionManagement = in.DisruptionManagement in.Mon.DeepCopyInto(&out.Mon) out.RBDMirroring = in.RBDMirroring - in.Dashboard.DeepCopyInto(&out.Dashboard) + out.Dashboard = in.Dashboard out.Monitoring = in.Monitoring out.External = in.External in.Mgr.DeepCopyInto(&out.Mgr) @@ -523,11 +523,6 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DashboardSpec) DeepCopyInto(out *DashboardSpec) { *out = *in - if in.SSL != nil { - in, out := &in.SSL, &out.SSL - *out = new(bool) - **out = **in - } return } diff --git a/pkg/operator/ceph/cluster/mgr/dashboard.go b/pkg/operator/ceph/cluster/mgr/dashboard.go index efa6c9370..fd50f8377 100755 --- a/pkg/operator/ceph/cluster/mgr/dashboard.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard.go @@ -27,8 +27,9 @@ import ( "time" "github.com/rook/rook/pkg/daemon/ceph/client" + cephver "github.com/rook/rook/pkg/operator/ceph/version" "github.com/rook/rook/pkg/operator/k8sutil" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -121,27 +122,33 @@ func (c *Cluster) configureDashboardModule(m *mgrConfig) error { return err } - // server port - port := strconv.Itoa(m.DashboardPort) - changed, err := client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/server_port", port, false) + // ssl support + ssl := strconv.FormatBool(c.dashboard.SSL) + changed, err := client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/ssl", ssl, false) if err != nil { return err } hasChanged = hasChanged || changed - // ssl support - var ssl string - if c.dashboard.SSL == nil { - ssl = "" - } else { - ssl = strconv.FormatBool(*c.dashboard.SSL) - } - changed, err = client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/ssl", ssl, false) + // server port + port := strconv.Itoa(m.DashboardPort) + changed, err = client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/server_port", port, false) if err != nil { return err } hasChanged = hasChanged || changed + // SSL enabled. Needed to set specifically the ssl port setting starting with Nautilus(14.2.1) + if c.dashboard.SSL { + if c.clusterInfo.CephVersion.IsAtLeast(cephver.CephVersion{Major: 14, Minor: 2, Extra: 1}) { + changed, err = client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/ssl_server_port", port, false) + if err != nil { + return err + } + hasChanged = hasChanged || changed + } + } + if hasChanged { logger.Infof("dashboard config has changed") return c.restartDashboard() @@ -158,7 +165,7 @@ func (c *Cluster) initializeSecureDashboard() error { return fmt.Errorf("failed to generate a password. %+v", err) } - if c.dashboard.SSL == nil || *c.dashboard.SSL { + if c.dashboard.SSL { alreadyCreated, err := c.createSelfSignedCert() if err != nil { return fmt.Errorf("failed to create a self signed cert. %+v", err) diff --git a/pkg/operator/ceph/cluster/mgr/dashboard_test.go b/pkg/operator/ceph/cluster/mgr/dashboard_test.go index 365305355..3e270554e 100644 --- a/pkg/operator/ceph/cluster/mgr/dashboard_test.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard_test.go @@ -102,7 +102,7 @@ func TestStartSecureDashboard(t *testing.T) { CephVersion: cephver.Mimic, } c := &Cluster{clusterInfo: clusterInfo, context: &clusterd.Context{Clientset: test.New(3), Executor: executor}, Namespace: "myns", - dashboard: cephv1.DashboardSpec{Enabled: true}, cephVersion: cephv1.CephVersionSpec{Image: "ceph/ceph:v13.2.2"}} + dashboard: cephv1.DashboardSpec{Enabled: true, SSL: true}, cephVersion: cephv1.CephVersionSpec{Image: "ceph/ceph:v13.2.2"}} c.exitCode = func(err error) (int, bool) { if exitCodeResponse != 0 { return exitCodeResponse, true