Skip to content

Commit b20e017

Browse files
authored
Merge pull request #180 from weaveworks/smi
Add support for SMI
2 parents b2500d0 + 5a490ab commit b20e017

36 files changed

+1476
-12
lines changed

.circleci/config.yml

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ jobs:
99
- run: test/e2e-build.sh
1010
- run: test/e2e-tests.sh
1111

12+
e2e-smi-istio-testing:
13+
machine: true
14+
steps:
15+
- checkout
16+
- run: test/e2e-kind.sh
17+
- run: test/e2e-istio.sh
18+
- run: test/e2e-smi-istio-build.sh
19+
- run: test/e2e-tests.sh canary
20+
1221
e2e-supergloo-testing:
1322
machine: true
1423
steps:
@@ -38,6 +47,13 @@ workflows:
3847
- /gh-pages.*/
3948
- /docs-.*/
4049
- /release-.*/
50+
- e2e-smi-istio-testing:
51+
filters:
52+
branches:
53+
ignore:
54+
- /gh-pages.*/
55+
- /docs-.*/
56+
- /release-.*/
4157
- e2e-supergloo-testing:
4258
filters:
4359
branches:

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ run-nginx:
2424
-slack-url=https://hooks.slack.com/services/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 \
2525
-slack-channel="devops-alerts"
2626

