From 3fbcff5127a3a34217592aa9df275d6cff3bcfbc Mon Sep 17 00:00:00 2001 From: parth-gr Date: Mon, 22 May 2023 18:23:32 +0530 Subject: [PATCH] external: fqdn should be persisted 1) donot change rgw fqdn to ip if provided, As now the bucket class supports the entry of fqdn 2) update crds with new description in EndpointAddress Signed-off-by: parth-gr (cherry picked from commit f66de7b9df94bdf02b6d38b1a9cb1e4e63fdda81) --- .../Object-Storage/ceph-object-store-crd.md | 1 + Documentation/CRDs/specification.md | 4 ++-- .../Object-Storage-RGW/object-storage.md | 1 + .../charts/rook-ceph/templates/resources.yaml | 4 ++-- deploy/examples/crds.yaml | 4 ++-- .../create-external-cluster-resources-tests.py | 9 --------- .../create-external-cluster-resources.py | 18 ------------------ deploy/examples/object-external.yaml | 1 + pkg/apis/ceph.rook.io/v1/types.go | 5 +++-- 9 files changed, 12 insertions(+), 35 deletions(-) diff --git a/Documentation/CRDs/Object-Storage/ceph-object-store-crd.md b/Documentation/CRDs/Object-Storage/ceph-object-store-crd.md index 989ef96e7..69c45428b 100644 --- a/Documentation/CRDs/Object-Storage/ceph-object-store-crd.md +++ b/Documentation/CRDs/Object-Storage/ceph-object-store-crd.md @@ -135,6 +135,7 @@ gateway: port: 80 externalRgwEndpoints: - ip: 192.168.39.182 + # hostname: example.com ``` This will create a service with the endpoint `192.168.39.182` on port `80`, pointing to the Ceph object external gateway. diff --git a/Documentation/CRDs/specification.md b/Documentation/CRDs/specification.md index f9d232b15..66c239809 100644 --- a/Documentation/CRDs/specification.md +++ b/Documentation/CRDs/specification.md @@ -4850,7 +4850,7 @@ string (Optional) -

The IP of this endpoint.

+

The IP of this endpoint. As a legacy behavior, this supports being given a DNS-adressable hostname as well.

@@ -4862,7 +4862,7 @@ string (Optional) -

The Hostname of this endpoint

+

The DNS-addressable Hostname of this endpoint. This field will be preferred over IP if both are given.

