From 0a972a0850e80260e152b71abf344a4dc897aafe Mon Sep 17 00:00:00 2001 From: root Date: Tue, 14 Mar 2023 21:11:24 +0800 Subject: [PATCH] rgw: allow the rgw dashboard to be disabled The rgw dashboard can be disabled by the setting in the CephObjectStore `gateway.dashboardEnabled` if set to false. Signed-off-by: xiaobaowen (cherry picked from commit 253d4123f68353cabb4cdb9d4341733867e03218) --- deploy/charts/rook-ceph/templates/resources.yaml | 5 +++++ deploy/examples/crds.yaml | 5 +++++ pkg/apis/ceph.rook.io/v1/object.go | 4 ++++ pkg/apis/ceph.rook.io/v1/types.go | 6 ++++++ pkg/operator/ceph/object/rgw.go | 8 ++++++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 04ecbfe86..6973a53b3 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -11948,6 +11948,11 @@ spec: description: The name of the secret that stores custom ca-bundle with root and intermediate certificates. nullable: true type: string + dashboardEnabled: + description: Whether rgw dashboard is enabled for the rgw daemon. If not set, the rgw dashboard will be enabled. + nullable: true + type: boolean + x-kubernetes-preserve-unknown-fields: true externalRgwEndpoints: description: ExternalRgwEndpoints points to external RGW endpoint(s). Multiple endpoints can be given, but for stability of ObjectBucketClaims, we highly recommend that users give only a single external RGW endpoint that is a load balancer that sends requests to the multiple RGWs. items: diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 4c8d5c12d..40f17ac20 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -11940,6 +11940,11 @@ spec: description: The name of the secret that stores custom ca-bundle with root and intermediate certificates. nullable: true type: string + dashboardEnabled: + description: Whether rgw dashboard is enabled for the rgw daemon. If not set, the rgw dashboard will be enabled. + nullable: true + type: boolean + x-kubernetes-preserve-unknown-fields: true externalRgwEndpoints: description: ExternalRgwEndpoints points to external RGW endpoint(s). Multiple endpoints can be given, but for stability of ObjectBucketClaims, we highly recommend that users give only a single external RGW endpoint that is a load balancer that sends requests to the multiple RGWs. items: diff --git a/pkg/apis/ceph.rook.io/v1/object.go b/pkg/apis/ceph.rook.io/v1/object.go index 47161d3cc..a6ae0081d 100644 --- a/pkg/apis/ceph.rook.io/v1/object.go +++ b/pkg/apis/ceph.rook.io/v1/object.go @@ -41,6 +41,10 @@ func (s *ObjectStoreSpec) IsTLSEnabled() bool { return s.Gateway.SecurePort != 0 && (s.Gateway.SSLCertificateRef != "" || s.GetServiceServingCert() != "") } +func (s *ObjectStoreSpec) IsRGWDashboardEnabled() bool { + return s.Gateway.DashboardEnabled == nil || *s.Gateway.DashboardEnabled +} + func (s *ObjectStoreSpec) GetPort() (int32, error) { if s.IsTLSEnabled() { return s.Gateway.SecurePort, nil diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 28e54893a..52762d9aa 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -1458,6 +1458,12 @@ type GatewaySpec struct { // +nullable // +optional HostNetwork *bool `json:"hostNetwork,omitempty"` + + // Whether rgw dashboard is enabled for the rgw daemon. If not set, the rgw dashboard will be enabled. + // +kubebuilder:pruning:PreserveUnknownFields + // +nullable + // +optional + DashboardEnabled *bool `json:"dashboardEnabled,omitempty"` } // EndpointAddress is a tuple that describes a single IP address or host name. This is a subset of diff --git a/pkg/operator/ceph/object/rgw.go b/pkg/operator/ceph/object/rgw.go index b396c5b9c..889b7494a 100644 --- a/pkg/operator/ceph/object/rgw.go +++ b/pkg/operator/ceph/object/rgw.go @@ -82,8 +82,12 @@ func (c *clusterConfig) createOrUpdateStore(realmName, zoneGroupName, zoneName s return nil } - if err = enableRGWDashboard(objContext); err != nil { - logger.Warningf("failed to enable dashboard for rgw. %v", err) + if c.clusterSpec.Dashboard.Enabled { + if !c.store.Spec.IsRGWDashboardEnabled() { + disableRGWDashboard(objContext) + } else if err = enableRGWDashboard(objContext); err != nil { + logger.Warningf("failed to enable dashboard for rgw. %v", err) + } } logger.Infof("created object store %q in namespace %q", c.store.Name, c.store.Namespace)