Skip to content

Commit

Permalink
Merge pull request #39 from arangodb/publish-not-ready-addresses
Browse files Browse the repository at this point in the history
Set PublishNotReadyAddresses on coordinator&syncmasters service
  • Loading branch information
ewoutp authored Mar 9, 2018
2 parents 262e57d + 217dbe5 commit 9a1e88c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/util/k8sutil/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func CreateHeadlessService(kubecli kubernetes.Interface, deployment metav1.Objec
Port: ArangoPort,
},
}
if err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), ClusterIPNone, "", ports, owner); err != nil {
publishNotReadyAddresses := false
if err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), ClusterIPNone, "", ports, publishNotReadyAddresses, owner); err != nil {
return "", maskAny(err)
}
return svcName, nil
Expand All @@ -85,7 +86,8 @@ func CreateDatabaseClientService(kubecli kubernetes.Interface, deployment metav1
} else {
role = "coordinator"
}
if err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", role, ports, owner); err != nil {
publishNotReadyAddresses := true
if err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", role, ports, publishNotReadyAddresses, owner); err != nil {
return "", maskAny(err)
}
return svcName, nil
Expand All @@ -104,7 +106,8 @@ func CreateSyncMasterClientService(kubecli kubernetes.Interface, deployment meta
Port: ArangoPort,
},
}
if err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", "syncmaster", ports, owner); err != nil {
publishNotReadyAddresses := true
if err := createService(kubecli, svcName, deploymentName, deployment.GetNamespace(), "", "syncmaster", ports, publishNotReadyAddresses, owner); err != nil {
return "", maskAny(err)
}
return svcName, nil
Expand All @@ -113,20 +116,24 @@ func CreateSyncMasterClientService(kubecli kubernetes.Interface, deployment meta
// createService prepares and creates a service in k8s.
// If the service already exists, nil is returned.
// If another error occurs, that error is returned.
func createService(kubecli kubernetes.Interface, svcName, deploymentName, ns, clusterIP, role string, ports []v1.ServicePort, owner metav1.OwnerReference) error {
func createService(kubecli kubernetes.Interface, svcName, deploymentName, ns, clusterIP, role string, ports []v1.ServicePort, publishNotReadyAddresses bool, owner metav1.OwnerReference) error {
labels := LabelsForDeployment(deploymentName, role)
svc := &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: svcName,
Labels: labels,
Annotations: map[string]string{
// This annotation is deprecated, PublishNotReadyAddresses is
// used instead. We leave the annotation in for a while.
// See https://github.com/kubernetes/kubernetes/pull/49061
TolerateUnreadyEndpointsAnnotation: "true",
},
},
Spec: v1.ServiceSpec{
Ports: ports,
Selector: labels,
ClusterIP: clusterIP,
Ports: ports,
Selector: labels,
ClusterIP: clusterIP,
PublishNotReadyAddresses: publishNotReadyAddresses,
},
}
addOwnerRefToObject(svc.GetObjectMeta(), &owner)
Expand Down

0 comments on commit 9a1e88c

Please sign in to comment.