Skip to content

Commit ab80d57

Browse files
committed
Try to clarify EndpointSlice semantics some more
Especially, the difference between what the API allows, and what the EndpointSlice controller and kube-proxy support.
1 parent d36322f commit ab80d57

File tree

1 file changed

+34
-27
lines changed
  • staging/src/k8s.io/api/discovery/v1

1 file changed

+34
-27
lines changed

staging/src/k8s.io/api/discovery/v1/types.go

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ import (
2525
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2626
// +k8s:prerelease-lifecycle-gen:introduced=1.21
2727

28-
// EndpointSlice represents a subset of the endpoints that implement a service.
29-
// For a given service there may be multiple EndpointSlice objects, selected by
30-
// labels, which must be joined to produce the full set of endpoints.
28+
// EndpointSlice represents a set of service endpoints. Most EndpointSlices are created by
29+
// the EndpointSlice controller to represent the Pods selected by Service objects. For a
30+
// given service there may be multiple EndpointSlice objects which must be joined to
31+
// produce the full set of endpoints; you can find all of the slices for a given service
32+
// by listing EndpointSlices in the service's namespace whose `kubernetes.io/service-name`
33+
// label contains the service's name.
3134
type EndpointSlice struct {
3235
metav1.TypeMeta `json:",inline"`
3336

@@ -41,7 +44,10 @@ type EndpointSlice struct {
4144
// supported:
4245
// * IPv4: Represents an IPv4 Address.
4346
// * IPv6: Represents an IPv6 Address.
44-
// * FQDN: Represents a Fully Qualified Domain Name.
47+
// * FQDN: Represents a Fully Qualified Domain Name. (Deprecated)
48+
// The EndpointSlice controller only generates, and kube-proxy only processes,
49+
// slices of addressType "IPv4" and "IPv6". No semantics are defined for
50+
// the "FQDN" type.
4551
AddressType AddressType `json:"addressType" protobuf:"bytes,4,rep,name=addressType"`
4652

4753
// endpoints is a list of unique endpoints in this slice. Each slice may
@@ -50,10 +56,11 @@ type EndpointSlice struct {
5056
Endpoints []Endpoint `json:"endpoints" protobuf:"bytes,2,rep,name=endpoints"`
5157

5258
// ports specifies the list of network ports exposed by each endpoint in
53-
// this slice. Each port must have a unique name. When ports is empty, it
54-
// indicates that there are no defined ports. When a port is defined with a
55-
// nil port value, it indicates "all ports". Each slice may include a
59+
// this slice. Each port must have a unique name. Each slice may include a
5660
// maximum of 100 ports.
61+
// Services always have at least 1 port, so EndpointSlices generated by the
62+
// EndpointSlice controller will likewise always have at least 1 port.
63+
// EndpointSlices used for other purposes may have an empty ports list.
5764
// +optional
5865
// +listType=atomic
5966
Ports []EndpointPort `json:"ports" protobuf:"bytes,3,rep,name=ports"`
@@ -76,12 +83,12 @@ const (
7683

7784
// Endpoint represents a single logical "backend" implementing a service.
7885
type Endpoint struct {
79-
// addresses of this endpoint. The contents of this field are interpreted
80-
// according to the corresponding EndpointSlice addressType field. Consumers
81-
// must handle different types of addresses in the context of their own
82-
// capabilities. This must contain at least one address but no more than
83-
// 100. These are all assumed to be fungible and clients may choose to only
84-
// use the first element. Refer to: https://issue.k8s.io/106267
86+
// addresses of this endpoint. For EndpointSlices of addressType "IPv4" or "IPv6",
87+
// the values are IP addresses in canonical form. The syntax and semantics of
88+
// other addressType values are not defined. This must contain at least one
89+
// address but no more than 100. EndpointSlices generated by the EndpointSlice
90+
// controller will always have exactly 1 address. No semantics are defined for
91+
// additional addresses beyond the first, and kube-proxy does not look at them.
8592
// +listType=set
8693
Addresses []string `json:"addresses" protobuf:"bytes,1,rep,name=addresses"`
8794

@@ -127,26 +134,25 @@ type Endpoint struct {
127134

128135
// EndpointConditions represents the current condition of an endpoint.
129136
type EndpointConditions struct {
130-
// ready indicates that this endpoint is prepared to receive traffic,
137+
// ready indicates that this endpoint is ready to receive traffic,
131138
// according to whatever system is managing the endpoint. A nil value
132-
// indicates an unknown state. In most cases consumers should interpret this
133-
// unknown state as ready. For compatibility reasons, ready should never be
134-
// "true" for terminating endpoints, except when the normal readiness
135-
// behavior is being explicitly overridden, for example when the associated
136-
// Service has set the publishNotReadyAddresses flag.
139+
// should be interpreted as "true". In general, an endpoint should be
140+
// marked ready if it is serving and not terminating, though this can
141+
// be overridden in some cases, such as when the associated Service has
142+
// set the publishNotReadyAddresses flag.
137143
// +optional
138144
Ready *bool `json:"ready,omitempty" protobuf:"bytes,1,name=ready"`
139145

140-
// serving is identical to ready except that it is set regardless of the
141-
// terminating state of endpoints. This condition should be set to true for
142-
// a ready endpoint that is terminating. If nil, consumers should defer to
143-
// the ready condition.
146+
// serving indicates that this endpoint is able to receive traffic,
147+
// according to whatever system is managing the endpoint. For endpoints
148+
// backed by pods, the EndpointSlice controller will mark the endpoint
149+
// as serving if the pod's Ready condition is True. A nil value should be
150+
// interpreted as "true".
144151
// +optional
145152
Serving *bool `json:"serving,omitempty" protobuf:"bytes,2,name=serving"`
146153

147154
// terminating indicates that this endpoint is terminating. A nil value
148-
// indicates an unknown state. Consumers should interpret this unknown state
149-
// to mean that the endpoint is not terminating.
155+
// should be interpreted as "false".
150156
// +optional
151157
Terminating *bool `json:"terminating,omitempty" protobuf:"bytes,3,name=terminating"`
152158
}
@@ -183,8 +189,9 @@ type EndpointPort struct {
183189
Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,2,name=protocol"`
184190

185191
// port represents the port number of the endpoint.
186-
// If this is not specified, ports are not restricted and must be
187-
// interpreted in the context of the specific consumer.
192+
// If the EndpointSlice is derived from a Kubernetes service, this must be set
193+
// to the service's target port. EndpointSlices used for other purposes may have
194+
// a nil port.
188195
Port *int32 `json:"port,omitempty" protobuf:"bytes,3,opt,name=port"`
189196

190197
// The application protocol for this port.

0 commit comments

Comments
 (0)