mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 07:44:26 +02:00
use old LB DNS format when teamId prefix is disabled (#2011)
* use old LB DNS format when teamId prefix is disabled * support both old and new format in external-dns * switch dns template from team to namespace
This commit is contained in:
+32
-2
@@ -505,20 +505,50 @@ func (c *Cluster) roleLabelsSet(shouldAddExtraLabels bool, role PostgresRole) la
|
||||
return lbls
|
||||
}
|
||||
|
||||
func (c *Cluster) dnsName(role PostgresRole) string {
|
||||
var dnsString string
|
||||
if role == Master {
|
||||
dnsString = c.masterDNSName()
|
||||
} else {
|
||||
dnsString = c.replicaDNSName()
|
||||
}
|
||||
|
||||
// when cluster name starts with teamId prefix create an extra DNS entry
|
||||
// to support the old format when prefix contraint was enabled (but is disabled now)
|
||||
if !c.OpConfig.EnableTeamIdClusternamePrefix {
|
||||
clusterNameWithoutTeamPrefix, _ := acidv1.ExtractClusterName(c.Name, c.Spec.TeamID)
|
||||
if clusterNameWithoutTeamPrefix != "" {
|
||||
if role == Replica {
|
||||
clusterNameWithoutTeamPrefix = fmt.Sprintf("%s-repl", clusterNameWithoutTeamPrefix)
|
||||
}
|
||||
dnsString = fmt.Sprintf("%s,%s", dnsString, c.oldDNSFormat(clusterNameWithoutTeamPrefix))
|
||||
}
|
||||
}
|
||||
|
||||
return dnsString
|
||||
}
|
||||
|
||||
func (c *Cluster) masterDNSName() string {
|
||||
return strings.ToLower(c.OpConfig.MasterDNSNameFormat.Format(
|
||||
"cluster", c.Spec.ClusterName,
|
||||
"team", c.teamName(),
|
||||
"namespace", c.Namespace,
|
||||
"hostedzone", c.OpConfig.DbHostedZone))
|
||||
}
|
||||
|
||||
func (c *Cluster) replicaDNSName() string {
|
||||
return strings.ToLower(c.OpConfig.ReplicaDNSNameFormat.Format(
|
||||
"cluster", c.Spec.ClusterName,
|
||||
"team", c.teamName(),
|
||||
"namespace", c.Namespace,
|
||||
"hostedzone", c.OpConfig.DbHostedZone))
|
||||
}
|
||||
|
||||
func (c *Cluster) oldDNSFormat(clusterName string) string {
|
||||
return fmt.Sprintf("%s.%s.%s",
|
||||
clusterName,
|
||||
c.teamName(),
|
||||
c.OpConfig.DbHostedZone)
|
||||
}
|
||||
|
||||
func (c *Cluster) credentialSecretName(username string) string {
|
||||
return c.credentialSecretNameForCluster(username, c.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user