mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 00:01:06 +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
@@ -88,6 +88,10 @@ func (c *Cluster) ClusterName() spec.ClusterName {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) ClusterTeamName() string {
|
||||
return c.Spec.TeamId
|
||||
}
|
||||
|
||||
func (c *Cluster) Run(stopCh <-chan struct{}) {
|
||||
go c.podEventsDispatcher(stopCh)
|
||||
|
||||
@@ -199,7 +203,7 @@ func (c *Cluster) Update(newSpec *spec.Postgresql) error {
|
||||
|
||||
newStatefulSet := getStatefulSet(c.ClusterName(), newSpec.Spec, c.etcdHost, c.dockerImage)
|
||||
|
||||
newService := resources.Service(c.ClusterName(), newSpec.Spec.AllowedSourceRanges)
|
||||
newService := resources.Service(c.ClusterName(), c.ClusterTeamName(), newSpec.Spec.AllowedSourceRanges)
|
||||
if !servicesEqual(newService, c.Service) {
|
||||
c.logger.Infof("Service needs to be upated")
|
||||
if err := c.updateService(newService); err != nil {
|
||||
|
||||
@@ -148,7 +148,7 @@ func (c *Cluster) createService() (*v1.Service, error) {
|
||||
if c.Service != nil {
|
||||
return nil, fmt.Errorf("Service already exists in the cluster")
|
||||
}
|
||||
serviceSpec := resources.Service(c.ClusterName(), c.Spec.AllowedSourceRanges)
|
||||
serviceSpec := resources.Service(c.ClusterName(), c.ClusterTeamName(), c.Spec.AllowedSourceRanges)
|
||||
|
||||
service, err := c.config.KubeClient.Services(serviceSpec.Namespace).Create(serviceSpec)
|
||||
if k8sutil.ResourceAlreadyExists(err) {
|
||||
|
||||
Reference in New Issue
Block a user