-
Notifications
You must be signed in to change notification settings - Fork 28
/
serviceimport_types.go
122 lines (107 loc) · 4.11 KB
/
serviceimport_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package v1alpha1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +kubebuilder:object:root=true
// ServiceImport describes a service imported from clusters in a ClusterSet.
type ServiceImport struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// spec defines the behavior of a ServiceImport.
// +optional
Spec ServiceImportSpec `json:"spec,omitempty"`
// status contains information about the exported services that form
// the multi-cluster service referenced by this ServiceImport.
// +optional
Status ServiceImportStatus `json:"status,omitempty"`
}
// ServiceImportType designates the type of a ServiceImport
type ServiceImportType string
const (
// ClusterSetIP are only accessible via the ClusterSet IP.
ClusterSetIP ServiceImportType = "ClusterSetIP"
// Headless services allow backend pods to be addressed directly.
Headless ServiceImportType = "Headless"
)
// ServiceImportSpec describes an imported service and the information necessary to consume it.
type ServiceImportSpec struct {
// +listType=atomic
Ports []ServicePort `json:"ports"`
// ip will be used as the VIP for this service when type is ClusterSetIP.
// +optional
IPs []string `json:"ips,omitempty"`
// type defines the type of this service.
// Must be ClusterSetIP or Headless.
// +kubebuilder:validation:Enum=ClusterSetIP;Headless
Type ServiceImportType `json:"type"`
// Supports "ClientIP" and "None". Used to maintain session affinity.
// Enable client IP based session affinity.
// Must be ClientIP or None.
// Defaults to None.
// Ignored when type is Headless
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
// +optional
SessionAffinity v1.ServiceAffinity `json:"sessionAffinity,omitempty"`
// sessionAffinityConfig contains session affinity configuration.
// +optional
SessionAffinityConfig *v1.SessionAffinityConfig `json:"sessionAffinityConfig,omitempty"`
}
// ServicePort represents the port on which the service is exposed
type ServicePort struct {
// The name of this port within the service. This must be a DNS_LABEL.
// All ports within a ServiceSpec must have unique names. When considering
// the endpoints for a Service, this must match the 'name' field in the
// EndpointPort.
// Optional if only one ServicePort is defined on this service.
// +optional
Name string `json:"name,omitempty"`
// The IP protocol for this port. Supports "TCP", "UDP", and "SCTP".
// Default is TCP.
// +optional
Protocol v1.Protocol `json:"protocol,omitempty"`
// The application protocol for this port.
// This field follows standard Kubernetes label syntax.
// Un-prefixed names are reserved for IANA standard service names (as per
// RFC-6335 and http://www.iana.org/assignments/service-names).
// Non-standard protocols should use prefixed names such as
// mycompany.com/my-custom-protocol.
// Field can be enabled with ServiceAppProtocol feature gate.
// +optional
AppProtocol *string `json:"appProtocol,omitempty"`
// The port that will be exposed by this service.
Port int32 `json:"port"`
}
// ServiceImportStatus describes derived state of an imported service.
type ServiceImportStatus struct {
// clusters is the list of exporting clusters from which this service
// was derived.
// +optional
// +patchStrategy=merge
// +patchMergeKey=cluster
// +listType=map
// +listMapKey=cluster
Clusters []ClusterStatus `json:"clusters,omitempty"`
}
// ClusterStatus contains service configuration mapped to a specific source cluster
type ClusterStatus struct {
// cluster is the name of the exporting cluster. Must be a valid RFC-1123 DNS
// label.
Cluster string `json:"cluster"`
}
// +kubebuilder:object:root=true
// ServiceImportList represents a list of endpoint slices
type ServiceImportList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata.
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
// List of endpoint slices
// +listType=set
Items []ServiceImport `json:"items"`
}
func init() {
SchemeBuilder.Register(&ServiceImport{}, &ServiceImportList{})
}