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

Commit

Permalink
Merge pull request #80 from servicemeshinterface/root-spec
Browse files Browse the repository at this point in the history
Add top level spec field to traffic specs and targets
  • Loading branch information
stefanprodan committed Jul 14, 2020
2 parents 7cd7340 + 41764b0 commit 28318bd
Show file tree
Hide file tree
Showing 53 changed files with 2,911 additions and 130 deletions.
131 changes: 68 additions & 63 deletions crds/access.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,87 @@ apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: traffictargets.access.smi-spec.io
spec:
spec:
group: access.smi-spec.io
scope: Namespaced
names:
names:
kind: TrafficTarget
shortNames:
- tt
plural: traffictargets
singular: traffictarget
version: v1alpha1
version: v1alpha2
versions:
- name: v1alpha1
- name: v1alpha2
served: true
storage: true
- name: v1alpha1
served: false
storage: false
validation:
openAPIV3Schema:
required:
- destination
properties:
destination:
description: The destination of this traffic target.
type: object
spec:
required:
- name
- kind
- destination
properties:
kind:
description: Kind of the destination.
type: string
name:
description: Name of the destination.
type: string
namespace:
description: Namespace of the destination.
type: string
port:
description: Port number of the destination.
type: number
specs:
description: Specifications of this traffic target.
type: array
items:
type: object
required:
- name
- kind
properties:
kind:
description: Kind of this spec.
type: string
enum:
- HTTPRouteGroup
- TCPRoute
name:
description: Name of this spec.
type: string
matches:
description: Match conditions of this spec.
type: array
items:
destination:
description: The destination of this traffic target.
type: object
required:
- name
- kind
properties:
kind:
description: Kind of the destination.
type: string
name:
description: Name of the destination.
type: string
namespace:
description: Namespace of the destination.
type: string
sources:
description: Sources of this traffic target.
type: array
items:
type: object
required:
- name
- kind
properties:
kind:
description: Kind of this source.
type: string
name:
description: Name of this source.
type: string
namespace:
description: Namespace of this source.
type: string
port:
description: Port number of the destination.
type: number
rules:
description: Specifications of this traffic target.
type: array
items:
type: object
required:
- name
- kind
properties:
kind:
description: Kind of this spec.
type: string
enum:
- HTTPRouteGroup
- TCPRoute
name:
description: Name of this spec.
type: string
matches:
description: Match conditions of this spec.
type: array
items:
type: string
sources:
description: Sources of this traffic target.
type: array
items:
type: object
required:
- name
- kind
properties:
kind:
description: Kind of this source.
type: string
name:
description: Name of this source.
type: string
namespace:
description: Namespace of this source.
type: string
96 changes: 52 additions & 44 deletions crds/specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,63 @@ spec:
- htr
plural: httproutegroups
singular: httproutegroup
version: v1alpha2
version: v1alpha3
versions:
- name: v1alpha2
- name: v1alpha3
served: true
storage: true
- name: v1alpha2
served: false
storage: false
- name: v1alpha1
served: false
storage: false
validation:
openAPIV3Schema:
required:
- matches
properties:
matches:
description: Match conditions of this route group.
type: array
items:
type: object
required:
- name
properties:
name:
description: Name of the HTTP route.
type: string
pathRegex:
description: URI path regex of the HTTP route.
type: string
methods:
description: The HTTP methods of this HTTP route.
type: array
items:
type: string
description: The HTTP method of this HTTP route.
enum:
- '*'
- GET
- HEAD
- PUT
- POST
- DELETE
- CONNECT
- OPTIONS
- TRACE
- PATCH
headers:
description: Header match conditions of this route.
type: array
items:
description: Header match condition of this route.
type: object
additionalProperties:
spec:
required:
- matches
properties:
matches:
description: Match conditions of this route group.
type: array
items:
type: object
required:
- name
properties:
name:
description: Name of the HTTP route.
type: string
pathRegex:
description: URI path regex of the HTTP route.
type: string
methods:
description: The HTTP methods of this HTTP route.
type: array
items:
type: string
description: The HTTP method of this HTTP route.
enum:
- '*'
- GET
- HEAD
- PUT
- POST
- DELETE
- CONNECT
- OPTIONS
- TRACE
- PATCH
headers:
description: Header match conditions of this route.
type: array
items:
description: Header match condition of this route.
type: object
additionalProperties:
type: string
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
Expand All @@ -78,11 +83,14 @@ spec:
- tr
plural: tcproutes
singular: tcproute
version: v1alpha2
version: v1alpha3
versions:
- name: v1alpha2
- name: v1alpha3
served: true
storage: true
- name: v1alpha2
served: false
storage: false
- name: v1alpha1
served: false
storage: false
32 changes: 15 additions & 17 deletions crds/split.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ spec:
JSONPath: .spec.service
validation:
openAPIV3Schema:
required:
- spec
properties:
spec:
type: object
Expand All @@ -43,6 +41,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 @@ -56,18 +69,3 @@ spec:
weight:
description: Traffic weight value of this backend.
type: number
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
4 changes: 2 additions & 2 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ function generate_client() {
}

echo "##### Generating specs client ######"
generate_client "specs" "v1alpha1,v1alpha2"
generate_client "specs" "v1alpha1,v1alpha2,v1alpha3"

echo ""
echo "###### Generating split client ######"
generate_client "split" "v1alpha1,v1alpha2,v1alpha3"

echo ""
echo "##### Generating access client ######"
generate_client "access" "v1alpha1"
generate_client "access" "v1alpha1,v1alpha2"

echo ""
echo "##### Generating metrics client ######"
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/access/v1alpha2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// +k8s:deepcopy-gen=package
// +groupName=access.smi-spec.io

package v1alpha2
48 changes: 48 additions & 0 deletions pkg/apis/access/v1alpha2/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

ts "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access"
)

// SchemeGroupVersion is the identifier for the API which includes
// the name of the group and the version of the API
var SchemeGroupVersion = schema.GroupVersion{
Group: ts.GroupName,
Version: "v1alpha2",
}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
// SchemeBuilder collects functions that add things to a scheme. It's to allow
// code to compile without explicitly referencing generated types. You should
// declare one in each package that will have generated deep copy or conversion
// functions.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme applies all the stored functions to the scheme. A non-nil error
// indicates that one function failed and the attempt was abandoned.
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&TrafficTarget{},
&TrafficTargetList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
Loading

0 comments on commit 28318bd

Please sign in to comment.