-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DNS entry for ovsdbserver- services
When the ovsdbserver-sb/nb pod gets deleted we can't ensure that it will be recreated with the same internalapi IP, since that IP is popullated to the EDPM nodes during ansibleee-deployment_phase, if the IP changes during reboot of the pod EDPM won't know until user retriggers ansibleee-deployment_phase. This will mean that meanwhile ovn_controller and neutron-ovn-metadata won't have connectivity to the SB DB. In order to fix this instead of using a string of IPs on the ovn-remote a single DNS entry will be used. Every service will add an entries to the openstack-dnsmasq: - ovsdbserver-xb.openstack.svc The last one will be the one popullated to the EDPM node, as querying it will return one IP from all the SB pods initialized at that moment (dns will use sequential round-robin to fulfill the request). Depends-on: openstack-k8s-operators/install_yamls#686 Resolves: OSPRH-660
- Loading branch information
Showing
13 changed files
with
431 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package ovndbcluster | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" | ||
"github.com/openstack-k8s-operators/lib-common/modules/common/helper" | ||
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" | ||
) | ||
|
||
// DNSData - Create DNS entry that openstack dnsmasq will resolve | ||
func DNSData( | ||
ctx context.Context, | ||
helper *helper.Helper, | ||
serviceName string, | ||
ip string, | ||
instance *ovnv1.OVNDBCluster, | ||
ovnPod corev1.Pod, | ||
serviceLabels map[string]string, | ||
) error { | ||
// ovsdbserver-(sb|nb) entry | ||
headlessDNSHostname := serviceName + "." + instance.Namespace + ".svc" | ||
dnsHostCname := infranetworkv1.DNSHost{ | ||
IP: ip, | ||
Hostnames: []string{ | ||
headlessDNSHostname, | ||
}, | ||
} | ||
|
||
// Create DNSData object | ||
dnsData := &infranetworkv1.DNSData{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: ovnPod.Name, | ||
Namespace: ovnPod.Namespace, | ||
Labels: serviceLabels, | ||
}, | ||
} | ||
dnsHosts := []infranetworkv1.DNSHost{dnsHostCname} | ||
|
||
_, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), dnsData, func() error { | ||
dnsData.Spec.Hosts = dnsHosts | ||
// TODO: use value from DNSMasq instance instead of hardcode | ||
dnsData.Spec.DNSDataLabelSelectorValue = "dnsdata" | ||
err := controllerutil.SetControllerReference(helper.GetBeforeObject(), dnsData, helper.GetScheme()) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("Error creating DNSData %s: %w", dnsData.Name, err) | ||
} | ||
return nil | ||
} | ||
|
||
// GetDBAddress - return string connection for the given service | ||
func GetDBAddress(svc *corev1.Service, serviceName string, namespace string) string { | ||
if svc == nil { | ||
return "" | ||
} | ||
headlessDNSHostname := serviceName + "." + namespace + ".svc" | ||
return fmt.Sprintf("tcp:%s:%d", headlessDNSHostname, svc.Spec.Ports[0].Port) | ||
} |
Oops, something went wrong.