mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 08:29:12 +02:00
Assign DNS name to the cluster.
DNS name is generated from the team name and cluster name. Use "zalando.org/dnsname" service annotation that makes 'mate' service assign a CNAME to the load balancer name.
This commit is contained in:
committed by
Murat Kabilov
parent
45fcb2adc9
commit
55dbacdfa6
@@ -11,13 +11,17 @@ import (
|
||||
"k8s.io/client-go/pkg/util/intstr"
|
||||
|
||||
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
|
||||
"github.bus.zalan.do/acid/postgres-operator/pkg/util"
|
||||
"github.bus.zalan.do/acid/postgres-operator/pkg/util/constants"
|
||||
)
|
||||
|
||||
const (
|
||||
superuserName = "postgres"
|
||||
replicationUsername = "replication"
|
||||
dataVolumeName = "pgdata"
|
||||
superuserName = "postgres"
|
||||
replicationUsername = "replication"
|
||||
dataVolumeName = "pgdata"
|
||||
zalandoDnsNameAnnotation = "zalando.org/dnsname"
|
||||
// TODO: move DbHostedZone to operator configuration
|
||||
DbHostedZone = "db.example.com"
|
||||
)
|
||||
|
||||
func credentialSecretName(clusterName, username string) string {
|
||||
@@ -248,12 +252,13 @@ func UserSecrets(cluster spec.ClusterName, pgUsers map[string]spec.PgUser) (secr
|
||||
return
|
||||
}
|
||||
|
||||
func Service(cluster spec.ClusterName, allowedSourceRanges []string) *v1.Service {
|
||||
func Service(cluster spec.ClusterName, teamName string, allowedSourceRanges []string) *v1.Service {
|
||||
service := &v1.Service{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: cluster.Name,
|
||||
Namespace: cluster.Namespace,
|
||||
Labels: labelsSet(cluster.Name),
|
||||
Name: cluster.Name,
|
||||
Namespace: cluster.Namespace,
|
||||
Labels: labelsSet(cluster.Name),
|
||||
Annotations: map[string]string{zalandoDnsNameAnnotation: util.ClusterDNSName(cluster.Name, teamName, DbHostedZone)},
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Type: v1.ServiceTypeLoadBalancer,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/types"
|
||||
@@ -43,3 +44,7 @@ func PodClusterName(pod *v1.Pod) spec.ClusterName {
|
||||
|
||||
return spec.ClusterName{}
|
||||
}
|
||||
|
||||
func ClusterDNSName(clusterName, teamName, hostedZone string) string {
|
||||
return fmt.Sprintf("%s.%s.%s", clusterName, teamName, hostedZone)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user