Skip to content

Commit

Permalink
rgw: add vhost style support for rgw in ocs-op
Browse files Browse the repository at this point in the history
Signed-off-by: Jiffin Tony Thottan <[email protected]>
  • Loading branch information
thotz committed Mar 21, 2024
1 parent 16f3414 commit cb9d50b
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/v1/storagecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ type ManageCephObjectStores struct {
// StorageClassName specifies the name of the storage class created for ceph obc's
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
StorageClassName string `json:"storageClassName,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
VirtualHostnames []string `json:"virtualHostnames,omitempty"`
}

// ManageCephObjectStoreUsers defines how to reconcile CephObjectStoreUsers
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ spec:
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
virtualHostnames:
items:
type: string
type: array
type: object
cephRBDMirror:
description: ManageCephRBDMirror defines how to reconcile Ceph
Expand Down
23 changes: 23 additions & 0 deletions controllers/storagecluster/cephobjectstores.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

routev1 "github.com/openshift/api/route/v1"
ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
"github.com/red-hat-storage/ocs-operator/v4/controllers/defaults"
"github.com/red-hat-storage/ocs-operator/v4/controllers/platform"
Expand Down Expand Up @@ -201,6 +202,28 @@ func (r *StorageClusterReconciler) newCephObjectStoreInstances(initData *ocsv1.S
return nil, err
}

if len(initData.Spec.ManagedResources.CephObjectStores.VirtualHostnames) > 0 {
obj.Spec.Hosting.DNSNames = initData.Spec.ManagedResources.CephObjectStores.VirtualHostnames
route := &routev1.Route{}
err := r.Client.Get(context.TODO(), types.NamespacedName{Name: obj.Name, Namespace: obj.Namespace}, route)
if err != nil {
if errors.IsNotFound(err) {
r.Log.Info("Ceph RGW Route not found.", "CephRGWRoute", klog.KRef(obj.Namespace, obj.Name))
}
} else {
obj.Spec.Hosting.DNSNames = append(obj.Spec.Hosting.DNSNames, route.Spec.Host)
}
secureRoute := &routev1.Route{}
err = r.Client.Get(context.TODO(), types.NamespacedName{Name: obj.Name + "-secure", Namespace: obj.Namespace}, secureRoute)
if err != nil {
if errors.IsNotFound(err) {
r.Log.Info("Ceph RGW Route not found.", "CephRGWRoute", klog.KRef(obj.Namespace, obj.Name + "-secure"))

Check failure on line 220 in controllers/storagecluster/cephobjectstores.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.21)

File is not `gofmt`-ed with `-s` (gofmt)
}
} else {
obj.Spec.Hosting.DNSNames = append(obj.Spec.Hosting.DNSNames, secureRoute.Spec.Host)
}
}

if initData.Spec.ManagedResources.CephObjectStores.HostNetwork != nil {
obj.Spec.Gateway.HostNetwork = initData.Spec.ManagedResources.CephObjectStores.HostNetwork
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ spec:
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
virtualHostnames:
items:
type: string
type: array
type: object
cephRBDMirror:
description: ManageCephRBDMirror defines how to reconcile Ceph
Expand Down
4 changes: 4 additions & 0 deletions deploy/ocs-operator/manifests/storagecluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,10 @@ spec:
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
virtualHostnames:
items:
type: string
type: array
type: object
cephRBDMirror:
description: ManageCephRBDMirror defines how to reconcile Ceph
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cb9d50b

Please sign in to comment.