...

Source file src/k8s.io/api/discovery/v1beta1/types.go

Documentation: k8s.io/api/discovery/v1beta1

     1  /*
     2  Copyright 2019 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1beta1
    18  
    19  import (
    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.21
    28  // +k8s:prerelease-lifecycle-gen:removed=1.25
    29  // +k8s:prerelease-lifecycle-gen:replacement=discovery.k8s.io,v1,EndpointSlice
    30  
    31  // EndpointSlice represents a subset of the endpoints that implement a service.
    32  // For a given service there may be multiple EndpointSlice objects, selected by
    33  // labels, which must be joined to produce the full set of endpoints.
    34  type EndpointSlice struct {
    35  	metav1.TypeMeta `json:",inline"`
    36  
    37  	// Standard object's metadata.
    38  	// +optional
    39  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    40  
    41  	// addressType specifies the type of address carried by this EndpointSlice.
    42  	// All addresses in this slice must be the same type. This field is
    43  	// immutable after creation. The following address types are currently
    44  	// supported:
    45  	// * IPv4: Represents an IPv4 Address.
    46  	// * IPv6: Represents an IPv6 Address.
    47  	// * FQDN: Represents a Fully Qualified Domain Name.
    48  	AddressType AddressType `json:"addressType" protobuf:"bytes,4,rep,name=addressType"`
    49  
    50  	// endpoints is a list of unique endpoints in this slice. Each slice may
    51  	// include a maximum of 1000 endpoints.
    52  	// +listType=atomic
    53  	Endpoints []Endpoint `json:"endpoints" protobuf:"bytes,2,rep,name=endpoints"`
    54  
    55  	// ports specifies the list of network ports exposed by each endpoint in
    56  	// this slice. Each port must have a unique name. When ports is empty, it
    57  	// indicates that there are no defined ports. When a port is defined with a
    58  	// nil port value, it indicates "all ports". Each slice may include a
    59  	// maximum of 100 ports.
    60  	// +optional
    61  	// +listType=atomic
    62  	Ports []EndpointPort `json:"ports" protobuf:"bytes,3,rep,name=ports"`
    63  }
    64  
    65  // AddressType represents the type of address referred to by an endpoint.
    66  type AddressType string
    67  
    68  const (
    69  	// AddressTypeIPv4 represents an IPv4 Address.
    70  	AddressTypeIPv4 = AddressType(v1.IPv4Protocol)
    71  
    72  	// AddressTypeIPv6 represents an IPv6 Address.
    73  	AddressTypeIPv6 = AddressType(v1.IPv6Protocol)
    74  
    75  	// AddressTypeFQDN represents a FQDN.
    76  	AddressTypeFQDN = AddressType("FQDN")
    77  )
    78  
    79  // Endpoint represents a single logical "backend" implementing a service.
    80  type Endpoint struct {
    81  	// addresses of this endpoint. The contents of this field are interpreted
    82  	// according to the corresponding EndpointSlice addressType field. Consumers
    83  	// must handle different types of addresses in the context of their own
    84  	// capabilities. This must contain at least one address but no more than
    85  	// 100. These are all assumed to be fungible and clients may choose to only
    86  	// use the first element. Refer to: https://issue.k8s.io/106267
    87  	// +listType=set
    88  	Addresses []string `json:"addresses" protobuf:"bytes,1,rep,name=addresses"`
    89  
    90  	// conditions contains information about the current status of the endpoint.
    91  	Conditions EndpointConditions `json:"conditions,omitempty" protobuf:"bytes,2,opt,name=conditions"`
    92  
    93  	// hostname of this endpoint. This field may be used by consumers of
    94  	// endpoints to distinguish endpoints from each other (e.g. in DNS names).
    95  	// Multiple endpoints which use the same hostname should be considered
    96  	// fungible (e.g. multiple A values in DNS). Must be lowercase and pass DNS
    97  	// Label (RFC 1123) validation.
    98  	// +optional
    99  	Hostname *string `json:"hostname,omitempty" protobuf:"bytes,3,opt,name=hostname"`
   100  
   101  	// targetRef is a reference to a Kubernetes object that represents this
   102  	// endpoint.
   103  	// +optional
   104  	TargetRef *v1.ObjectReference `json:"targetRef,omitempty" protobuf:"bytes,4,opt,name=targetRef"`
   105  
   106  	// topology contains arbitrary topology information associated with the
   107  	// endpoint. These key/value pairs must conform with the label format.
   108  	// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels
   109  	// Topology may include a maximum of 16 key/value pairs. This includes, but
   110  	// is not limited to the following well known keys:
   111  	// * kubernetes.io/hostname: the value indicates the hostname of the node
   112  	//   where the endpoint is located. This should match the corresponding
   113  	//   node label.
   114  	// * topology.kubernetes.io/zone: the value indicates the zone where the
   115  	//   endpoint is located. This should match the corresponding node label.
   116  	// * topology.kubernetes.io/region: the value indicates the region where the
   117  	//   endpoint is located. This should match the corresponding node label.
   118  	// This field is deprecated and will be removed in future api versions.
   119  	// +optional
   120  	Topology map[string]string `json:"topology,omitempty" protobuf:"bytes,5,opt,name=topology"`
   121  
   122  	// nodeName represents the name of the Node hosting this endpoint. This can
   123  	// be used to determine endpoints local to a Node.
   124  	// +optional
   125  	NodeName *string `json:"nodeName,omitempty" protobuf:"bytes,6,opt,name=nodeName"`
   126  
   127  	// hints contains information associated with how an endpoint should be
   128  	// consumed.
   129  	// +featureGate=TopologyAwareHints
   130  	// +optional
   131  	Hints *EndpointHints `json:"hints,omitempty" protobuf:"bytes,7,opt,name=hints"`
   132  }
   133  
   134  // EndpointConditions represents the current condition of an endpoint.
   135  type EndpointConditions struct {
   136  	// ready indicates that this endpoint is prepared to receive traffic,
   137  	// according to whatever system is managing the endpoint. A nil value
   138  	// indicates an unknown state. In most cases consumers should interpret this
   139  	// unknown state as ready. For compatibility reasons, ready should never be
   140  	// "true" for terminating endpoints.
   141  	// +optional
   142  	Ready *bool `json:"ready,omitempty" protobuf:"bytes,1,name=ready"`
   143  
   144  	// serving is identical to ready except that it is set regardless of the
   145  	// terminating state of endpoints. This condition should be set to true for
   146  	// a ready endpoint that is terminating. If nil, consumers should defer to
   147  	// the ready condition.
   148  	// +optional
   149  	Serving *bool `json:"serving,omitempty" protobuf:"bytes,2,name=serving"`
   150  
   151  	// terminating indicates that this endpoint is terminating. A nil value
   152  	// indicates an unknown state. Consumers should interpret this unknown state
   153  	// to mean that the endpoint is not terminating.
   154  	// +optional
   155  	Terminating *bool `json:"terminating,omitempty" protobuf:"bytes,3,name=terminating"`
   156  }
   157  
   158  // EndpointHints provides hints describing how an endpoint should be consumed.
   159  type EndpointHints struct {
   160  	// forZones indicates the zone(s) this endpoint should be consumed by to
   161  	// enable topology aware routing. May contain a maximum of 8 entries.
   162  	// +listType=atomic
   163  	ForZones []ForZone `json:"forZones,omitempty" protobuf:"bytes,1,name=forZones"`
   164  }
   165  
   166  // ForZone provides information about which zones should consume this endpoint.
   167  type ForZone struct {
   168  	// name represents the name of the zone.
   169  	Name string `json:"name" protobuf:"bytes,1,name=name"`
   170  }
   171  
   172  // EndpointPort represents a Port used by an EndpointSlice
   173  type EndpointPort struct {
   174  	// name represents the name of this port. All ports in an EndpointSlice must have a unique name.
   175  	// If the EndpointSlice is derived from a Kubernetes service, this corresponds to the Service.ports[].name.
   176  	// Name must either be an empty string or pass DNS_LABEL validation:
   177  	// * must be no more than 63 characters long.
   178  	// * must consist of lower case alphanumeric characters or '-'.
   179  	// * must start and end with an alphanumeric character.
   180  	// Default is empty string.
   181  	Name *string `json:"name,omitempty" protobuf:"bytes,1,name=name"`
   182  
   183  	// protocol represents the IP protocol for this port.
   184  	// Must be UDP, TCP, or SCTP.
   185  	// Default is TCP.
   186  	Protocol *v1.Protocol `json:"protocol,omitempty" protobuf:"bytes,2,name=protocol"`
   187  
   188  	// port represents the port number of the endpoint.
   189  	// If this is not specified, ports are not restricted and must be
   190  	// interpreted in the context of the specific consumer.
   191  	Port *int32 `json:"port,omitempty" protobuf:"bytes,3,opt,name=port"`
   192  
   193  	// appProtocol represents the application protocol for this port.
   194  	// This field follows standard Kubernetes label syntax.
   195  	// Un-prefixed names are reserved for IANA standard service names (as per
   196  	// RFC-6335 and https://www.iana.org/assignments/service-names).
   197  	// Non-standard protocols should use prefixed names such as
   198  	// mycompany.com/my-custom-protocol.
   199  	// +optional
   200  	AppProtocol *string `json:"appProtocol,omitempty" protobuf:"bytes,4,name=appProtocol"`
   201  }
   202  
   203  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   204  // +k8s:prerelease-lifecycle-gen:introduced=1.16
   205  // +k8s:prerelease-lifecycle-gen:deprecated=1.21
   206  // +k8s:prerelease-lifecycle-gen:removed=1.25
   207  // +k8s:prerelease-lifecycle-gen:replacement=discovery.k8s.io,v1,EndpointSlice
   208  
   209  // EndpointSliceList represents a list of endpoint slices
   210  type EndpointSliceList struct {
   211  	metav1.TypeMeta `json:",inline"`
   212  
   213  	// Standard list metadata.
   214  	// +optional
   215  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
   216  
   217  	// items is the list of endpoint slices
   218  	Items []EndpointSlice `json:"items" protobuf:"bytes,2,rep,name=items"`
   219  }
   220  

View as plain text