Skip to content

Commit

Permalink
Added route delegate in virtualservice
Browse files Browse the repository at this point in the history
  • Loading branch information
hzxuzhonghu committed Feb 13, 2020
1 parent 6fa980c commit 4211ddf
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 2 deletions.
108 changes: 107 additions & 1 deletion networking/v1alpha3/virtual_service.proto
Expand Up @@ -228,7 +228,9 @@ message VirtualService {
// the mesh, i.e., those found in the service registry, must always be
// referred to using their alphanumeric names. IP addresses are allowed
// only for services defined via the Gateway.
repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED];
//
// *Note*: It must be empty for a delegate VirtualService.
repeated string hosts = 1;

// The names of gateways and sidecars that should apply these routes.
// Gateways in other namespaces may be referred to by
Expand Down Expand Up @@ -582,6 +584,16 @@ message HTTPRoute {
// send a HTTP 301 redirect to a different URI or Authority.
HTTPRedirect redirect = 3;

// Delegate is used to specify the particular VirtualService which
// can be used to define delegated HTTPRoute.
// It can be set only when `Route` and `Redirect` are empty, and the route rules of the
// delegated VirtualService will be merged with that in the current one.
// **NOTE**:
// 1. currently only one tier of delegate can be set.
// 2. The delegate's HTTPMatchRequest must be a strict subset of the root's,
// otherwise there is a conflict and the VirtualService will not take effect.
Delegate delegate = 20;

// Rewrite HTTP URIs and Authority headers. Rewrite cannot be used with
// Redirect primitive. Rewrite will be performed before forwarding.
HTTPRewrite rewrite = 4;
Expand Down Expand Up @@ -628,8 +640,81 @@ message HTTPRoute {

// Header manipulation rules
Headers headers = 16;

// $hide_from_docs
// Next available field number: 21
}


// Describes the delegated VirtualService.
// The following routing rules forward the traffic to `/productpage` by a delegated VirtualService named `productpage`,
// forward the traffic to `/reviews` by a delegated VirtualService named `reviews`.
//
// ```yaml
// apiVersion: networking.istio.io/v1alpha3
// kind: VirtualService
// metadata:
// name: bookinfo
// spec:
// hosts:
// - "bookinfo.com"
// gateways:
// - mygateway
// http:
// - match:
// - uri:
// prefix: "/productpage"
// delegate:
// name: productpage
// namespace: nsA
// - match:
// - uri:
// prefix: "/reviews"
// delegate:
// name: reviews
// namespace: nsB
// ```
//
// ```yaml
// apiVersion: networking.istio.io/v1alpha3
// kind: VirtualService
// metadata:
// name: productpage
// namespace: nsA
// spec:
// http:
// - match:
// - uri:
// prefix: "/productpage/v1/"
// route:
// - destination:
// host: productpage-v1.nsA.svc.cluster.local
// - route:
// - destination:
// host: productpage.nsA.svc.cluster.local
// ```
//
// ```yaml
// apiVersion: networking.istio.io/v1alpha3
// kind: VirtualService
// metadata:
// name: reviews
// namespace: nsB
// spec:
// http:
// - route:
// - destination:
// host: reviews.nsB.svc.cluster.local
// ```
message Delegate {
// Name specifies the name of the delegated VirtualService.
string name = 1;
// Namespace specifies the namespace where the delegated VirtualService resides.
// By default, it is same to the root's.
string namespace = 2;
}


// Message headers can be manipulated when Envoy forwards requests to,
// or responses from, a destination service. Header manipulation rules can
// be specified for a specific route destination or for all destinations.
Expand Down Expand Up @@ -793,6 +878,16 @@ message TLSRoute {

// The destination to which the connection should be forwarded to.
repeated RouteDestination route = 2;

// Delegate is used to specify the particular VirtualService which
// can be used to define delegated TLSRoute.
// It can be set only when `Route` is empty, and the route rules of the
// delegated VirtualService will be merged with that in the current one.
// **NOTE**:
// 1. currently only one tier of delegate can be set.
// 2. The delegate's Match conditions must be a strict subset of the root's,
// otherwise there is a conflict and the VirtualService will not take effect.
Delegate delegate = 3;
}

// Describes match conditions and actions for routing TCP traffic. The
Expand Down Expand Up @@ -849,6 +944,16 @@ message TCPRoute {

// The destination to which the connection should be forwarded to.
repeated RouteDestination route = 2;

// Delegate is used to specify the particular VirtualService which
// can be used to define delegated TCPRoute.
// It can be set only when `Route` is empty, and the route rules of the
// delegated VirtualService will be merged with that in the current one.
// **NOTE**:
// 1. currently only one tier of delegate can be set.
// 2. The delegate's Match conditions must be a strict subset of the root's,
// otherwise there is a conflict and the VirtualService will not take effect.
Delegate delegate = 3;
}

// HttpMatchRequest specifies a set of criterion to be met in order for the
Expand Down Expand Up @@ -906,6 +1011,7 @@ message TCPRoute {
// {{</tabset>}}
//
// HTTPMatchRequest CANNOT be empty.
// **Note:** No regex string match can be set when delegated VirtualService is specified.
message HTTPMatchRequest {
// The name assigned to a match. The match's name will be
// concatenated with the parent route's name and will be logged in
Expand Down
106 changes: 105 additions & 1 deletion networking/v1beta1/virtual_service.proto
Expand Up @@ -173,7 +173,9 @@ message VirtualService {
// the mesh, i.e., those found in the service registry, must always be
// referred to using their alphanumeric names. IP addresses are allowed
// only for services defined via the Gateway.
repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED];
//
// *Note*: It must be empty for a delegate VirtualService.
repeated string hosts = 1;

// The names of gateways and sidecars that should apply these routes.
// Gateways in other namespaces may be referred to by
Expand Down Expand Up @@ -413,6 +415,16 @@ message HTTPRoute {
// send a HTTP 301 redirect to a different URI or Authority.
HTTPRedirect redirect = 3;

// Delegate is used to specify the particular VirtualService which
// can be used to define delegated HTTPRoute.
// It can be set only when `Route` and `Redirect` are empty, and the route rules of the
// delegated VirtualService will be merged with that in the current one.
// **NOTE**:
// 1. currently only one tier of delegate can be set.
// 2. The delegate's HTTPMatchRequest must be a strict subset of the root's,
// otherwise there is a conflict and the VirtualService will not take effect.
Delegate delegate = 20;

// Rewrite HTTP URIs and Authority headers. Rewrite cannot be used with
// Redirect primitive. Rewrite will be performed before forwarding.
HTTPRewrite rewrite = 4;
Expand Down Expand Up @@ -459,6 +471,77 @@ message HTTPRoute {

// Header manipulation rules
Headers headers = 16;

// $hide_from_docs
// Next available field number: 21
}

// Describes the delegated VirtualService.
// The following routing rules forward the traffic to `/productpage` by a delegated VirtualService named `productpage`,
// forward the traffic to `/reviews` by a delegated VirtualService named `reviews`.
//
// ```yaml
// apiVersion: networking.istio.io/v1alpha3
// kind: VirtualService
// metadata:
// name: bookinfo
// spec:
// hosts:
// - "bookinfo.com"
// gateways:
// - mygateway
// http:
// - match:
// - uri:
// prefix: "/productpage"
// delegate:
// name: productpage
// namespace: nsA
// - match:
// - uri:
// prefix: "/reviews"
// delegate:
// name: reviews
// namespace: nsB
// ```
//
// ```yaml
// apiVersion: networking.istio.io/v1alpha3
// kind: VirtualService
// metadata:
// name: productpage
// namespace: nsA
// spec:
// http:
// - match:
// - uri:
// prefix: "/productpage/v1/"
// route:
// - destination:
// host: productpage-v1.nsA.svc.cluster.local
// - route:
// - destination:
// host: productpage.nsA.svc.cluster.local
// ```
//
// ```yaml
// apiVersion: networking.istio.io/v1alpha3
// kind: VirtualService
// metadata:
// name: reviews
// namespace: nsB
// spec:
// http:
// - route:
// - destination:
// host: reviews.nsB.svc.cluster.local
// ```
message Delegate {
// Name specifies the name of the delegated VirtualService.
string name = 1;
// Namespace specifies the namespace where the delegated VirtualService resides.
// By default, it is same to the root's.
string namespace = 2;
}

// Message headers can be manipulated when Envoy forwards requests to,
Expand Down Expand Up @@ -556,6 +639,16 @@ message TLSRoute {

// The destination to which the connection should be forwarded to.
repeated RouteDestination route = 2;

// Delegate is used to specify the particular VirtualService which
// can be used to define delegated TLSRoute.
// It can be set only when `Route` is empty, and the route rules of the
// delegated VirtualService will be merged with that in the current one.
// **NOTE**:
// 1. currently only one tier of delegate can be set.
// 2. The delegate's Match conditions must be a strict subset of the root's,
// otherwise there is a conflict and the VirtualService will not take effect.
Delegate delegate = 3;
}

// Describes match conditions and actions for routing TCP traffic. The
Expand Down Expand Up @@ -588,6 +681,16 @@ message TCPRoute {

// The destination to which the connection should be forwarded to.
repeated RouteDestination route = 2;

// Delegate is used to specify the particular VirtualService which
// can be used to define delegated TCPRoute.
// It can be set only when `Route` is empty, and the route rules of the
// delegated VirtualService will be merged with that in the current one.
// **NOTE**:
// 1. currently only one tier of delegate can be set.
// 2. The delegate's Match conditions must be a strict subset of the root's,
// otherwise there is a conflict and the VirtualService will not take effect.
Delegate delegate = 3;
}

// HttpMatchRequest specifies a set of criterion to be met in order for the
Expand Down Expand Up @@ -618,6 +721,7 @@ message TCPRoute {
// ```
//
// HTTPMatchRequest CANNOT be empty.
// **Note:** No regex string match can be set when delegated VirtualService is specified.
message HTTPMatchRequest {
// The name assigned to a match. The match's name will be
// concatenated with the parent route's name and will be logged in
Expand Down

0 comments on commit 4211ddf

Please sign in to comment.