Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw: add vhost style support for rgw in ocs-op #2515

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))
}
} 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.

Loading