Skip to content

Commit 049bc0c

Browse files
authored
feat(multicluster): Add Link v1alpha3 (#13801)
We add a new v1alpha3 resource version to the Link custom resource. This version adds `excludedAnnotations` and `excludedLabels` fields to the spec which will be used to exclude labels and annotations from being copied onto mirror and federated services. Signed-off-by: Alex Leong <[email protected]>
1 parent 2aea89d commit 049bc0c

File tree

110 files changed

+3623
-1943
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+3623
-1943
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// +k8s:deepcopy-gen=package
2+
3+
package v1alpha3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha3
2+
3+
import (
4+
"github.com/linkerd/linkerd2/controller/gen/apis/link"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
"k8s.io/apimachinery/pkg/runtime"
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
)
9+
10+
var (
11+
// SchemeGroupVersion is the identifier for the API which includes the name
12+
// of the group and the version of the API.
13+
SchemeGroupVersion = schema.GroupVersion{
14+
Group: link.GroupName,
15+
Version: "v1alpha3",
16+
}
17+
18+
// SchemeBuilder collects functions that add things to a scheme. It's to
19+
// allow code to compile without explicitly referencing generated types.
20+
// You should declare one in each package that will have generated deep
21+
// copy or conversion functions.
22+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
23+
24+
// AddToScheme applies all the stored functions to the scheme. A non-nil error
25+
// indicates that one function failed and the attempt was abandoned.
26+
AddToScheme = SchemeBuilder.AddToScheme
27+
)
28+
29+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
30+
func Kind(kind string) schema.GroupKind {
31+
return SchemeGroupVersion.WithKind(kind).GroupKind()
32+
}
33+
34+
// Resource takes an unqualified resource and returns a Group qualified
35+
// GroupResource
36+
func Resource(resource string) schema.GroupResource {
37+
return SchemeGroupVersion.WithResource(resource).GroupResource()
38+
}
39+
40+
// Adds the list of known types to Scheme.
41+
func addKnownTypes(scheme *runtime.Scheme) error {
42+
scheme.AddKnownTypes(SchemeGroupVersion,
43+
&Link{},
44+
&LinkList{},
45+
)
46+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
47+
return nil
48+
}
+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package v1alpha3
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
// +genclient
8+
// +genclient:noStatus
9+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
10+
// +groupName=multicluster.linkerd.io
11+
12+
type Link struct {
13+
// TypeMeta is the metadata for the resource, like kind and apiversion
14+
metav1.TypeMeta `json:",inline"`
15+
16+
// ObjectMeta contains the metadata for the particular object, including
17+
// things like...
18+
// - name
19+
// - namespace
20+
// - self link
21+
// - labels
22+
// - ... etc ...
23+
metav1.ObjectMeta `json:"metadata,omitempty"`
24+
25+
// Spec is the custom resource spec
26+
Spec LinkSpec `json:"spec"`
27+
28+
// Status defines the current state of a Link
29+
Status LinkStatus `json:"status,omitempty"`
30+
}
31+
32+
// LinkSpec specifies a LinkSpec resource.
33+
type LinkSpec struct {
34+
TargetClusterName string `json:"targetClusterName,omitempty"`
35+
TargetClusterDomain string `json:"targetClusterDomain,omitempty"`
36+
TargetClusterLinkerdNamespace string `json:"targetClusterLinkerdNamespace,omitempty"`
37+
ClusterCredentialsSecret string `json:"clusterCredentialsSecret,omitempty"`
38+
GatewayAddress string `json:"gatewayAddress,omitempty"`
39+
GatewayPort string `json:"gatewayPort,omitempty"`
40+
GatewayIdentity string `json:"gatewayIdentity,omitempty"`
41+
ProbeSpec ProbeSpec `json:"probeSpec,omitempty"`
42+
Selector *metav1.LabelSelector `json:"selector,omitempty"`
43+
RemoteDiscoverySelector *metav1.LabelSelector `json:"remoteDiscoverySelector,omitempty"`
44+
FederatedServiceSelector *metav1.LabelSelector `json:"federatedServiceSelector,omitempty"`
45+
ExcludedAnnotations []string `json:"excludedAnnotations,omitempty"`
46+
ExcludedLabels []string `json:"excludedLabels,omitempty"`
47+
}
48+
49+
// ProbeSpec for gateway health probe
50+
type ProbeSpec struct {
51+
Path string `json:"path,omitempty"`
52+
Port string `json:"port,omitempty"`
53+
Period string `json:"period,omitempty"`
54+
Timeout string `json:"timeout,omitempty"`
55+
FailureThreshold string `json:"failureThreshold,omitempty"`
56+
}
57+
58+
// LinkStatus holds information about the status services mirrored with this
59+
// Link.
60+
type LinkStatus struct {
61+
// +optional
62+
MirrorServices []ServiceStatus `json:"mirrorServices,omitempty"`
63+
// +optional
64+
FederatedServices []ServiceStatus `json:"federatedServices,omitempty"`
65+
}
66+
67+
type ServiceStatus struct {
68+
Conditions []LinkCondition `json:"conditions,omitempty"`
69+
ControllerName string `json:"controllerName,omitempty"`
70+
RemoteRef ObjectRef `json:"remoteRef,omitempty"`
71+
}
72+
73+
// LinkCondition represents the service state of an ExternalWorkload
74+
type LinkCondition struct {
75+
// Type of the condition
76+
Type string `json:"type"`
77+
// Status of the condition.
78+
// Can be True, False, Unknown
79+
Status metav1.ConditionStatus `json:"status"`
80+
// Last time an ExternalWorkload was probed for a condition.
81+
// +optional
82+
LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"`
83+
// Last time a condition transitioned from one status to another.
84+
// +optional
85+
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
86+
// Unique one word reason in CamelCase that describes the reason for a
87+
// transition.
88+
// +optional
89+
Reason string `json:"reason,omitempty"`
90+
// Human readable message that describes details about last transition.
91+
// +optional
92+
Message string `json:"message"`
93+
// LocalRef is a reference to the local mirror or federated service.
94+
LocalRef ObjectRef `json:"localRef,omitempty"`
95+
}
96+
97+
type ObjectRef struct {
98+
Group string `json:"group,omitempty"`
99+
Kind string `json:"kind,omitempty"`
100+
Name string `json:"name,omitempty"`
101+
Namespace string `json:"namespace,omitempty"`
102+
}
103+
104+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
105+
106+
// LinkList is a list of LinkList resources.
107+
type LinkList struct {
108+
metav1.TypeMeta `json:",inline"`
109+
metav1.ListMeta `json:"metadata"`
110+
111+
Items []Link `json:"items"`
112+
}

0 commit comments

Comments
 (0)