Skip to content

Commit

Permalink
Actually support service publishNotReadyAddresses
Browse files Browse the repository at this point in the history
This was added and the annotation was deprecated, but it was never
implemented.
  • Loading branch information
thockin committed May 14, 2018
1 parent fc28745 commit c038f60
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 35 deletions.
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/swagger-spec/v1.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/api-reference/v1/definitions.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pkg/apis/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3053,9 +3053,6 @@ type ServiceSpec struct {
// The primary use case for setting this field is to use a StatefulSet's Headless Service
// to propagate SRV records for its Pods without respect to their readiness for purpose
// of peer discovery.
// This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints
// when that annotation is deprecated and all clients have been converted to use this
// field.
// +optional
PublishNotReadyAddresses bool
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/endpoint/endpoints_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const (
// containers in the pod and marks it "Running", till the kubelet stops all
// containers and deletes the pod from the apiserver.
// This field is deprecated. v1.Service.PublishNotReadyAddresses will replace it
// subsequent releases.
// subsequent releases. It will be removed no sooner than 1.13.
TolerateUnreadyEndpointsAnnotation = "service.alpha.kubernetes.io/tolerate-unready-endpoints"
)

Expand Down Expand Up @@ -420,7 +420,8 @@ func (e *EndpointController) syncService(key string) error {
return err
}

var tolerateUnreadyEndpoints bool
// If the user specified the older (deprecated) annotation, we have to respect it.
tolerateUnreadyEndpoints := service.Spec.PublishNotReadyAddresses
if v, ok := service.Annotations[TolerateUnreadyEndpointsAnnotation]; ok {
b, err := strconv.ParseBool(v)
if err == nil {
Expand Down
3 changes: 0 additions & 3 deletions staging/src/k8s.io/api/core/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions staging/src/k8s.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3362,9 +3362,6 @@ type ServiceSpec struct {
// The primary use case for setting this field is to use a StatefulSet's Headless Service
// to propagate SRV records for its Pods without respect to their readiness for purpose
// of peer discovery.
// This field will replace the service.alpha.kubernetes.io/tolerate-unready-endpoints
// when that annotation is deprecated and all clients have been converted to use this
// field.
// +optional
PublishNotReadyAddresses bool `json:"publishNotReadyAddresses,omitempty" protobuf:"varint,13,opt,name=publishNotReadyAddresses"`
// sessionAffinityConfig contains the configurations of session affinity.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions test/e2e/testing-manifests/statefulset/cockroachdb/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ metadata:
labels:
app: cockroachdb
annotations:
# This is needed to make the peer-finder work properly and to help avoid
# edge cases where instance 0 comes up after losing its data and needs to
# decide whether it should create a new cluster or try to join an existing
# one. If it creates a new cluster when it should have joined an existing
# one, we'd end up with two separate clusters listening at the same service
# endpoint, which would be very bad.
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
# Enable automatic monitoring of all instances when Prometheus is running in the cluster.
prometheus.io/scrape: "true"
prometheus.io/path: "_status/vars"
Expand All @@ -31,3 +24,10 @@ spec:
clusterIP: None
selector:
app: cockroachdb
# This is needed to make the peer-finder work properly and to help avoid
# edge cases where instance 0 comes up after losing its data and needs to
# decide whether it should create a new cluster or try to join an existing
# one. If it creates a new cluster when it should have joined an existing
# one, we'd end up with two separate clusters listening at the same service
# endpoint, which would be very bad.
publishNotReadyAddresses: true
4 changes: 1 addition & 3 deletions test/e2e/testing-manifests/statefulset/etcd/service.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
metadata:
name: etcd
labels:
Expand All @@ -16,3 +13,4 @@ spec:
clusterIP: None
selector:
app: etcd
publishNotReadyAddresses: true
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
name: galera
labels:
app: mysql
Expand All @@ -15,4 +13,4 @@ spec:
clusterIP: None
selector:
app: mysql

publishNotReadyAddresses: true
3 changes: 0 additions & 3 deletions test/e2e/testing-manifests/statefulset/redis/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
name: redis
labels:
app: redis
Expand All @@ -15,4 +13,3 @@ spec:
clusterIP: None
selector:
app: redis

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
name: zk
labels:
app: zk
Expand All @@ -17,4 +15,4 @@ spec:
clusterIP: None
selector:
app: zk

publishNotReadyAddresses: true
2 changes: 1 addition & 1 deletion test/images/pets/peer-finder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ All it does is watch DNS for changes in the set of endpoints that are part of th
of the PetSet. It periodically looks up the SRV record of the DNS entry that corresponds to a Kubernetes
Service which enumerates the set of peers for this the specified service.

Be sure to use the `service.alpha.kubernetes.io/tolerate-unready-endpoints` on the governing service
Be sure to use the `publishNotReadyAddresses` field on the governing service
of the StatefulSet so that all peers are listed in endpoints before any peers are started.

There are several ways to bundle it with your main application.
Expand Down

0 comments on commit c038f60

Please sign in to comment.