From b889967ce0563294ff56a16c96270acb78619225 Mon Sep 17 00:00:00 2001 From: Arnau Verdaguer Date: Mon, 11 Nov 2024 15:22:11 +0100 Subject: [PATCH] Use dns cluster info from lib common get function Openshift coreDNS creates the domain name using an string located in dnses.operator.openshift.io. This string can change in the future, calling lib-common/GetDNSClusterDomain the responsability of gathering this information correctly only falls under lib-common intead of all operators. Resolves: OSPRH-3627 Depends-on: https://github.com/openstack-k8s-operators/lib-common/pull/580 --- api/v1beta1/ovndbcluster_types.go | 4 ---- controllers/ovndbcluster_controller.go | 5 ++++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/api/v1beta1/ovndbcluster_types.go b/api/v1beta1/ovndbcluster_types.go index 91a31d61..c89b6fe2 100644 --- a/api/v1beta1/ovndbcluster_types.go +++ b/api/v1beta1/ovndbcluster_types.go @@ -39,10 +39,6 @@ const ( // ServiceClusterType - Constant to identify Cluster services ServiceClusterType = "cluster" - // DNSSuffix : hardcoded value on how DNSCore domain is configured - DNSSuffix = "cluster.local" - // TODO: retrieve it from environment - // Container image fall-back defaults // OVNNBContainerImage is the fall-back container image for OVNDBCluster NB diff --git a/controllers/ovndbcluster_controller.go b/controllers/ovndbcluster_controller.go index 4a21566a..70bcd06b 100644 --- a/controllers/ovndbcluster_controller.go +++ b/controllers/ovndbcluster_controller.go @@ -39,6 +39,7 @@ import ( infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/common" + "github.com/openstack-k8s-operators/lib-common/modules/common/clusterdns" "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/configmap" "github.com/openstack-k8s-operators/lib-common/modules/common/env" @@ -97,6 +98,7 @@ func (r *OVNDBClusterReconciler) GetLogger(ctx context.Context) logr.Logger { //+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list; //+kubebuilder:rbac:groups=k8s.cni.cncf.io,resources=network-attachment-definitions,verbs=get;list;watch //+kubebuilder:rbac:groups=network.openstack.org,resources=dnsdata,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups="operator.openshift.io",resources=dnses,verbs=get;list;watch // service account, role, rolebinding // +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch @@ -615,7 +617,8 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance * // Filter out headless services if svc.Spec.ClusterIP != "None" { - internalDbAddress = append(internalDbAddress, fmt.Sprintf("%s:%s.%s.svc.%s:%d", scheme, svc.Name, svc.Namespace, ovnv1.DNSSuffix, svcPort)) + clusterDomain := clusterdns.getDNSClusterDomain() + internalDbAddress = append(internalDbAddress, fmt.Sprintf("%s:%s.%s.svc.%s:%d", scheme, svc.Name, svc.Namespace, clusterDomain, svcPort)) } }