Skip to content

Commit

Permalink
Set LB-related annotations only if LB is enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyklyukin committed Jun 26, 2017
1 parent 7945d72 commit 232a35e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/cluster/k8sres.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ func (c *Cluster) genService(role PostgresRole, allowedSourceRanges []string) *v
}

serviceSpec := v1.ServiceSpec{}
var annotations map[string]string

if c.OpConfig.EnableLoadBalancer {
// safe default value: lock load balancer to only local address unless overriden explicitely.
Expand All @@ -450,6 +451,11 @@ func (c *Cluster) genService(role PostgresRole, allowedSourceRanges []string) *v
LoadBalancerSourceRanges: sourceRanges,
}

annotations = map[string]string{
constants.ZalandoDNSNameAnnotation: dnsNameFunction(),
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
}

if role == Replica {
serviceSpec.Selector = map[string]string{c.OpConfig.PodRoleLabel: string(Replica)}
}
Expand All @@ -460,10 +466,7 @@ func (c *Cluster) genService(role PostgresRole, allowedSourceRanges []string) *v
Name: name,
Namespace: c.Metadata.Namespace,
Labels: c.roleLabelsSet(role),
Annotations: map[string]string{
constants.ZalandoDNSNameAnnotation: dnsNameFunction(),
constants.ElbTimeoutAnnotationName: constants.ElbTimeoutAnnotationValue,
},
Annotations: annotations,
},
Spec: serviceSpec,
}
Expand Down

0 comments on commit 232a35e

Please sign in to comment.