Skip to content

Commit 5eb2b52

Browse files
authored
Merge pull request #896 from fluxcd/smi-v1alpha3
Implement SMI v1alpha3 router
2 parents 2ed9ddc + 593f450 commit 5eb2b52

27 files changed

+1405
-13
lines changed

README.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ metadata:
8282
spec:
8383
# service mesh provider (optional)
8484
# can be: kubernetes, istio, linkerd, appmesh, nginx, skipper, contour, gloo, supergloo, traefik
85+
# for SMI TrafficSplit can be: smi:v1alpha1, smi:v1alpha2, smi:v1alpha3
8586
provider: istio
8687
# deployment reference
8788
targetRef:
@@ -192,17 +193,21 @@ For more details on how the canary analysis and promotion works please [read the
192193
193194
**Service Mesh**
194195
195-
| Feature | App Mesh | Istio | Linkerd | Kubernetes CNI |
196-
| ------------------------------------------ | ------------------ | ------------------ | ------------------ | ----------------- |
197-
| Canary deployments (weighted traffic) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: |
198-
| A/B testing (headers and cookies routing) | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: |
199-
| Blue/Green deployments (traffic switch) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
200-
| Blue/Green deployments (traffic mirroring) | :heavy_minus_sign: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: |
201-
| Webhooks (acceptance/load testing) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
202-
| Manual gating (approve/pause/resume) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
203-
| Request success rate check (L7 metric) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: |
204-
| Request duration check (L7 metric) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: |
205-
| Custom metric checks | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
196+
| Feature | App Mesh | Istio | Linkerd | SMI | Kubernetes CNI |
197+
| ------------------------------------------ | ------------------ | ------------------ | ------------------ | ----------------- | ----------------- |
198+
| Canary deployments (weighted traffic) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: |
199+
| A/B testing (headers and cookies routing) | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: |
200+
| Blue/Green deployments (traffic switch) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
201+
| Blue/Green deployments (traffic mirroring) | :heavy_minus_sign: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: |
202+
| Webhooks (acceptance/load testing) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
203+
| Manual gating (approve/pause/resume) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
204+
| Request success rate check (L7 metric) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: |
205+
| Request duration check (L7 metric) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: |
206+
| Custom metric checks | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
207+
208+
For SMI compatible service mesh solutions like Open Service Mesh, Consul Connect or Nginx Service Mesh,
209+
[Prometheus MetricTemplates](https://docs.flagger.app/usage/metrics#prometheus) can be used to implement
210+
the request success rate and request duration checks.
206211
207212
**Ingress**
208213
@@ -229,7 +234,6 @@ For more details on how the canary analysis and promotion works please [read the
229234
#### Integrations
230235
231236
* Add support for Kubernetes [Ingress v2](https://github.com/kubernetes-sigs/service-apis)
232-
* Add support for SMI compatible service mesh solutions like Open Service Mesh and Consul Connect
233237
* Add support for ingress controllers like HAProxy and ALB
234238
* Add support for metrics providers like InfluxDB, Stackdriver, SignalFX
235239

hack/update-codegen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh
3030

3131
${CODEGEN_PKG}/generate-groups.sh all \
3232
github.com/fluxcd/flagger/pkg/client github.com/fluxcd/flagger/pkg/apis \
33-
"flagger:v1beta1 appmesh:v1beta2 appmesh:v1beta1 istio:v1alpha3 smi:v1alpha1 smi:v1alpha2 gloo:v1 projectcontour:v1 traefik:v1alpha1" \
33+
"flagger:v1beta1 appmesh:v1beta2 appmesh:v1beta1 istio:v1alpha3 smi:v1alpha1 smi:v1alpha2 smi:v1alpha3 gloo:v1 projectcontour:v1 traefik:v1alpha1" \
3434
--output-base "${TEMP_DIR}" \
3535
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt
3636

kustomize/base/flagger/crd.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,10 @@ spec:
940940
- post-rollout
941941
- event
942942
- rollback
943+
- confirm-traffic-increase
944+
muteAlert:
945+
description: Mute all alerts for the webhook
946+
type: boolean
943947
url:
944948
description: URL address of this webhook
945949
type: string

pkg/apis/smi/v1alpha3/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 v1alpha3

pkg/apis/smi/v1alpha3/register.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha3
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/fluxcd/flagger/pkg/apis/smi"
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: "v1alpha3",
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 v1alpha3
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/smi/v1alpha3/zz_generated.deepcopy.go

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

pkg/client/clientset/versioned/clientset.go

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

pkg/client/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.

0 commit comments

Comments
 (0)