blob: 5cafea747905cd39679652e218a762890b0f8958 [file] [log] [blame]
Matteo Scandoloa4285862020-12-01 18:10:10 -08001/*
2Copyright 2019 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1beta1
18
19import (
20 v1 "k8s.io/api/core/v1"
21 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22)
23
24// +genclient
25// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
26// +k8s:prerelease-lifecycle-gen:introduced=1.16
27// +k8s:prerelease-lifecycle-gen:deprecated=1.22
28
29// EndpointSlice represents a subset of the endpoints that implement a service.
30// For a given service there may be multiple EndpointSlice objects, selected by
31// labels, which must be joined to produce the full set of endpoints.
32type EndpointSlice struct {
33 metav1.TypeMeta `json:",inline"`
34 // Standard object's metadata.
35 // +optional
36 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
37 // addressType specifies the type of address carried by this EndpointSlice.
38 // All addresses in this slice must be the same type. This field is
39 // immutable after creation. The following address types are currently
40 // supported:
41 // * IPv4: Represents an IPv4 Address.
42 // * IPv6: Represents an IPv6 Address.
43 // * FQDN: Represents a Fully Qualified Domain Name.
44 AddressType AddressType `json:"addressType" protobuf:"bytes,4,rep,name=addressType"`
45 // endpoints is a list of unique endpoints in this slice. Each slice may
46 // include a maximum of 1000 endpoints.
47 // +listType=atomic
48 Endpoints []Endpoint `json:"endpoints" protobuf:"bytes,2,rep,name=endpoints"`
49 // ports specifies the list of network ports exposed by each endpoint in
50 // this slice. Each port must have a unique name. When ports is empty, it
51 // indicates that there are no defined ports. When a port is defined with a
52 // nil port value, it indicates "all ports". Each slice may include a
53 // maximum of 100 ports.
54 // +optional
55 // +listType=atomic
56 Ports []EndpointPort `json:"ports" protobuf:"bytes,3,rep,name=ports"`
57}
58
59// AddressType represents the type of address referred to by an endpoint.
60type AddressType string
61
62const (
63 // AddressTypeIP represents an IP Address.
64 // This address type has been deprecated and has been replaced by the IPv4
65 // and IPv6 adddress types. New resources with this address type will be
66 // considered invalid. This will be fully removed in 1.18.
67 // +deprecated
68 AddressTypeIP = AddressType("IP")
69 // AddressTypeIPv4 represents an IPv4 Address.
70 AddressTypeIPv4 = AddressType(v1.IPv4Protocol)
71 // AddressTypeIPv6 represents an IPv6 Address.
72 AddressTypeIPv6 = AddressType(v1.IPv6Protocol)
73 // AddressTypeFQDN represents a FQDN.
74 AddressTypeFQDN = AddressType("FQDN")
75)
76
77// Endpoint represents a single logical "backend" implementing a service.
78type 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.
84 // +listType=set
85 Addresses []string `json:"addresses" protobuf:"bytes,1,rep,name=addresses"`
86 // conditions contains information about the current status of the endpoint.
87 Conditions EndpointConditions `json:"conditions,omitempty" protobuf:"bytes,2,opt,name=conditions"`
88 // hostname of this endpoint. This field may be used by consumers of
89 // endpoints to distinguish endpoints from each other (e.g. in DNS names).
90 // Multiple endpoints which use the same hostname should be considered
91 // fungible (e.g. multiple A values in DNS). Must pass DNS Label (RFC 1123)
92 // validation.
93 // +optional
94 Hostname *string `json:"hostname,omitempty" protobuf:"bytes,3,opt,name=hostname"`
95 // targetRef is a reference to a Kubernetes object that represents this
96 // endpoint.
97 // +optional
98 TargetRef *v1.ObjectReference `json:"targetRef,omitempty" protobuf:"bytes,4,opt,name=targetRef"`
99 // topology contains arbitrary topology information associated with the
100 // endpoint. These key/value pairs must conform with the label format.
101 // https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
102 // Topology may include a maximum of 16 key/value pairs. This includes, but
103 // is not limited to the following well known keys:
104 // * kubernetes.io/hostname: the value indicates the hostname of the node
105 // where the endpoint is located. This should match the corresponding
106 // node label.
107 // * topology.kubernetes.io/zone: the value indicates the zone where the
108 // endpoint is located. This should match the corresponding node label.
109 // * topology.kubernetes.io/region: the value indicates the region where the
110 // endpoint is located. This should match the corresponding node label.
111 // +optional
112 Topology map[string]string `json:"topology,omitempty" protobuf:"bytes,5,opt,name=topology"`
113}
114
115// EndpointConditions represents the current condition of an endpoint.
116type EndpointConditions struct {
117 // ready indicates that this endpoint is prepared to receive traffic,
118 // according to whatever system is managing the endpoint. A nil value
119 // indicates an unknown state. In most cases consumers should interpret this
120 // unknown state as ready.
121 // +optional
122 Ready *bool `json:"ready,omitempty" protobuf:"bytes,1,name=ready"`
123}
124
125// EndpointPort represents a Port used by an EndpointSlice
126type EndpointPort struct {
127 // The name of this port. All ports in an EndpointSlice must have a unique
128 // name. If the EndpointSlice is dervied from a Kubernetes service, this
129 // corresponds to the Service.ports[].name.
130 // Name must either be an empty string or pass DNS_LABEL validation:
131 // * must be no more than 63 characters long.
132 // * must consist of lower case alphanumeric characters or '-'.
133 // * must start and end with an alphanumeric character.
134 // Default is empty string.
135 Name *string `json:"name,omitempty" protobuf:"bytes,1,name=name"`
136 // The IP protocol for this port.
137 // Must be UDP, TCP, or SCTP.
138 // Default is TCP.
139 Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,2,name=protocol"`
140 // The port number of the endpoint.
141 // If this is not specified, ports are not restricted and must be
142 // interpreted in the context of the specific consumer.
143 Port *int32 `json:"port,omitempty" protobuf:"bytes,3,opt,name=port"`
144 // The application protocol for this port.
145 // This field follows standard Kubernetes label syntax.
146 // Un-prefixed names are reserved for IANA standard service names (as per
147 // RFC-6335 and http://www.iana.org/assignments/service-names).
148 // Non-standard protocols should use prefixed names such as
149 // mycompany.com/my-custom-protocol.
150 // +optional
151 AppProtocol *string `json:"appProtocol,omitempty" protobuf:"bytes,4,name=appProtocol"`
152}
153
154// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
155// +k8s:prerelease-lifecycle-gen:introduced=1.16
156// +k8s:prerelease-lifecycle-gen:deprecated=1.22
157
158// EndpointSliceList represents a list of endpoint slices
159type EndpointSliceList struct {
160 metav1.TypeMeta `json:",inline"`
161 // Standard list metadata.
162 // +optional
163 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
164 // List of endpoint slices
165 Items []EndpointSlice `json:"items" protobuf:"bytes,2,rep,name=items"`
166}