@@ -20,6 +20,7 @@ import (
2020 "net"
2121 "net/url"
2222 "os"
23+ "strconv"
2324 "strings"
2425 "time"
2526
@@ -158,7 +159,7 @@ func CreateClientService(kubecli kubernetes.Interface, clusterName, ns string, o
158159 TargetPort : intstr .FromInt (EtcdClientPort ),
159160 Protocol : v1 .ProtocolTCP ,
160161 }}
161- return createService (kubecli , ClientServiceName (clusterName ), clusterName , ns , "" , ports , owner )
162+ return createService (kubecli , ClientServiceName (clusterName ), clusterName , ns , "" , ports , owner , false )
162163}
163164
164165func ClientServiceName (clusterName string ) string {
@@ -178,11 +179,11 @@ func CreatePeerService(kubecli kubernetes.Interface, clusterName, ns string, own
178179 Protocol : v1 .ProtocolTCP ,
179180 }}
180181
181- return createService (kubecli , clusterName , clusterName , ns , v1 .ClusterIPNone , ports , owner )
182+ return createService (kubecli , clusterName , clusterName , ns , v1 .ClusterIPNone , ports , owner , true )
182183}
183184
184- func createService (kubecli kubernetes.Interface , svcName , clusterName , ns , clusterIP string , ports []v1.ServicePort , owner metav1.OwnerReference ) error {
185- svc := newEtcdServiceManifest (svcName , clusterName , clusterIP , ports )
185+ func createService (kubecli kubernetes.Interface , svcName , clusterName , ns , clusterIP string , ports []v1.ServicePort , owner metav1.OwnerReference , publishNotReadyAddresses bool ) error {
186+ svc := newEtcdServiceManifest (svcName , clusterName , clusterIP , ports , publishNotReadyAddresses )
186187 addOwnerRefToObject (svc .GetObjectMeta (), owner )
187188 _ , err := kubecli .CoreV1 ().Services (ns ).Create (svc )
188189 if err != nil && ! apierrors .IsAlreadyExists (err ) {
@@ -225,20 +226,21 @@ func CreateAndWaitPod(kubecli kubernetes.Interface, ns string, pod *v1.Pod, time
225226 return retPod , nil
226227}
227228
228- func newEtcdServiceManifest (svcName , clusterName , clusterIP string , ports []v1.ServicePort ) * v1.Service {
229+ func newEtcdServiceManifest (svcName , clusterName , clusterIP string , ports []v1.ServicePort , publishNotReadyAddresses bool ) * v1.Service {
229230 labels := LabelsForCluster (clusterName )
230231 svc := & v1.Service {
231232 ObjectMeta : metav1.ObjectMeta {
232233 Name : svcName ,
233234 Labels : labels ,
234235 Annotations : map [string ]string {
235- TolerateUnreadyEndpointsAnnotation : "true" ,
236+ TolerateUnreadyEndpointsAnnotation : strconv . FormatBool ( publishNotReadyAddresses ) ,
236237 },
237238 },
238239 Spec : v1.ServiceSpec {
239240 Ports : ports ,
240241 Selector : labels ,
241242 ClusterIP : clusterIP ,
243+ // PublishNotReadyAddresses: publishNotReadyAddresses, // TODO(ckoehn): Activate once TolerateUnreadyEndpointsAnnotation is deprecated.
242244 },
243245 }
244246 return svc
0 commit comments