27+
run-smi:
28+
go run cmd/flagger/* -kubeconfig=$$HOME/.kube/config -log-level=info -mesh-provider=smi:istio -namespace=smi \
29+
-metrics-server=https://prometheus.istio.weavedx.com \
30+
-slack-url=https://hooks.slack.com/services/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 \
31+
-slack-channel="devops-alerts"
32+
2733
build:
2834
docker build -t weaveworks/flagger:$(TAG) . -f Dockerfile
2935

README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ spec:
8282
# Istio gateways (optional)
8383
gateways:
8484
- public-gateway.istio-system.svc.cluster.local
85-
- mesh
8685
# Istio virtual service host names (optional)
8786
hosts:
8887
- podinfo.example.com
@@ -93,17 +92,12 @@ spec:
9392
# HTTP rewrite (optional)
9493
rewrite:
9594
uri: /
96-
# Envoy timeout and retry policy (optional)
97-
headers:
98-
request:
99-
add:
100-
x-envoy-upstream-rq-timeout-ms: "15000"
101-
x-envoy-max-retries: "10"
102-
x-envoy-retry-on: "gateway-error,connect-failure,refused-stream"
10395
# cross-origin resource sharing policy (optional)
10496
corsPolicy:
10597
allowOrigin:
10698
- example.com
99+
# request timeout (optional)
100+
timeout: 5s
107101
# promote the canary without analysing it (default false)
108102
skipAnalysis: false
109103
# define the canary analysis timing and KPIs

artifacts/flagger/account.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ rules:
5959
- virtualservices
6060
- virtualservices/status
6161
verbs: ["*"]
62+
- apiGroups:
63+
- split.smi-spec.io
64+
resources:
65+
- trafficsplits
66+
verbs: ["*"]
6267
- nonResourceURLs:
6368
- /version
6469
verbs:

artifacts/smi/istio-adapter.yaml

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: trafficsplits.split.smi-spec.io
5+
spec:
6+
additionalPrinterColumns:
7+
- JSONPath: .spec.service
8+
description: The service
9+
name: Service
10+
type: string
11+
group: split.smi-spec.io
12+
names:
13+
kind: TrafficSplit
14+
listKind: TrafficSplitList
15+
plural: trafficsplits
16+
singular: trafficsplit
17+
scope: Namespaced
18+
subresources:
19+
status: {}
20+
version: v1alpha1
21+
versions:
22+
- name: v1alpha1
23+
served: true
24+
storage: true
25+
---
26+
apiVersion: v1
27+
kind: ServiceAccount
28+
metadata:
29+
name: smi-adapter-istio
30+
namespace: istio-system
31+
---
32+
apiVersion: rbac.authorization.k8s.io/v1
33+
kind: ClusterRole
34+
metadata:
35+
name: smi-adapter-istio
36+
rules:
37+
- apiGroups:
38+
- ""
39+
resources:
40+
- pods
41+
- services
42+
- endpoints
43+
- persistentvolumeclaims
44+
- events
45+
- configmaps
46+
- secrets
47+
verbs:
48+
- '*'
49+
- apiGroups:
50+
- apps
51+
resources:
52+
- deployments
53+
- daemonsets
54+
- replicasets
55+
- statefulsets
56+
verbs:
57+
- '*'
58+
- apiGroups:
59+
- monitoring.coreos.com
60+
resources:
61+
- servicemonitors
62+
verbs:
63+
- get
64+
- create
65+
- apiGroups:
66+
- apps
67+
resourceNames:
68+
- smi-adapter-istio
69+
resources:
70+
- deployments/finalizers
71+
verbs:
72+
- update
73+
- apiGroups:
74+
- split.smi-spec.io
75+
resources:
76+
- '*'
77+
verbs:
78+
- '*'
79+
- apiGroups:
80+
- networking.istio.io
81+
resources:
82+
- '*'
83+
verbs:
84+
- '*'
85+
---
86+
kind: ClusterRoleBinding
87+
apiVersion: rbac.authorization.k8s.io/v1
88+
metadata:
89+
name: smi-adapter-istio
90+
subjects:
91+
- kind: ServiceAccount
92+
name: smi-adapter-istio
93+
namespace: istio-system
94+
roleRef:
95+
kind: ClusterRole
96+
name: smi-adapter-istio
97+
apiGroup: rbac.authorization.k8s.io
98+
---
99+
apiVersion: apps/v1
100+
kind: Deployment
101+
metadata:
102+
name: smi-adapter-istio
103+
namespace: istio-system
104+
spec:
105+
replicas: 1
106+
selector:
107+
matchLabels:
108+
name: smi-adapter-istio
109+
template:
110+
metadata:
111+
labels:
112+
name: smi-adapter-istio
113+
annotations:
114+
sidecar.istio.io/inject: "false"
115+
spec:
116+
serviceAccountName: smi-adapter-istio
117+
containers:
118+
- name: smi-adapter-istio
119+
image: docker.io/stefanprodan/smi-adapter-istio:0.0.2-beta.1
120+
command:
121+
- smi-adapter-istio
122+
imagePullPolicy: Always
123+
env:
124+
- name: WATCH_NAMESPACE
125+
value: ""
126+
- name: POD_NAME
127+
valueFrom:
128+
fieldRef:
129+
fieldPath: metadata.name
130+
- name: OPERATOR_NAME
131+
value: "smi-adapter-istio"

charts/flagger/templates/rbac.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ rules:
5555
- virtualservices
5656
- virtualservices/status
5757
verbs: ["*"]
58+
- apiGroups:
59+
- split.smi-spec.io
60+
resources:
61+
- trafficsplits
62+
verbs: ["*"]
5863
- nonResourceURLs:
5964
- /version
6065
verbs:

docs/gitbook/how-it-works.md

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ spec:
3838
# Istio gateways (optional)
3939
gateways:
4040
- public-gateway.istio-system.svc.cluster.local
41-
- mesh
4241
# Istio virtual service host names (optional)
4342
hosts:
4443
- podinfo.example.com

docs/gitbook/usage/ab-testing.md

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ spec:
6060
# Istio gateways (optional)
6161
gateways:
6262
- public-gateway.istio-system.svc.cluster.local
63-
- mesh
6463
# Istio virtual service host names (optional)
6564
hosts:
6665
- app.example.com

docs/gitbook/usage/progressive-delivery.md

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ spec:
5454
# Istio gateways (optional)
5555
gateways:
5656
- public-gateway.istio-system.svc.cluster.local
57-
- mesh
5857
# Istio virtual service host names (optional)
5958
hosts:
6059
- app.example.com

hack/update-codegen.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge
2323

2424
${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
2525
github.com/weaveworks/flagger/pkg/client github.com/weaveworks/flagger/pkg/apis \
26-
"appmesh:v1beta1 istio:v1alpha3 flagger:v1alpha3" \
26+
"appmesh:v1beta1 istio:v1alpha3 flagger:v1alpha3 smi:v1alpha1" \
2727
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt

pkg/apis/smi/register.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package smi
2+
3+
const (
4+
GroupName = "split.smi-spec.io"
5+
)

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

pkg/apis/smi/v1alpha1/register.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package v1alpha1
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/weaveworks/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: "v1alpha1",
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+
}
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package v1alpha1
2+
3+
import (
4+
"k8s.io/apimachinery/pkg/api/resource"
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" protobuf:"bytes,1,opt,name=metadata"`
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" protobuf:"bytes,2,opt,name=spec"`
27+
28+
// Most recently observed status of the pod.
29+
// This data may not be up to date.
30+
// Populated by the system.
31+
// Read-only.
32+
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
33+
// +optional
34+
//Status Status `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
35+
}
36+
37+
// TrafficSplitSpec is the specification for a TrafficSplit
38+
type TrafficSplitSpec struct {
39+
Service string `json:"service,omitempty"`
40+
Backends []TrafficSplitBackend `json:"backends,omitempty"`
41+
}
42+
43+
// TrafficSplitBackend defines a backend
44+
type TrafficSplitBackend struct {
45+
Service string `json:"service,omitempty"`
46+
Weight *resource.Quantity `json:"weight,omitempty"`
47+
}
48+
49+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
50+
51+
type TrafficSplitList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata"`
54+
55+
Items []TrafficSplit `json:"items"`
56+
}

0 commit comments

Comments
 (0)