Skip to content
This repository was archived by the owner on Oct 20, 2023. It is now read-only.

Commit a0b7b26

Browse files
author
Michelle Noorali
committed
feat(*): add trafficsplit v1alpha4 api
Signed-off-by: Michelle Noorali <[email protected]>
1 parent 37dac10 commit a0b7b26

File tree

22 files changed

+1011
-1
lines changed

22 files changed

+1011
-1
lines changed

hack/update-codegen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ generate_client "specs" "v1alpha1,v1alpha2,v1alpha3,v1alpha4"
6060

6161
echo ""
6262
echo "###### Generating split client ######"
63-
generate_client "split" "v1alpha1,v1alpha2,v1alpha3"
63+
generate_client "split" "v1alpha1,v1alpha2,v1alpha3,v1alpha4"
6464

6565
echo ""
6666
echo "##### Generating access client ######"

pkg/apis/split/v1alpha4/doc.go

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// +k8s:deepcopy-gen=package
2+
// +groupName=split.smi-spec.io
3+
4+
package v1alpha4

pkg/apis/split/v1alpha4/register.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha4
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
8+
ts "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split"
9+
)
10+
11+
// SchemeGroupVersion is the identifier for the API which includes
12+
// the name of the group and the version of the API
13+
var SchemeGroupVersion = schema.GroupVersion{
14+
Group: ts.GroupName,
15+
Version: "v1alpha4",
16+
}
17+
18+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
19+
func Kind(kind string) schema.GroupKind {
20+
return SchemeGroupVersion.WithKind(kind).GroupKind()
21+
}
22+
23+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
24+
func Resource(resource string) schema.GroupResource {
25+
return SchemeGroupVersion.WithResource(resource).GroupResource()
26+
}
27+
28+
var (
29+
// SchemeBuilder collects functions that add things to a scheme. It's to allow
30+
// code to compile without explicitly referencing generated types. You should
31+
// declare one in each package that will have generated deep copy or conversion
32+
// functions.
33+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
34+
35+
// AddToScheme applies all the stored functions to the scheme. A non-nil error
36+
// indicates that one function failed and the attempt was abandoned.
37+
AddToScheme = SchemeBuilder.AddToScheme
38+
)
39+
40+
// Adds the list of known types to Scheme.
41+
func addKnownTypes(scheme *runtime.Scheme) error {
42+
scheme.AddKnownTypes(SchemeGroupVersion,
43+
&TrafficSplit{},
44+
&TrafficSplitList{},
45+
)
46+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
47+
return nil
48+
}
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package v1alpha4
2+
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
7+
8+
// +genclient
9+
// +genclient:noStatus
10+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
11+
12+
// TrafficSplit allows users to incrementally direct percentages of traffic
13+
// between various services. It will be used by clients such as ingress
14+
// controllers or service mesh sidecars to split the outgoing traffic to
15+
// different destinations.
16+
type TrafficSplit struct {
17+
metav1.TypeMeta `json:",inline"`
18+
// Standard object's metadata.
19+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
20+
// +optional
21+
metav1.ObjectMeta `json:"metadata,omitempty"`
22+
23+
// Specification of the desired behavior of the traffic split.
24+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
25+
// +optional
26+
Spec TrafficSplitSpec `json:"spec,omitempty"`
27+
}
28+
29+
// TrafficSplitSpec is the specification for a TrafficSplit
30+
type TrafficSplitSpec struct {
31+
// Service represents the apex service
32+
Service string `json:"service"`
33+
34+
// Backends defines a list of Kubernetes services
35+
// used as the traffic split destination
36+
Backends []TrafficSplitBackend `json:"backends"`
37+
38+
// Matches allows defining a list of HTTP route groups
39+
// that this traffic split object should match
40+
// +optional
41+
Matches []corev1.TypedLocalObjectReference `json:"matches,omitempty"`
42+
}
43+
44+
// TrafficSplitBackend defines a backend
45+
type TrafficSplitBackend struct {
46+
// Service is the name of a Kubernetes service
47+
Service string `json:"service"`
48+
49+
// Weight defines the traffic split percentage
50+
Weight int `json:"weight"`
51+
}
52+
53+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
54+
55+
type TrafficSplitList struct {
56+
metav1.TypeMeta `json:",inline"`
57+
metav1.ListMeta `json:"metadata"`
58+
59+
Items []TrafficSplit `json:"items"`
60+
}

pkg/apis/split/v1alpha4/zz_generated.deepcopy.go

+128
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/gen/client/split/clientset/versioned/clientset.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/gen/client/split/clientset/versioned/fake/clientset_generated.go

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/gen/client/split/clientset/versioned/fake/register.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/gen/client/split/clientset/versioned/scheme/register.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/gen/client/split/clientset/versioned/typed/split/v1alpha4/doc.go

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)