Skip to content

Commit

Permalink
smi: update to smi-sdk-go v0.5.0 and traffic-specs v1alpha4 (openserv…
Browse files Browse the repository at this point in the history
…icemesh#2331)

This change upgrades the code to use the latest v0.5.0 SMI
SDK to be able to support v1alpha4 of SMI traffic-specs APIs.
v1alpha4 is primarily required for TCP routes support.

Resolves openservicemesh#2318

Signed-off-by: Shashank Ram <shashr2204@gmail.com>
  • Loading branch information
shashankram authored Jan 20, 2021
1 parent af93fe0 commit db184fc
Show file tree
Hide file tree
Showing 28 changed files with 198 additions and 116 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ OSM runs an Envoy based control plane on Kubernetes, can be configured with SMI

### Project status

OSM is under active development and is **NOT** ready for production workloads.
OSM is under active development and is **NOT** ready for production workloads.

### Support

Expand All @@ -62,10 +62,10 @@ OSM is an open source project that is [**not** covered by the Microsoft Azure su

| Specification Component | Supported Release | Comments |
| :---------------------------- | :--------------------------------: | :--------------------------------: |
| Traffic Access Control | [v1alpha2](https://github.com/servicemeshinterface/smi-spec/blob/master/apis/traffic-access/v1alpha2/traffic-access.md) | |
| Traffic Specs | [v1alpha3](https://github.com/servicemeshinterface/smi-spec/blob/master/apis/traffic-specs/v1alpha3/traffic-specs.md) | |
| Traffic Split | [v1alpha2](https://github.com/servicemeshinterface/smi-spec/blob/master/apis/traffic-split/v1alpha2/traffic-split.md) | |
| Traffic Metrics | [v1alpha1](https://github.com/servicemeshinterface/smi-spec/blob/master/apis/traffic-metrics/v1alpha1/traffic-metrics.md) | 🚧 **In Progress** [#379](https://github.com/openservicemesh/osm/issues/379) 🚧 |
| Traffic Access Control | [v1alpha2](https://github.com/servicemeshinterface/smi-spec/blob/v0.6.0/apis/traffic-access/v1alpha2/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 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) 🚧 |

## OSM Design

Expand Down Expand Up @@ -96,7 +96,7 @@ $ osm install
See the [installation guide](docs/installation_guide.md) for more detailed options.

## Demos
We have provided two demos for you to experience OSM.
We have provided two demos for you to experience OSM.

- The [automated demo](demo/README.md) is a set of scripts anyone can run and shows how OSM can manage, secure and provide observability for microservice environments.
- The [manual demo](docs/example/README.md) is a step-by-step walkthrough set of instruction of the automated demo.
Expand Down
80 changes: 75 additions & 5 deletions charts/osm/crds/specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ metadata:
name: httproutegroups.specs.smi-spec.io
spec:
group: specs.smi-spec.io
scope: Namespaced
scope: Namespaced
names:
kind: HTTPRouteGroup
shortNames:
- htr
plural: httproutegroups
singular: httproutegroup
version: v1alpha3
version: v1alpha4
versions:
- name: v1alpha3
- name: v1alpha4
served: true
storage: true
- name: v1alpha3
served: false
storage: false
- name: v1alpha2
served: false
storage: false
Expand Down Expand Up @@ -76,21 +79,88 @@ metadata:
name: tcproutes.specs.smi-spec.io
spec:
group: specs.smi-spec.io
scope: Namespaced
scope: Namespaced
names:
kind: TCPRoute
shortNames:
- tr
plural: tcproutes
singular: tcproute
version: v1alpha3
version: v1alpha4
versions:
- name: v1alpha4
served: true
storage: true
- name: v1alpha3
served: false
storage: false
- name: v1alpha2
served: false
storage: false
- name: v1alpha1
served: false
storage: false
validation:
openAPIV3Schema:
properties:
spec:
required:
- matches
properties:
matches:
description: Match conditions of this route.
type: object
required:
- ports
properties:
ports:
description: Port numbers to match TCP traffic.
type: array
items:
type: integer
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: udproutes.specs.smi-spec.io
spec:
group: specs.smi-spec.io
scope: Namespaced
names:
kind: UDPRoute
shortNames:
- ur
plural: udproutes
singular: udproute
version: v1alpha4
versions:
- name: v1alpha4
served: true
storage: true
- name: v1alpha3
served: false
storage: false
- name: v1alpha2
served: false
storage: false
- name: v1alpha1
served: false
storage: false
validation:
openAPIV3Schema:
properties:
spec:
required:
- matches
properties:
matches:
description: Match conditions of this route.
type: object
required:
- ports
properties:
ports:
description: Port numbers to match UDP traffic.
type: array
items:
type: integer
4 changes: 2 additions & 2 deletions demo/deploy-traffic-specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source .env

echo "Create Bookstore HTTPRouteGroup"
kubectl apply -f - <<EOF
apiVersion: specs.smi-spec.io/v1alpha3
apiVersion: specs.smi-spec.io/v1alpha4
kind: HTTPRouteGroup
metadata:
name: bookstore-service-routes
Expand All @@ -34,7 +34,7 @@ EOF

echo "Create Bookwarehouse HTTPRouteGroup"
kubectl apply -f - <<EOF
apiVersion: specs.smi-spec.io/v1alpha3
apiVersion: specs.smi-spec.io/v1alpha4
kind: HTTPRouteGroup
metadata:
name: bookwarehouse-service-routes
Expand Down
6 changes: 3 additions & 3 deletions docs/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,6 @@ $ osm dashboard
```
Simply navigate to http://localhost:3000 to access the Grafana dashboards. The default user name is `admin` and the default password is `admin`. On the Grafana homepage click on the **Home** icon, you will see a folders containing dashboards for both OSM Control Plan and OSM Data Plane.

[1]: https://github.com/servicemeshinterface/smi-spec/blob/v0.5.0/apis/traffic-access/v1alpha2/traffic-access.md
[2]: https://github.com/servicemeshinterface/smi-spec/blob/v0.5.0/apis/traffic-specs/v1alpha3/traffic-specs.md
[3]: https://github.com/servicemeshinterface/smi-spec/blob/v0.5.0/apis/traffic-split/v1alpha2/traffic-split.md
[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
2 changes: 1 addition & 1 deletion docs/example/manifests/access/traffic-access.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
#name: bookthief
#namespace: bookthief
---
apiVersion: specs.smi-spec.io/v1alpha3
apiVersion: specs.smi-spec.io/v1alpha4
kind: HTTPRouteGroup
metadata:
name: bookstore-service-routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
#name: bookthief
#namespace: bookthief
---
apiVersion: specs.smi-spec.io/v1alpha3
apiVersion: specs.smi-spec.io/v1alpha4
kind: HTTPRouteGroup
metadata:
name: bookstore-service-routes
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require (
github.com/prometheus/client_golang v1.0.0
github.com/prometheus/common v0.4.1
github.com/rs/zerolog v1.18.0
github.com/servicemeshinterface/smi-sdk-go v0.4.1
github.com/servicemeshinterface/smi-sdk-go v0.5.0
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.6.1
Expand All @@ -45,10 +45,10 @@ require (
google.golang.org/protobuf v1.23.0
gopkg.in/yaml.v2 v2.3.0
helm.sh/helm/v3 v3.2.0
k8s.io/api v0.18.6
k8s.io/api v0.18.8
k8s.io/apimachinery v0.18.8
k8s.io/cli-runtime v0.18.5
k8s.io/client-go v0.18.6
k8s.io/client-go v0.18.8
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/controller-runtime v0.6.3
sigs.k8s.io/kind v0.9.0
Expand Down
9 changes: 7 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/securego/gosec/v2 v2.5.0 h1:kjfXLeKdk98gBe2+eYRFMpC4+mxmQQtbidpiiOQ69Qc=
github.com/securego/gosec/v2 v2.5.0/go.mod h1:L/CDXVntIff5ypVHIkqPXbtRpJiNCh6c6Amn68jXDjo=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/servicemeshinterface/smi-sdk-go v0.4.1 h1:L8nS7WtVlGoEJF7RdCbwh0Oj/JheGY+5fa3R+cA2ReY=
github.com/servicemeshinterface/smi-sdk-go v0.4.1/go.mod h1:9rsLPBNcqfDNmEgyYwpopn93aE9yz46d2EHFBNOYj/w=
github.com/servicemeshinterface/smi-sdk-go v0.5.0 h1:9cZdhvGbGDlmnp9qqmcQL+RL6KZ3IzHfDLoA5Axg8n0=
github.com/servicemeshinterface/smi-sdk-go v0.5.0/go.mod h1:nm1Slf3pfaZPP3g2tE/K5wDmQ1uWVSP0p3uu5rQAQLc=
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU=
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs=
github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc=
Expand Down Expand Up @@ -1312,6 +1312,8 @@ k8s.io/api v0.18.5 h1:fKbCxr+U3fu7k6jB+QeYPD/c6xKYeSJ2KVWmyUypuWM=
k8s.io/api v0.18.5/go.mod h1:tN+e/2nbdGKOAH55NMV8oGrMG+3uRlA9GaRfvnCCSNk=
k8s.io/api v0.18.6 h1:osqrAXbOQjkKIWDTjrqxWQ3w0GkKb1KA1XkUGHHYpeE=
k8s.io/api v0.18.6/go.mod h1:eeyxr+cwCjMdLAmr2W3RyDI0VvTawSg/3RFFBEnmZGI=
k8s.io/api v0.18.8 h1:aIKUzJPb96f3fKec2lxtY7acZC9gQNDLVhfSGpxBAC4=
k8s.io/api v0.18.8/go.mod h1:d/CXqwWv+Z2XEG1LgceeDmHQwpUJhROPx16SlxJgERY=
k8s.io/apiextensions-apiserver v0.18.0 h1:HN4/P8vpGZFvB5SOMuPPH2Wt9Y/ryX+KRvIyAkchu1Q=
k8s.io/apiextensions-apiserver v0.18.0/go.mod h1:18Cwn1Xws4xnWQNC00FLq1E350b9lUF+aOdIWDOZxgo=
k8s.io/apiextensions-apiserver v0.18.5 h1:pvbXjB/BRXZiO+/Erp5Pxr+lnhDCv5uxNxHh3FLGZ/g=
Expand All @@ -1338,9 +1340,12 @@ k8s.io/client-go v0.18.5 h1:cLhGZdOmyPhwtt20Lrb7uAqxxB1uvY+NTmNJvno1oKA=
k8s.io/client-go v0.18.5/go.mod h1:EsiD+7Fx+bRckKWZXnAXRKKetm1WuzPagH4iOSC8x58=
k8s.io/client-go v0.18.6 h1:I+oWqJbibLSGsZj8Xs8F0aWVXJVIoUHWaaJV3kUN/Zw=
k8s.io/client-go v0.18.6/go.mod h1:/fwtGLjYMS1MaM5oi+eXhKwG+1UHidUEXRh6cNsdO0Q=
k8s.io/client-go v0.18.8 h1:SdbLpIxk5j5YbFr1b7fq8S7mDgDjYmUxSbszyoesoDM=
k8s.io/client-go v0.18.8/go.mod h1:HqFqMllQ5NnQJNwjro9k5zMyfhZlOwpuTLVrxjkYSxU=
k8s.io/code-generator v0.18.0/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc=
k8s.io/code-generator v0.18.5/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c=
k8s.io/code-generator v0.18.6/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c=
k8s.io/code-generator v0.18.8/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c=
k8s.io/component-base v0.18.0 h1:I+lP0fNfsEdTDpHaL61bCAqTZLoiWjEEP304Mo5ZQgE=
k8s.io/component-base v0.18.0/go.mod h1:u3BCg0z1uskkzrnAKFzulmYaEpZF7XC9Pf/uFyb1v2c=
k8s.io/component-base v0.18.5 h1:QIz2xFax8W5XQREoNcP/MHgnt4ClgfZ837Qx9yCeCzA=
Expand Down
2 changes: 1 addition & 1 deletion pkg/catalog/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"

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

"github.com/openservicemesh/osm/pkg/certificate"
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 @@ -6,7 +6,7 @@ import (

"github.com/golang/mock/gomock"
target "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2"
specs "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3"
specs "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
36 changes: 18 additions & 18 deletions pkg/catalog/mock_catalog.go

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

4 changes: 2 additions & 2 deletions pkg/catalog/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
mapset "github.com/deckarep/golang-set"
"github.com/golang/mock/gomock"
target "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3"
specs "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha3"
spec "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
specs "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/specs/v1alpha4"
tassert "github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
22 changes: 1 addition & 21 deletions pkg/catalog/traffictarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package catalog

import (
"fmt"
"strconv"
"strings"

mapset "github.com/deckarep/golang-set"
"github.com/pkg/errors"
smiAccess "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha2"

"github.com/openservicemesh/osm/pkg/identity"
Expand Down Expand Up @@ -179,25 +176,8 @@ func (mc *MeshCatalog) getTCPRouteMatchesFromTrafficTarget(trafficTarget smiAcce
return nil, errNoTrafficSpecFoundForTrafficPolicy
}

// TODO(#1521): Create an actual TCP route match once v1alpha4 TCPRoute spec is available
// Hack: derive ports from 'ports' label on the TCPRoute resource
portsStr, ok := tcpRoute.Labels["ports"]
if !ok {
continue
}
portStrList := strings.Split(portsStr, ",")
var ports []int
for i := range portStrList {
portStrList[i] = strings.TrimSpace(portStrList[i])
port, err := strconv.Atoi(portStrList[i])
if err != nil {
return nil, errors.Errorf("Invalid port value %s, must be an integer", portStrList[i])
}
ports = append(ports, port)
}

tcpRouteMatch := trafficpolicy.TCPRouteMatch{
Ports: ports,
Ports: tcpRoute.Spec.Matches.Ports,
}
matches = append(matches, tcpRouteMatch)
}
Expand Down
Loading

0 comments on commit db184fc

Please sign in to comment.