Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set PublishNotReadyAddresses on coordinator&syncmasters service #39

Merged
merged 1 commit into from
Mar 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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