Skip to content

Commit

Permalink
feat(*): support SMI traffic split v1alpha4
Browse files Browse the repository at this point in the history
+ updates OSM to support SMI Traffic Split v1alpha4
which includes HTTPRouteGroup support enabling scenarios
such as A/B testing and routing based on HTTP attributes

* resolves openservicemesh#2759
* resolves openservicemesh#2368

Signed-off-by: Michelle Noorali <minooral@microsoft.com>
  • Loading branch information
Michelle Noorali committed Mar 16, 2021
1 parent 77dd57d commit 1dc89e8
Show file tree
Hide file tree
Showing 32 changed files with 79 additions and 59 deletions.
4 changes: 2 additions & 2 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ spec:

---

apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-traffic-split
Expand Down Expand Up @@ -190,7 +190,7 @@ This certificate's Common Name leverages the DNS-1123 standard with the followin
### (E) Policy
The policy component referenced in the diagram above (E) is any [SMI Spec resource](https://github.com/deislabs/smi-spec#service-mesh-interface) referencing the [service (C)](#c-service). For instance, `TrafficSplit`, referencing a services `bookstore`, and `bookstore-v1`:
```yaml
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-traffic-split
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,5 @@ This software is covered under the Apache 2.0 license. You can read the license

[1]: https://en.wikipedia.org/wiki/Service_mesh
[2]: https://github.com/servicemeshinterface/smi-spec/blob/master/SPEC_LATEST_STABLE.md
[3]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha2/traffic-split.md
[3]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha4/traffic-split.md
[4]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-access/v1alpha3/traffic-access.md
34 changes: 29 additions & 5 deletions charts/osm/crds/split.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ metadata:
name: trafficsplits.split.smi-spec.io
spec:
group: split.smi-spec.io
version: v1alpha2
scope: Namespaced
names:
kind: TrafficSplit
Expand All @@ -29,10 +28,20 @@ spec:
- ts
plural: trafficsplits
singular: trafficsplit
version: v1alpha4
versions:
- name: v1alpha2
served: true
storage: true
- name: v1alpha4
served: true
storage: true
- name: v1alpha3
served: false
storage: false
- name: v1alpha2
served: false
storage: false
- name: v1alpha1
served: false
storage: false
additionalPrinterColumns:
- name: Service
type: string
Expand All @@ -50,6 +59,21 @@ spec:
service:
description: The apex service of this split.
type: string
matches:
description: The HTTP route groups that this traffic split should match.
type: array
items:
type: object
required: ['kind', 'name']
properties:
kind:
description: Kind of the matching group.
type: string
enum:
- HTTPRouteGroup
name:
description: Name of the matching group.
type: string
backends:
description: The backend services of this split.
type: array
Expand All @@ -62,4 +86,4 @@ spec:
type: string
weight:
description: Traffic weight value of this backend.
type: number
type: number
5 changes: 1 addition & 4 deletions demo/deploy-traffic-split.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ set -aueo pipefail
source .env

kubectl apply -f - <<EOF
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-split
namespace: "$BOOKSTORE_NAMESPACE"
spec:
service: bookstore
backends:
- service: bookstore-v1
weight: 50
- service: bookstore-v2
weight: 50
EOF
4 changes: 2 additions & 2 deletions docs/content/docs/design_concepts/components_desc.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ spec:
app: bookstore

---
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-traffic-split
Expand Down Expand Up @@ -131,7 +131,7 @@ This certificate's Common Name leverages the DNS-1123 standard with the followin
The policy component referenced in the diagram above (E) is any [SMI Spec resource](https://github.com/deislabs/smi-spec#service-mesh-interface) referencing the [service (C)](#c-service). For instance, `TrafficSplit`, referencing a services `bookstore`, and `bookstore-v1`:

```yaml
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-traffic-split
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/getting_started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ OSM runs an Envoy based control plane on Kubernetes, can be configured with SMI

## Features

1. Easily and transparently configure [traffic shifting](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha2/traffic-split.md) for deployments
1. Easily and transparently configure [traffic shifting](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha4/traffic-split.md) for deployments
1. Secure service to service communication by [enabling mTLS](https://github.com/openservicemesh/osm/blob/main/docs/patterns/certificates.md)
1. Define and execute fine grained [access control](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-access/v1alpha3/traffic-access.md) policies for services
1. [Observability](https://github.com/openservicemesh/osm/blob/main/docs/patterns/observability/README.md) and insights into application metrics for debugging and monitoring services
Expand All @@ -42,5 +42,5 @@ OSM is under active development and is NOT ready for production workloads.
| :---------------------- | :-----------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------: |
| Traffic Access Control | [v1alpha3](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-access/v1alpha3/traffic-access.md) | |
| Traffic Specs | [v1alpha4](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-specs/v1alpha4/traffic-specs.md) | |
| Traffic Split | [v1alpha2](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha2/traffic-split.md) | |
| Traffic Split | [v1alpha4](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha4/traffic-split.md) | |
| Traffic Metrics | [v1alpha1](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-metrics/v1alpha1/traffic-metrics.md) | 🚧 **In Progress** [#379](https://github.com/openservicemesh/osm/issues/379) 🚧 |
2 changes: 1 addition & 1 deletion docs/content/docs/install/manual_demo/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,4 @@ For more details about uninstalling OSM, see the [uninstallation guide](../unins

[1]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-access/v1alpha2/traffic-access.md
[2]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-specs/v1alpha4/traffic-specs.md
[3]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha2/traffic-split.md
[3]: https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-split/v1alpha4/traffic-split.md
2 changes: 1 addition & 1 deletion docs/content/docs/troubleshooting/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If the [upgrade CRD guide](../upgrade_guide.md##crd-upgrades) was not followed,

The OSM controller will then crash with errors similar to this:
```
reflector.go:178] pkg/mod/k8s.io/client-go@v0.18.6/tools/cache/reflector.go:125: Failed to list *v1alpha2.TrafficTarget: the server could not find the requested resource (get traffictargets.access.smi-spec.io)
reflector.go:178] pkg/mod/k8s.io/client-go@v0.18.6/tools/cache/reflector.go:125: Failed to list *v1alpha4.TrafficTarget: the server could not find the requested resource (get traffictargets.access.smi-spec.io)
```
To resolve these errors:
1. Checkout the correct release branch of the [repo](https://github.com/openservicemesh/osm) and run the following commands from the root.
Expand Down
2 changes: 1 addition & 1 deletion docs/example/manifests/split/traffic-split-50-50.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-split
Expand Down
2 changes: 1 addition & 1 deletion docs/example/manifests/split/traffic-split-v1.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-split
Expand Down
2 changes: 1 addition & 1 deletion docs/example/manifests/split/traffic-split-v2.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: split.smi-spec.io/v1alpha2
apiVersion: split.smi-spec.io/v1alpha4
kind: TrafficSplit
metadata:
name: bookstore-split
Expand Down
2 changes: 1 addition & 1 deletion pkg/catalog/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"

"github.com/openservicemesh/osm/pkg/certificate"
"github.com/openservicemesh/osm/pkg/envoy"
Expand Down
2 changes: 1 addition & 1 deletion pkg/catalog/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/golang/mock/gomock"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
specs "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
testclient "k8s.io/client-go/kubernetes/fake"
Expand Down
2 changes: 1 addition & 1 deletion pkg/catalog/inbound_traffic_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/golang/mock/gomock"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
tassert "github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
6 changes: 3 additions & 3 deletions pkg/catalog/mock_catalog_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pkg/catalog/outbound_traffic_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"github.com/golang/mock/gomock"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
v1alpha2 "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
tassert "github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -377,9 +376,9 @@ func TestListOutboundTrafficPoliciesForTrafficSplits(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Namespace: tests.Namespace,
},
Spec: v1alpha2.TrafficSplitSpec{
Spec: split.TrafficSplitSpec{
Service: tests.BookstoreApexServiceName + "." + tests.Namespace,
Backends: []v1alpha2.TrafficSplitBackend{
Backends: []split.TrafficSplitBackend{
{
Service: tests.BookstoreV1ServiceName,
Weight: tests.Weight90,
Expand Down
2 changes: 1 addition & 1 deletion pkg/catalog/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/pkg/errors"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
tassert "github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/catalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/google/uuid"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
"k8s.io/client-go/kubernetes"

"github.com/openservicemesh/osm/pkg/certificate"
Expand Down
6 changes: 3 additions & 3 deletions pkg/debugger/mock_debugger_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/debugger/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"

"github.com/openservicemesh/osm/pkg/service"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/debugger/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/golang/mock/gomock"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
tassert "github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -49,6 +49,6 @@ func TestGetSMIPolicies(t *testing.T) {
responseRecorder := httptest.NewRecorder()
smiPoliciesHandler.ServeHTTP(responseRecorder, nil)
actualResponseBody := responseRecorder.Body.String()
expectedResponseBody := `{"traffic_splits":[{"metadata":{"name":"bar","namespace":"foo","creationTimestamp":null},"spec":{}}],"service_accounts":[{"Namespace":"default","Name":"bookbuyer"}],"route_groups":[{"kind":"HTTPRouteGroup","apiVersion":"specs.smi-spec.io/v1alpha4","metadata":{"name":"bookstore-service-routes","namespace":"default","creationTimestamp":null},"spec":{"matches":[{"name":"buy-books","methods":["GET"],"pathRegex":"/buy","headers":[{"user-agent":"test-UA"}]},{"name":"sell-books","methods":["GET"],"pathRegex":"/sell","headers":[{"user-agent":"test-UA"}]},{"name":"allow-everything-on-header","headers":[{"user-agent":"test-UA"}]}]}}],"traffic_targets":[{"kind":"TrafficTarget","apiVersion":"access.smi-spec.io/v1alpha3","metadata":{"name":"bookbuyer-access-bookstore","namespace":"default","creationTimestamp":null},"spec":{"destination":{"kind":"ServiceAccount","name":"bookstore","namespace":"default"},"sources":[{"kind":"ServiceAccount","name":"bookbuyer","namespace":"default"}],"rules":[{"kind":"HTTPRouteGroup","name":"bookstore-service-routes","matches":["buy-books","sell-books"]}]}}]}`
expectedResponseBody := `{"traffic_splits":[{"metadata":{"name":"bar","namespace":"foo","creationTimestamp":null},"spec":{"service":"","backends":null}}],"service_accounts":[{"Namespace":"default","Name":"bookbuyer"}],"route_groups":[{"kind":"HTTPRouteGroup","apiVersion":"specs.smi-spec.io/v1alpha4","metadata":{"name":"bookstore-service-routes","namespace":"default","creationTimestamp":null},"spec":{"matches":[{"name":"buy-books","methods":["GET"],"pathRegex":"/buy","headers":[{"user-agent":"test-UA"}]},{"name":"sell-books","methods":["GET"],"pathRegex":"/sell","headers":[{"user-agent":"test-UA"}]},{"name":"allow-everything-on-header","headers":[{"user-agent":"test-UA"}]}]}}],"traffic_targets":[{"kind":"TrafficTarget","apiVersion":"access.smi-spec.io/v1alpha3","metadata":{"name":"bookbuyer-access-bookstore","namespace":"default","creationTimestamp":null},"spec":{"destination":{"kind":"ServiceAccount","name":"bookstore","namespace":"default"},"sources":[{"kind":"ServiceAccount","name":"bookbuyer","namespace":"default"}],"rules":[{"kind":"HTTPRouteGroup","name":"bookstore-service-routes","matches":["buy-books","sell-books"]}]}}]}`
assert.Equal(expectedResponseBody, actualResponseBody, "Actual value did not match expectations:\n%s", actualResponseBody)
}
2 changes: 1 addition & 1 deletion pkg/debugger/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

Expand Down
2 changes: 1 addition & 1 deletion pkg/envoy/lds/inmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
xds_tcp_proxy "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/tcp_proxy/v3"
"github.com/envoyproxy/go-control-plane/pkg/wellknown"
"github.com/golang/protobuf/ptypes"
smiSplit "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
smiSplit "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
"google.golang.org/protobuf/types/known/wrapperspb"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down
2 changes: 1 addition & 1 deletion pkg/envoy/rds/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/google/uuid"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha2"
split "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/split/v1alpha4"
tassert "github.com/stretchr/testify/assert"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down
Loading

0 comments on commit 1dc89e8

Please sign in to comment.