This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 277
/
multi_cluster_service.go
73 lines (56 loc) · 2.42 KB
/
multi_cluster_service.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
package v1alpha1
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// MultiClusterService is the type used to represent the multicluster configuration.
// MultiClusterService name needs to match the name of the service backing the pods in each cluster.
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type MultiClusterService struct {
// Object's type metadata.
metav1.TypeMeta `json:",inline" yaml:",inline"`
// Object's metadata.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
// Spec is the MultiClusterService specification.
Spec MultiClusterServiceSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
}
func (mcs MultiClusterService) String() string {
return fmt.Sprintf("%s/%s with SA=%s", mcs.Namespace, mcs.Name, mcs.Spec.ServiceAccount)
}
// MultiClusterServiceSpec is the type used to represent the multicluster service specification.
type MultiClusterServiceSpec struct {
// ClusterSpec defines the configuration of other clusters
Clusters []ClusterSpec `json:"clusters,omitempty"`
// ServiceAccount represents the service account of the multicluster service.
ServiceAccount string `json:"serviceAccount,omitempty"`
// Ports is the list of ports exported by this service.
Ports []PortSpec `json:"ports,omitempty"`
}
// ClusterSpec is the type used to represent a remote cluster in multicluster scenarios.
type ClusterSpec struct {
// Address defines the remote IP address of the gateway
Address string `json:"address,omitempty"`
// Name defines the name of the remote cluster.
Name string `json:"name,omitempty"`
// Weight defines the load balancing weight of the remote cluster
Weight int `json:"weight,omitempty"`
// Priority defines the priority of the remote cluster in locality based load balancing
Priority int `json:"priority,omitempty"`
}
// PortSpec contains information on service's port.
type PortSpec struct {
// The port that will be exposed by this service.
Port uint32
// Protocol is The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". Default is TCP.
Protocol string
}
// MultiClusterServiceList defines the list of MultiClusterService objects.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type MultiClusterServiceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MultiClusterService `json:"items"`
}