diff --git a/Documentation/Storage-Configuration/Object-Storage-RGW/object-storage.md b/Documentation/Storage-Configuration/Object-Storage-RGW/object-storage.md index 8992e5d6d..113537597 100644 --- a/Documentation/Storage-Configuration/Object-Storage-RGW/object-storage.md +++ b/Documentation/Storage-Configuration/Object-Storage-RGW/object-storage.md @@ -93,6 +93,7 @@ spec: port: 8080 externalRgwEndpoints: - ip: 192.168.39.182 + # hostname: example.com ``` Use the existing `object-external.yaml` file. Even though multiple endpoints can be specified, it is recommend to use only one endpoint. This endpoint is randomly added to `configmap` of OBC and secret of the `cephobjectstoreuser`. Rook never guarantees the randomly picked endpoint is a working one or not. diff --git a/deploy/charts/rook-ceph/templates/resources.yaml b/deploy/charts/rook-ceph/templates/resources.yaml index 6c09a0ce1..b4bc15865 100644 --- a/deploy/charts/rook-ceph/templates/resources.yaml +++ b/deploy/charts/rook-ceph/templates/resources.yaml @@ -9160,10 +9160,10 @@ spec: description: EndpointAddress is a tuple that describes a single IP address or host name. This is a subset of Kubernetes's v1.EndpointAddress. properties: hostname: - description: The Hostname of this endpoint + description: The DNS-addressable Hostname of this endpoint. This field will be preferred over IP if both are given. type: string ip: - description: The IP of this endpoint. + description: The IP of this endpoint. As a legacy behavior, this supports being given a DNS-adressable hostname as well. type: string type: object x-kubernetes-map-type: atomic diff --git a/deploy/examples/crds.yaml b/deploy/examples/crds.yaml index 0edae70fb..21828e2df 100644 --- a/deploy/examples/crds.yaml +++ b/deploy/examples/crds.yaml @@ -9152,10 +9152,10 @@ spec: description: EndpointAddress is a tuple that describes a single IP address or host name. This is a subset of Kubernetes's v1.EndpointAddress. properties: hostname: - description: The Hostname of this endpoint + description: The DNS-addressable Hostname of this endpoint. This field will be preferred over IP if both are given. type: string ip: - description: The IP of this endpoint. + description: The IP of this endpoint. As a legacy behavior, this supports being given a DNS-adressable hostname as well. type: string type: object x-kubernetes-map-type: atomic diff --git a/deploy/examples/create-external-cluster-resources-tests.py b/deploy/examples/create-external-cluster-resources-tests.py index bc35e0f4c..98fe7ecf9 100644 --- a/deploy/examples/create-external-cluster-resources-tests.py +++ b/deploy/examples/create-external-cluster-resources-tests.py @@ -187,15 +187,6 @@ class TestRadosJSON(unittest.TestCase): except ext.ExecutionFailureException as err: print(f"Successfully thrown error: {err}") - def test_convert_fqdn_rgw_endpoint_to_ip(self): - try: - rgw_endpoint_ip = self.rjObj.convert_fqdn_rgw_endpoint_to_ip( - "www.redhat.com:80" - ) - print(f"Successfully Converted www.redhat.com to it's IP {rgw_endpoint_ip}") - except ext.ExecutionFailureException as err: - print(f"Successfully thrown error: {err}") - def test_upgrade_user_permissions(self): self.rjObj = ext.RadosJSON( [ diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index 0c36f5547..62e4b1d1d 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -1229,19 +1229,6 @@ class RadosJSON: "", ) - def convert_fqdn_rgw_endpoint_to_ip(self, fqdn_rgw_endpoint): - try: - fqdn, port = fqdn_rgw_endpoint.split(":") - except ValueError: - raise ExecutionFailureException( - f"Not a proper endpoint: {fqdn_rgw_endpoint}, " - ":, format is expected" - ) - rgw_endpoint_ip = self._convert_hostname_to_ip(fqdn) - rgw_endpoint_port = port - rgw_endpoint = self._join_host_port(rgw_endpoint_ip, rgw_endpoint_port) - return rgw_endpoint - def validate_rbd_pool(self): if not self.cluster.pool_exists(self._arg_parser.rbd_data_pool_name): raise ExecutionFailureException( @@ -1325,7 +1312,6 @@ class RadosJSON: # check if the rgw endpoint is reachable rgw_endpoint = self._arg_parser.rgw_endpoint - self._invalid_endpoint(rgw_endpoint) cert = None if not self._arg_parser.rgw_skip_tls and self.validate_rgw_endpoint_tls_cert(): cert = self._arg_parser.rgw_tls_cert_path @@ -1390,10 +1376,6 @@ class RadosJSON: self._arg_parser.cluster_name = ( self._arg_parser.cluster_name.lower() ) # always convert cluster name to lowercase characters - if self._arg_parser.rgw_endpoint: - self._arg_parser.rgw_endpoint = self.convert_fqdn_rgw_endpoint_to_ip( - self._arg_parser.rgw_endpoint - ) self.validate_rbd_pool() self.validate_rados_namespace() self.validate_subvolume_group() diff --git a/deploy/examples/object-external.yaml b/deploy/examples/object-external.yaml index f7bd55558..d42e410af 100644 --- a/deploy/examples/object-external.yaml +++ b/deploy/examples/object-external.yaml @@ -16,3 +16,4 @@ spec: port: 80 externalRgwEndpoints: - ip: 192.168.39.182 + # hostname: example.com diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index cf2a5e95f..f6e176d60 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -1484,10 +1484,11 @@ type GatewaySpec struct { // Kubernetes's v1.EndpointAddress. // +structType=atomic type EndpointAddress struct { - // The IP of this endpoint. + // The IP of this endpoint. As a legacy behavior, this supports being given a DNS-adressable hostname as well. // +optional IP string `json:"ip" protobuf:"bytes,1,opt,name=ip"` - // The Hostname of this endpoint + + // The DNS-addressable Hostname of this endpoint. This field will be preferred over IP if both are given. // +optional Hostname string `json:"hostname,omitempty" protobuf:"bytes,3,opt,name=hostname"` }