Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit a18b469

Browse files
authored
Merge branch 'master' into snapshot_naming_fix
2 parents 5d457ea + b2a63ce commit a18b469

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Fixed
1010

11+
- Don't expose unready nodes via client service. [#2063](https://github.com/coreos/etcd-operator/pull/2063)
12+
1113
### Deprecated
1214

1315
### Security

pkg/util/k8sutil/k8sutil.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

164165
func 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

Comments
 (0)