diff --git a/Gopkg.lock b/Gopkg.lock index 438b4dafc9e..6a38a60790b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -861,6 +861,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "3cc97f3e7505f0e537f526b3f11472a99f515438f217963fd1d73894dc44f669" + inputs-digest = "a2faefe914d55104c1cff466274b267f2f32eda137c5f4339d1f29e8026dfbd5" solver-name = "gps-cdcl" solver-version = 1 diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index b560c3cf9f2..ac4051f8ed9 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -27,7 +27,7 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ github.com/knative/eventing/pkg/client github.com/knative/eventing/pkg/apis \ - "channels:v1alpha1 feeds:v1alpha1 istio:v1alpha2" \ + "channels:v1alpha1 feeds:v1alpha1, istio:v1alpha3" \ --go-header-file ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.go.txt # Make sure our dependencies are up-to-date diff --git a/pkg/apis/istio/register.go b/pkg/apis/istio/register.go index 4d6c0404047..c5accd838e6 100644 --- a/pkg/apis/istio/register.go +++ b/pkg/apis/istio/register.go @@ -1,23 +1,21 @@ /* - * Copyright 2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +Copyright 2018 Google LLC -package istio +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 -// TODO remove package after knative/serving#1002 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package istio const ( - GroupName = "config.istio.io" + GroupName = "networking.istio.io" ) diff --git a/pkg/apis/istio/v1alpha2/doc.go b/pkg/apis/istio/v1alpha2/doc.go deleted file mode 100644 index 424f9e1233d..00000000000 --- a/pkg/apis/istio/v1alpha2/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// +k8s:deepcopy-gen=package -// HACK to enable k8s go client for RouteRule resources -// +groupName=config.istio.io -package v1alpha2 diff --git a/pkg/apis/istio/v1alpha2/register.go b/pkg/apis/istio/v1alpha2/register.go deleted file mode 100644 index d65eae0097d..00000000000 --- a/pkg/apis/istio/v1alpha2/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package v1alpha2 - -import ( - "github.com/knative/eventing/pkg/apis/istio" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: istio.GroupName, Version: "v1alpha2"} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -var ( - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme -) - -func init() { - // We only register manually written functions here. The registration of the - // generated functions takes place in the generated files. The separation - // makes the code compile even when the generated files are missing. - localSchemeBuilder.Register(addKnownTypes) -} - -// Adds the list of known types to api.Scheme. -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &RouteRule{}, - &RouteRuleList{}, - ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/pkg/apis/istio/v1alpha2/routerule.go b/pkg/apis/istio/v1alpha2/routerule.go deleted file mode 100644 index 3656dd1e42b..00000000000 --- a/pkg/apis/istio/v1alpha2/routerule.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package v1alpha2 - -import ( - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +genclient -// +genclient:noStatus -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:defaulter-gen=true - -// RouteRule HACK -type RouteRule struct { - meta_v1.TypeMeta `json:",inline"` - meta_v1.ObjectMeta `json:"metadata"` - Spec RouteRuleSpec `json:"spec"` - Status *RouteRuleStatus `json:"status,omitempty"` -} - -// RouteRuleSpec HACK -type RouteRuleSpec struct { - Destination IstioService `json:"destination"` - Route []DestinationWeight `json:"route"` - Rewrite HTTPRewrite `json:"rewrite"` -} - -// IstioService HACK -type IstioService struct { - Domain string `json:"domain"` - Name string `json:"name"` - Namespace string `json:"namespace"` -} - -// DestinationWeight HACK -type DestinationWeight struct { - Destination IstioService `json:"destination"` - Weight int32 `json:"weight"` -} - -// HTTPRewrite HACK -type HTTPRewrite struct { - Authority string `json:"authority"` -} - -// RouteRuleStatus HACK -type RouteRuleStatus struct { -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// HACK -type RouteRuleList struct { - meta_v1.TypeMeta `json:",inline"` - meta_v1.ListMeta `json:"metadata"` - Items []RouteRule `json:"items"` -} diff --git a/pkg/apis/istio/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/istio/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index c66ed208c91..00000000000 --- a/pkg/apis/istio/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,182 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 2018 Google, Inc. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DestinationWeight) DeepCopyInto(out *DestinationWeight) { - *out = *in - out.Destination = in.Destination - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestinationWeight. -func (in *DestinationWeight) DeepCopy() *DestinationWeight { - if in == nil { - return nil - } - out := new(DestinationWeight) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HTTPRewrite) DeepCopyInto(out *HTTPRewrite) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRewrite. -func (in *HTTPRewrite) DeepCopy() *HTTPRewrite { - if in == nil { - return nil - } - out := new(HTTPRewrite) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IstioService) DeepCopyInto(out *IstioService) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IstioService. -func (in *IstioService) DeepCopy() *IstioService { - if in == nil { - return nil - } - out := new(IstioService) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteRule) DeepCopyInto(out *RouteRule) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - if in.Status != nil { - in, out := &in.Status, &out.Status - if *in == nil { - *out = nil - } else { - *out = new(RouteRuleStatus) - **out = **in - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteRule. -func (in *RouteRule) DeepCopy() *RouteRule { - if in == nil { - return nil - } - out := new(RouteRule) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *RouteRule) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteRuleList) DeepCopyInto(out *RouteRuleList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]RouteRule, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteRuleList. -func (in *RouteRuleList) DeepCopy() *RouteRuleList { - if in == nil { - return nil - } - out := new(RouteRuleList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *RouteRuleList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteRuleSpec) DeepCopyInto(out *RouteRuleSpec) { - *out = *in - out.Destination = in.Destination - if in.Route != nil { - in, out := &in.Route, &out.Route - *out = make([]DestinationWeight, len(*in)) - copy(*out, *in) - } - out.Rewrite = in.Rewrite - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteRuleSpec. -func (in *RouteRuleSpec) DeepCopy() *RouteRuleSpec { - if in == nil { - return nil - } - out := new(RouteRuleSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *RouteRuleStatus) DeepCopyInto(out *RouteRuleStatus) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteRuleStatus. -func (in *RouteRuleStatus) DeepCopy() *RouteRuleStatus { - if in == nil { - return nil - } - out := new(RouteRuleStatus) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/apis/istio/v1alpha2/zz_generated.defaults.go b/pkg/apis/istio/v1alpha2/zz_generated.defaults.go deleted file mode 100644 index 58996627546..00000000000 --- a/pkg/apis/istio/v1alpha2/zz_generated.defaults.go +++ /dev/null @@ -1,32 +0,0 @@ -// +build !ignore_autogenerated - -/* - * Copyright 2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// This file was autogenerated by defaulter-gen. Do not edit it manually! - -package v1alpha2 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// RegisterDefaults adds defaulters functions to the given scheme. -// Public to allow building arbitrary schemes. -// All generated defaulters are covering - they call all nested defaulters. -func RegisterDefaults(scheme *runtime.Scheme) error { - return nil -} diff --git a/pkg/client/listers/istio/v1alpha2/expansion_generated.go b/pkg/apis/istio/v1alpha3/doc.go similarity index 57% rename from pkg/client/listers/istio/v1alpha2/expansion_generated.go rename to pkg/apis/istio/v1alpha3/doc.go index 381e18b6494..a28b66df79c 100644 --- a/pkg/client/listers/istio/v1alpha2/expansion_generated.go +++ b/pkg/apis/istio/v1alpha3/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2018 Google, Inc. All rights reserved. +Copyright 2018 Google LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,14 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Code generated by lister-gen. DO NOT EDIT. +// Api versions allow the api contract for a resource to be changed while keeping +// backward compatibility by support multiple concurrent versions +// of the same resource -package v1alpha2 - -// RouteRuleListerExpansion allows custom methods to be added to -// RouteRuleLister. -type RouteRuleListerExpansion interface{} - -// RouteRuleNamespaceListerExpansion allows custom methods to be added to -// RouteRuleNamespaceLister. -type RouteRuleNamespaceListerExpansion interface{} +// +k8s:deepcopy-gen=package +// +groupName=networking.istio.io +package v1alpha3 diff --git a/pkg/apis/istio/v1alpha3/gateway_types.go b/pkg/apis/istio/v1alpha3/gateway_types.go new file mode 100644 index 00000000000..31c709ef448 --- /dev/null +++ b/pkg/apis/istio/v1alpha3/gateway_types.go @@ -0,0 +1,318 @@ +/* +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Gateway describes a load balancer operating at the edge of the mesh +// receiving incoming or outgoing HTTP/TCP connections. The specification +// describes a set of ports that should be exposed, the type of protocol to +// use, SNI configuration for the load balancer, etc. +// +// For example, the following gateway spec sets up a proxy to act as a load +// balancer exposing port 80 and 9080 (http), 443 (https), and port 2379 +// (TCP) for ingress. The gateway will be applied to the proxy running on +// a pod with labels "app: my-gateway-controller". While Istio will configure the +// proxy to listen on these ports, it is the responsibility of the user to +// ensure that external traffic to these ports are allowed into the mesh. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-gateway +// spec: +// selector: +// app: my-gatweway-controller +// servers: +// - port: +// number: 80 +// name: http +// protocol: HTTP +// hosts: +// - uk.bookinfo.com +// - eu.bookinfo.com +// tls: +// httpsRedirect: true # sends 302 redirect for http requests +// - port: +// number: 443 +// name: https +// protocol: HTTPS +// hosts: +// - uk.bookinfo.com +// - eu.bookinfo.com +// tls: +// mode: SIMPLE #enables HTTPS on this port +// serverCertificate: /etc/certs/servercert.pem +// privateKey: /etc/certs/privatekey.pem +// - port: +// number: 9080 +// name: http-wildcard +// protocol: HTTP +// # no hosts implies wildcard match +// - port: +// number: 2379 #to expose internal service via external port 2379 +// name: mongo +// protocol: MONGO +// +// The gateway specification above describes the L4-L6 properties of a load +// balancer. A VirtualService can then be bound to a gateway to control +// the forwarding of traffic arriving at a particular host or gateway port. +// +// For example, the following VirtualService splits traffic for +// https://uk.bookinfo.com/reviews, https://eu.bookinfo.com/reviews, +// http://uk.bookinfo.com:9080/reviews, http://eu.bookinfo.com:9080/reviews +// into two versions (prod and qa) of an internal reviews service on port +// 9080. In addition, requests containing the cookie user: dev-123 will be +// sent to special port 7777 in the qa version. The same rule is also +// applicable inside the mesh for requests to the reviews.prod +// service. This rule is applicable across ports 443, 9080. Note that +// http://uk.bookinfo.com gets redirected to https://uk.bookinfo.com +// (i.e. 80 redirects to 443). +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: bookinfo-rule +// spec: +// hosts: +// - reviews.prod +// - uk.bookinfo.com +// - eu.bookinfo.com +// gateways: +// - my-gateway +// - mesh # applies to all the sidecars in the mesh +// http: +// - match: +// - headers: +// cookie: +// user: dev-123 +// route: +// - destination: +// port: +// number: 7777 +// name: reviews.qa +// - match: +// uri: +// prefix: /reviews/ +// route: +// - destination: +// port: +// number: 9080 # can be omitted if its the only port for reviews +// name: reviews.prod +// weight: 80 +// - destination: +// name: reviews.qa +// weight: 20 +// +// The following VirtualService forwards traffic arriving at (external) port +// 2379 from 172.17.16.0/24 subnet to internal Mongo server on port 5555. This +// rule is not applicable internally in the mesh as the gateway list omits +// the reserved name "mesh". +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: bookinfo-Mongo +// spec: +// hosts: +// - mongosvr #name of Mongo service +// gateways: +// - my-gateway +// tcp: +// - match: +// - port: +// number: 2379 +// sourceSubnet: "172.17.16.0/24" +// route: +// - destination: +// name: mongo.prod +// +type Gateway struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec GatewaySpec `json:"spec"` +} + +type GatewaySpec struct { + // REQUIRED: A list of server specifications. + Servers []Server `json:"servers"` + + // One or more labels that indicate a specific set of pods/VMs + // on which this gateway configuration should be applied. + // If no selectors are provided, the gateway will be implemented by + // the default istio-ingress controller. + Selector map[string]string `json:"selector,omitempty"` +} + +// Server describes the properties of the proxy on a given load balancer port. +// For example, +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-ingress +// spec: +// selector: +// app: my-ingress-controller +// servers: +// - port: +// number: 80 +// name: http2 +// protocol: HTTP2 +// +// Another example +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-tcp-ingress +// spec: +// selector: +// app: my-tcp-ingress-controller +// servers: +// - port: +// number: 27018 +// name: mongo +// protocol: MONGO +// +// The following is an example of TLS configuration for port 443 +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: Gateway +// metadata: +// name: my-tls-ingress +// spec: +// selector: +// app: my-tls-ingress-controller +// servers: +// - port: +// number: 443 +// name: https +// protocol: HTTPS +// tls: +// mode: SIMPLE +// serverCertificate: /etc/certs/server.pem +// privateKey: /etc/certs/privatekey.pem +// +type Server struct { + // REQUIRED: The Port on which the proxy should listen for incoming + // connections + Port Port `json:"port"` + + // A list of hosts exposed by this gateway. While + // typically applicable to HTTP services, it can also be used for TCP + // services using TLS with SNI. Standard DNS wildcard prefix syntax + // is permitted. + // + // A VirtualService that is bound to a gateway must having a matching host + // in its default destination. Specifically one of the VirtualService + // destination hosts is a strict suffix of a gateway host or + // a gateway host is a suffix of one of the VirtualService hosts. + Hosts []string `json:"hosts,omitempty"` + + // Set of TLS related options that govern the server's behavior. Use + // these options to control if all http requests should be redirected to + // https, and the TLS modes to use. + TLS *TLSOptions `json:"tls,omitempty"` +} + +type TLSOptions struct { + // If set to true, the load balancer will send a 302 redirect for all + // http connections, asking the clients to use HTTPS. + HttpsRedirect bool `json:"httpsRedirect"` + + // Optional: Indicates whether connections to this port should be + // secured using TLS. The value of this field determines how TLS is + // enforced. + Mode TLSMode `json:"mode,omitempty"` + + // REQUIRED if mode is "SIMPLE" or "MUTUAL". The path to the file + // holding the server-side TLS certificate to use. + ServerCertificate string `json:"serverCertificate"` + + // REQUIRED if mode is "SIMPLE" or "MUTUAL". The path to the file + // holding the server's private key. + PrivateKey string `json:"privateKey"` + + // REQUIRED if mode is "MUTUAL". The path to a file containing + // certificate authority certificates to use in verifying a presented + // client side certificate. + CaCertificates string `json:"caCertificates"` + + // A list of alternate names to verify the subject identity in the + // certificate presented by the client. + SubjectAltNames []string `json:"subjectAltNames"` +} + +// TLS modes enforced by the proxy +type TLSMode string + +const ( + // If set to "PASSTHROUGH", the proxy will forward the connection + // to the upstream server selected based on the SNI string presented + // by the client. + TLSModePassThrough TLSMode = "PASSTHROUGH" + + // If set to "SIMPLE", the proxy will secure connections with + // standard TLS semantics. + TLSModeSimple TLSMode = "SIMPLE" + + // If set to "MUTUAL", the proxy will secure connections to the + // upstream using mutual TLS by presenting client certificates for + // authentication. + TLSModeMutual TLSMode = "MUTUAL" +) + +// Port describes the properties of a specific port of a service. +type Port struct { + // REQUIRED: A valid non-negative integer port number. + Number int `json:"number"` + + // REQUIRED: The protocol exposed on the port. + // MUST BE one of HTTP|HTTPS|GRPC|HTTP2|MONGO|TCP. + Protocol PortProtocol `json:"protocol"` + + // Label assigned to the port. + Name string `json:"name,omitempty"` +} + +type PortProtocol string + +const ( + ProtocolHTTP PortProtocol = "HTTP" + ProtocolHTTPS PortProtocol = "HTTPS" + ProtocolGRPC PortProtocol = "GRPC" + ProtocolHTTP2 PortProtocol = "HTTP2" + ProtocolMongo PortProtocol = "Mongo" + ProtocolTCP PortProtocol = "TCP" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// GatewayList is a list of Gateway resources +type GatewayList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Gateway `json:"items"` +} diff --git a/pkg/apis/istio/v1alpha3/register.go b/pkg/apis/istio/v1alpha3/register.go new file mode 100644 index 00000000000..3ffcc209788 --- /dev/null +++ b/pkg/apis/istio/v1alpha3/register.go @@ -0,0 +1,52 @@ +/* +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha3 + +import ( + istio "github.com/knative/eventing/pkg/apis/istio" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: istio.GroupName, Version: "v1alpha3"} + +// 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 = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &VirtualService{}, + &Gateway{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/istio/v1alpha3/virtualservice_types.go b/pkg/apis/istio/v1alpha3/virtualservice_types.go new file mode 100644 index 00000000000..fd659288607 --- /dev/null +++ b/pkg/apis/istio/v1alpha3/virtualservice_types.go @@ -0,0 +1,783 @@ +/* +Copyright 2018 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha3 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VirtualService +type VirtualService struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec VirtualServiceSpec `json:"spec"` +} + +// A VirtualService defines a set of traffic routing rules to apply when a host is +// addressed. Each routing rule defines matching criteria for traffic of a specific +// protocol. If the traffic is matched, then it is sent to a named destination service +// (or subset/version of it) defined in the registry. +// +// The source of traffic can also be matched in a routing rule. This allows routing +// to be customized for specific client contexts. +// +// The following example routes all HTTP traffic by default to +// pods of the reviews service with label "version: v1". In addition, +// HTTP requests containing /wpcatalog/, /consumercatalog/ url prefixes will +// be rewritten to /newcatalog and sent to pods with label "version: v2". The +// rules will be applied at the gateway named "bookinfo" as well as at all +// the sidecars in the mesh (indicated by the reserved gateway name +// "mesh"). +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: reviews-route +// spec: +// hosts: +// - reviews +// gateways: # if omitted, defaults to "mesh" +// - bookinfo +// - mesh +// http: +// - match: +// - uri: +// prefix: "/wpcatalog" +// - uri: +// prefix: "/consumercatalog" +// rewrite: +// uri: "/newcatalog" +// route: +// - destination: +// host: reviews +// subset: v2 +// - route: +// - destination: +// host: reviews +// subset: v1 +// +// A subset/version of a route destination is identified with a reference +// to a named service subset which must be declared in a corresponding +// DestinationRule. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: DestinationRule +// metadata: +// name: reviews-destination +// spec: +// host: reviews +// subsets: +// - name: v1 +// labels: +// version: v1 +// - name: v2 +// labels: +// version: v2 +// +// A host name can be defined by only one VirtualService. A single +// VirtualService can be used to describe traffic properties for multiple +// HTTP and TCP ports. +type VirtualServiceSpec struct { + // REQUIRED. The destination address for traffic captured by this virtual + // service. Could be a DNS name with wildcard prefix or a CIDR + // prefix. Depending on the platform, short-names can also be used + // instead of a FQDN (i.e. has no dots in the name). In such a scenario, + // the FQDN of the host would be derived based on the underlying + // platform. + // + // For example on Kubernetes, when hosts contains a short name, Istio will + // interpret the short name based on the namespace of the rule. Thus, when a + // client namespace applies a rule in the "default" namespace containing a name + // "reviews, Istio will setup routes to the "reviews.default.svc.cluster.local" + // service. However, if a different name such as "reviews.sales.svc.cluster.local" + // is used, it would be treated as a FQDN during virtual host matching. + // In Consul, a plain service name would be resolved to the FQDN + // "reviews.service.consul". + // + // Note that the hosts field applies to both HTTP and TCP + // services. Service inside the mesh, i.e., those found in the service + // registry, must always be referred to using their alphanumeric + // names. IP addresses or CIDR prefixes are allowed only for services + // defined via the Gateway. + Hosts []string `json:"hosts"` + + // The names of gateways and sidecars that should apply these routes. A + // single VirtualService is used for sidecars inside the mesh as well + // as for one or more gateways. The selection condition imposed by this field + // can be overridden using the source field in the match conditions of HTTP/TCP + // routes. The reserved word "mesh" is used to imply all the sidecars in + // the mesh. When this field is omitted, the default gateway ("mesh") + // will be used, which would apply the rule to all sidecars in the + // mesh. If a list of gateway names is provided, the rules will apply + // only to the gateways. To apply the rules to both gateways and sidecars, + // specify "mesh" as one of the gateway names. + Gateways []string `json:"gateways,omitempty"` + + // An ordered list of route rules for HTTP traffic. + // The first rule matching an incoming request is used. + Http []HTTPRoute `json:"http,omitempty"` + + // An ordered list of route rules for TCP traffic. + // The first rule matching an incoming request is used. + Tcp []TCPRoute `json:"tcp,omitempty"` +} + +// Describes match conditions and actions for routing HTTP/1.1, HTTP2, and +// gRPC traffic. See VirtualService for usage examples. +type HTTPRoute struct { + // Match conditions to be satisfied for the rule to be + // activated. All conditions inside a single match block have AND + // semantics, while the list of match blocks have OR semantics. The rule + // is matched if any one of the match blocks succeed. + Match []HTTPMatchRequest `json:"match,omitempty"` + + // A http rule can either redirect or forward (default) traffic. The + // forwarding target can be one of several versions of a service (see + // glossary in beginning of document). Weights associated with the + // service version determine the proportion of traffic it receives. + Route []DestinationWeight `json:"route,omitempty"` + + // A http rule can either redirect or forward (default) traffic. If + // traffic passthrough option is specified in the rule, + // route/redirect will be ignored. The redirect primitive can be used to + // send a HTTP 302 redirect to a different URI or Authority. + Redirect *HTTPRedirect `json:"redirect,omitempty"` + + // Rewrite HTTP URIs and Authority headers. Rewrite cannot be used with + // Redirect primitive. Rewrite will be performed before forwarding. + Rewrite *HTTPRewrite `json:"rewrite,omitempty"` + + // Indicates that a HTTP/1.1 client connection to this particular route + // should be allowed (and expected) to upgrade to a WebSocket connection. + // The default is false. Istio's reference sidecar implementation (Envoy) + // expects the first request to this route to contain the WebSocket + // upgrade headers. Otherwise, the request will be rejected. Note that + // Websocket allows secondary protocol negotiation which may then be + // subject to further routing rules based on the protocol selected. + WebsocketUpgrade bool `json:"websocketUpgrade,omitempty"` + + // Timeout for HTTP requests. + Timeout string `json:"timeout,omitempty"` + + // Retry policy for HTTP requests. + Retries *HTTPRetry `json:"retries,omitempty"` + + //Fault injection policy to apply on HTTP traffic. + Fault *HTTPFaultInjection `json:"fault,omitempty"` + + // Mirror HTTP traffic to a another destination in addition to forwarding + // the requests to the intended destination. Mirrored traffic is on a + // best effort basis where the sidecar/gateway will not wait for the + // mirrored cluster to respond before returning the response from the + // original destination. Statistics will be generated for the mirrored + // destination. + Mirror *Destination `json:"mirror,omitempty"` + + // Additional HTTP headers to add before forwarding a request to the + // destination service. + AppendHeaders map[string]string `json:"appendHeaders,omitempty"` + + // Http headers to remove before returning the response to the caller + RemoveResponseHeaders map[string]string `json:"removeResponseHeaders,omitempty"` +} + +// HttpMatchRequest specifies a set of criterion to be met in order for the +// rule to be applied to the HTTP request. For example, the following +// restricts the rule to match only requests where the URL path +// starts with /ratings/v2/ and the request contains a "cookie" with value +// "user=jason". +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - match: +// - headers: +// cookie: +// regex: "^(.*?;)?(user=jason)(;.*)?" +// uri: +// prefix: "/ratings/v2/" +// route: +// - destination: +// host: ratings +// +// HTTPMatchRequest CANNOT be empty. +type HTTPMatchRequest struct { + // URI to match + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Uri *StringMatch `json:"uri,omitempty"` + + // URI Scheme + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Scheme *StringMatch `json:"scheme,omitempty"` + + // HTTP Method + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Method *StringMatch `json:"method,omitempty"` + + // HTTP Authority + // values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + Authority *StringMatch `json:"authority,omitempty"` + + // The header keys must be lowercase and use hyphen as the separator, + // e.g. _x-request-id_. + // + // Header values are case-sensitive and formatted as follows: + // + // - `exact: "value"` for exact string match + // + // - `prefix: "value"` for prefix-based match + // + // - `regex: "value"` for ECMAscript style regex-based match + // + // **Note:** The keys `uri`, `scheme`, `method`, and `authority` will be ignored. + Headers map[string]StringMatch `json:"headers,omitempty"` +} + +// Describes how to match a given string in HTTP headers. Match is +// case-sensitive. +type StringMatch struct { + // Specified exactly one of the fields below. + + // exact string match + Exact string `json:"exact,omitempty"` + + // prefix-based match + Prefix string `json:"prefix,omitempty"` + + // ECMAscript style regex-based match + Regex string `json:"regex,omitempty"` +} + +type DestinationWeight struct { + // REQUIRED. Destination uniquely identifies the instances of a service + // to which the request/connection should be forwarded to. + Destination Destination `json:"destination"` + + // REQUIRED. The proportion of traffic to be forwarded to the service + // version. (0-100). Sum of weights across destinations SHOULD BE == 100. + // If there is only destination in a rule, the weight value is assumed to + // be 100. + Weight int `json:"weight"` +} + +// Destination indicates the network addressable service to which the +// request/connection will be sent after processing a routing rule. The +// destination.name should unambiguously refer to a service in the service +// registry. It can be a short name or a fully qualified domain name from +// the service registry, a resolvable DNS name, an IP address or a service +// name from the service registry and a subset name. The order of inference +// is as follows: +// +// 1. Service registry lookup. The entire name is looked up in the service +// registry. If the lookup succeeds, the search terminates. The requests +// will be routed to any instance of the service in the mesh. When the +// service name consists of a single word, the FQDN will be constructed in +// a platform specific manner. For example, in Kubernetes, the namespace +// associated with the routing rule will be used to identify the service as +// .. However, if the service name contains +// multiple words separated by a dot (e.g., reviews.prod), the name in its +// entirety would be looked up in the service registry. +// +// 2. Runtime DNS lookup by the proxy. If step 1 fails, and the name is not +// an IP address, it will be considered as a DNS name that is not in the +// service registry (e.g., wikipedia.org). The sidecar/gateway will resolve +// the DNS and load balance requests appropriately. See Envoy's strict_dns +// for details. +// +// The following example routes all traffic by default to pods of the +// reviews service with label "version: v1" (i.e., subset v1), and some +// to subset v2, in a kubernetes environment. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: reviews-route +// spec: +// hosts: +// - reviews # namespace is same as the client/caller's namespace +// http: +// - match: +// - uri: +// prefix: "/wpcatalog" +// - uri: +// prefix: "/consumercatalog" +// rewrite: +// uri: "/newcatalog" +// route: +// - destination: +// host: reviews +// subset: v2 +// - route: +// - destination: +// host: reviews +// subset: v1 +// +// And the associated DestinationRule +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: DestinationRule +// metadata: +// name: reviews-destination +// spec: +// host: reviews +// subsets: +// - name: v1 +// labels: +// version: v1 +// - name: v2 +// labels: +// version: v2 +// +// The following VirtualService sets a timeout of 5s for all calls to +// productpage.prod service. Notice that there are no subsets defined in +// this rule. Istio will fetch all instances of productpage.prod service +// from the service registry and populate the sidecar's load balancing +// pool. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: my-productpage-rule +// spec: +// hosts: +// - productpage.prod # in kubernetes, this applies only to prod namespace +// http: +// - timeout: 5s +// route: +// - destination: +// host: productpage.prod +// +// The following sets a timeout of 5s for all calls to the external +// service wikipedia.org, as there is no internal service of that name. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: my-wiki-rule +// spec: +// hosts: +// - wikipedia.org +// http: +// - timeout: 5s +// route: +// - destination: +// host: wikipedia.org +// +type Destination struct { + // REQUIRED. The name of a service from the service registry. Service + // names are looked up from the platform's service registry (e.g., + // Kubernetes services, Consul services, etc.) and from the hosts + // declared by [ServiceEntry](#ServiceEntry). Traffic forwarded to + // destinations that are not found in either of the two, will be dropped. + // + // *Note for Kubernetes users*: When short names are used (e.g. "reviews" + // instead of "reviews.default.svc.cluster.local"), Istio will interpret + // the short name based on the namespace of the rule, not the service. A + // rule in the "default" namespace containing a host "reviews will be + // interpreted as "reviews.default.svc.cluster.local", irrespective of + // the actual namespace associated with the reviews service. _To avoid + // potential misconfigurations, it is recommended to always use fully + // qualified domain names over short names._ + Host string `json:"host"` + + // The name of a subset within the service. Applicable only to services + // within the mesh. The subset must be defined in a corresponding + // DestinationRule. + Subset string `json:"subset,omitempty"` + + // Specifies the port on the host that is being addressed. If a service + // exposes only a single port it is not required to explicitly select the + // port. + Port PortSelector `json:"port,omitempty"` +} + +// PortSelector specifies the number of a port to be used for +// matching or selection for final routing. +type PortSelector struct { + // Choose one of the fields below. + + // Valid port number + Number uint32 `json:"number,omitempty"` + + // Valid port name + Name string `json:"name,omitempty"` +} + +// Describes match conditions and actions for routing TCP traffic. The +// following routing rule forwards traffic arriving at port 27017 for +// mongo.prod.svc.cluster.local from 172.17.16.* subnet to another Mongo +// server on port 5555. +// +// ```yaml +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: bookinfo-Mongo +// spec: +// hosts: +// - mongo.prod.svc.cluster.local +// tcp: +// - match: +// - port: 27017 +// sourceSubnet: "172.17.16.0/24" +// route: +// - destination: +// host: mongo.backup.svc.cluster.local +// port: +// number: 5555 +// ``` +type TCPRoute struct { + // Match conditions to be satisfied for the rule to be + // activated. All conditions inside a single match block have AND + // semantics, while the list of match blocks have OR semantics. The rule + // is matched if any one of the match blocks succeed. + Match []L4MatchAttributes `json:"match"` + + // The destination to which the connection should be forwarded to. + // Currently, only one destination is allowed for TCP services. When TCP + // weighted routing support is introduced in Envoy, multiple destinations + // with weights can be specified. + Route DestinationWeight `json:"route"` +} + +// L4 connection match attributes. Note that L4 connection matching support +// is incomplete. +type L4MatchAttributes struct { + // IPv4 or IPv6 ip address of destination with optional subnet. E.g., + // a.b.c.d/xx form or just a.b.c.d. This is only valid when the + // destination service has several IPs and the application explicitly + // specifies a particular IP. + DestinationSubnet string `json:"destinationSubnet,omitempty"` + + // Specifies the port on the host that is being addressed. Many services + // only expose a single port or label ports with the protocols they support, + // in these cases it is not required to explicitly select the port. + Port int `json:"port,omitempty"` + + // IPv4 or IPv6 ip address of source with optional subnet. E.g., a.b.c.d/xx + // form or just a.b.c.d + SourceSubnet string `json:"sourceSubnet,omitempty"` + + // One or more labels that constrain the applicability of a rule to + // workloads with the given labels. If the VirtualService has a list of + // gateways specified at the top, it should include the reserved gateway + // `mesh` in order for this field to be applicable. + SourceLabel map[string]string `json:"sourceLabel,omitempty"` + + // Names of gateways where the rule should be applied to. Gateway names + // at the top of the VirtualService (if any) are overridden. The gateway match is + // independent of sourceLabels. + Gateways []string `json:"gateways,omitempty"` +} + +// HTTPRedirect can be used to send a 302 redirect response to the caller, +// where the Authority/Host and the URI in the response can be swapped with +// the specified values. For example, the following rule redirects +// requests for /v1/getProductRatings API on the ratings service to +// /v1/bookRatings provided by the bookratings service. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - match: +// - uri: +// exact: /v1/getProductRatings +// redirect: +// uri: /v1/bookRatings +// authority: bookratings.default.svc.cluster.local +// ... +// +type HTTPRedirect struct { + // On a redirect, overwrite the Path portion of the URL with this + // value. Note that the entire path will be replaced, irrespective of the + // request URI being matched as an exact path or prefix. + Uri string `json:"uri,omitempty"` + + // On a redirect, overwrite the Authority/Host portion of the URL with + // this value. + Authority string `json:"authority,omitempty"` +} + +// HTTPRewrite can be used to rewrite specific parts of a HTTP request +// before forwarding the request to the destination. Rewrite primitive can +// be used only with the DestinationWeights. The following example +// demonstrates how to rewrite the URL prefix for api call (/ratings) to +// ratings service before making the actual API call. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - match: +// - uri: +// prefix: /ratings +// rewrite: +// uri: /v1/bookRatings +// route: +// - destination: +// host: ratings +// subset: v1 +// +type HTTPRewrite struct { + // rewrite the path (or the prefix) portion of the URI with this + // value. If the original URI was matched based on prefix, the value + // provided in this field will replace the corresponding matched prefix. + Uri string `json:"uri,omitempty"` + + // rewrite the Authority/Host header with this value. + Authority string `json:"authority,omitempty"` +} + +// Describes the retry policy to use when a HTTP request fails. For +// example, the following rule sets the maximum number of retries to 3 when +// calling ratings:v1 service, with a 2s timeout per retry attempt. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - route: +// - destination: +// host: ratings +// subset: v1 +// retries: +// attempts: 3 +// perTryTimeout: 2s +// +type HTTPRetry struct { + // REQUIRED. Number of retries for a given request. The interval + // between retries will be determined automatically (25ms+). Actual + // number of retries attempted depends on the httpReqTimeout. + Attempts int `json:"attempts"` + + // Timeout per retry attempt for a given request. format: 1h/1m/1s/1ms. MUST BE >=1ms. + PerTryTimeout string `json:"perTryTimeout"` +} + +// Describes the Cross-Origin Resource Sharing (CORS) policy, for a given +// service. Refer to +// https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS +// for further details about cross origin resource sharing. For example, +// the following rule restricts cross origin requests to those originating +// from example.com domain using HTTP POST/GET, and sets the +// Access-Control-Allow-Credentials header to false. In addition, it only +// exposes X-Foo-bar header and sets an expiry period of 1 day. +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - route: +// - destination: +// host: ratings +// subset: v1 +// corsPolicy: +// allowOrigin: +// - example.com +// allowMethods: +// - POST +// - GET +// allowCredentials: false +// allowHeaders: +// - X-Foo-Bar +// maxAge: "1d" +// +type CorsPolicy struct { + // The list of origins that are allowed to perform CORS requests. The + // content will be serialized into the Access-Control-Allow-Origin + // header. Wildcard * will allow all origins. + AllowOrigin []string `json:"allowOrigin,omitempty"` + + // List of HTTP methods allowed to access the resource. The content will + // be serialized into the Access-Control-Allow-Methods header. + AllowMethods []string `json:"allowMethods,omitempty"` + + // List of HTTP headers that can be used when requesting the + // resource. Serialized to Access-Control-Allow-Methods header. + AllowHeaders []string `json:"allowHeaders,omitempty"` + + // A white list of HTTP headers that the browsers are allowed to + // access. Serialized into Access-Control-Expose-Headers header. + ExposeHeaders []string `json:"exposeHeaders,omitempty"` + + // Specifies how long the the results of a preflight request can be + // cached. Translates to the Access-Control-Max-Age header. + MaxAge string `json:"maxAge,omitempty"` + + // Indicates whether the caller is allowed to send the actual request + // (not the preflight) using credentials. Translates to + // Access-Control-Allow-Credentials header. + AllowCredentials bool `json:"allowCredentials,omitempty"` +} + +// HTTPFaultInjection can be used to specify one or more faults to inject +// while forwarding http requests to the destination specified in a route. +// Fault specification is part of a VirtualService rule. Faults include +// aborting the Http request from downstream service, and/or delaying +// proxying of requests. A fault rule MUST HAVE delay or abort or both. +// +// *Note:* Delay and abort faults are independent of one another, even if +// both are specified simultaneously. +type HTTPFaultInjection struct { + // Delay requests before forwarding, emulating various failures such as + // network issues, overloaded upstream service, etc. + Delay *InjectDelay `json:"delay,omitempty"` + + // Abort Http request attempts and return error codes back to downstream + // service, giving the impression that the upstream service is faulty. + Abort *InjectAbort `json:"abort,omitempty"` +} + +// Delay specification is used to inject latency into the request +// forwarding path. The following example will introduce a 5 second delay +// in 10% of the requests to the "v1" version of the "reviews" +// service from all pods with label env: prod +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: reviews-route +// spec: +// hosts: +// - reviews +// http: +// - match: +// - sourceLabels: +// env: prod +// route: +// - destination: +// host: reviews +// subset: v1 +// fault: +// delay: +// percent: 10 +// fixedDelay: 5s +// +// The _fixedDelay_ field is used to indicate the amount of delay in +// seconds. An optional _percent_ field, a value between 0 and 100, can +// be used to only delay a certain percentage of requests. If left +// unspecified, all request will be delayed. +type InjectDelay struct { + // Percentage of requests on which the delay will be injected (0-100). + Percent int `json:"percent,omitempty"` + + // REQUIRED. Add a fixed delay before forwarding the request. Format: + // 1h/1m/1s/1ms. MUST be >=1ms. + FixedDelay string `json:"fixedDelay"` + + // (-- Add a delay (based on an exponential function) before forwarding + // the request. mean delay needed to derive the exponential delay + // values --) + ExponentialDelay string `json:"exponentialDelay,omitempty"` +} + +// Abort specification is used to prematurely abort a request with a +// pre-specified error code. The following example will return an HTTP +// 400 error code for 10% of the requests to the "ratings" service "v1". +// +// apiVersion: networking.istio.io/v1alpha3 +// kind: VirtualService +// metadata: +// name: ratings-route +// spec: +// hosts: +// - ratings +// http: +// - route: +// - destination: +// host: ratings +// subset: v1 +// fault: +// abort: +// percent: 10 +// httpStatus: 400 +// +// The _httpStatus_ field is used to indicate the HTTP status code to +// return to the caller. The optional _percent_ field, a value between 0 +// and 100, is used to only abort a certain percentage of requests. If +// not specified, all requests are aborted. +type InjectAbort struct { + // Percentage of requests to be aborted with the error code provided (0-100). + Perecent int `json:"percent,omitempty"` + + // REQUIRED. HTTP status code to use to abort the Http request. + HttpStatus int `json:"httpStatus"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// VirtualServiceList is a list of VirtualService resources +type VirtualServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []VirtualService `json:"items"` +} diff --git a/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go b/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go new file mode 100644 index 00000000000..8fde0cd8007 --- /dev/null +++ b/pkg/apis/istio/v1alpha3/zz_generated.deepcopy.go @@ -0,0 +1,697 @@ +// +build !ignore_autogenerated + +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CorsPolicy) DeepCopyInto(out *CorsPolicy) { + *out = *in + if in.AllowOrigin != nil { + in, out := &in.AllowOrigin, &out.AllowOrigin + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AllowMethods != nil { + in, out := &in.AllowMethods, &out.AllowMethods + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.AllowHeaders != nil { + in, out := &in.AllowHeaders, &out.AllowHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.ExposeHeaders != nil { + in, out := &in.ExposeHeaders, &out.ExposeHeaders + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CorsPolicy. +func (in *CorsPolicy) DeepCopy() *CorsPolicy { + if in == nil { + return nil + } + out := new(CorsPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Destination) DeepCopyInto(out *Destination) { + *out = *in + out.Port = in.Port + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. +func (in *Destination) DeepCopy() *Destination { + if in == nil { + return nil + } + out := new(Destination) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DestinationWeight) DeepCopyInto(out *DestinationWeight) { + *out = *in + out.Destination = in.Destination + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DestinationWeight. +func (in *DestinationWeight) DeepCopy() *DestinationWeight { + if in == nil { + return nil + } + out := new(DestinationWeight) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Gateway) DeepCopyInto(out *Gateway) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Gateway. +func (in *Gateway) DeepCopy() *Gateway { + if in == nil { + return nil + } + out := new(Gateway) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Gateway) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GatewayList) DeepCopyInto(out *GatewayList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Gateway, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewayList. +func (in *GatewayList) DeepCopy() *GatewayList { + if in == nil { + return nil + } + out := new(GatewayList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GatewayList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GatewaySpec) DeepCopyInto(out *GatewaySpec) { + *out = *in + if in.Servers != nil { + in, out := &in.Servers, &out.Servers + *out = make([]Server, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GatewaySpec. +func (in *GatewaySpec) DeepCopy() *GatewaySpec { + if in == nil { + return nil + } + out := new(GatewaySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPFaultInjection) DeepCopyInto(out *HTTPFaultInjection) { + *out = *in + if in.Delay != nil { + in, out := &in.Delay, &out.Delay + if *in == nil { + *out = nil + } else { + *out = new(InjectDelay) + **out = **in + } + } + if in.Abort != nil { + in, out := &in.Abort, &out.Abort + if *in == nil { + *out = nil + } else { + *out = new(InjectAbort) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPFaultInjection. +func (in *HTTPFaultInjection) DeepCopy() *HTTPFaultInjection { + if in == nil { + return nil + } + out := new(HTTPFaultInjection) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPMatchRequest) DeepCopyInto(out *HTTPMatchRequest) { + *out = *in + if in.Uri != nil { + in, out := &in.Uri, &out.Uri + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Scheme != nil { + in, out := &in.Scheme, &out.Scheme + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Method != nil { + in, out := &in.Method, &out.Method + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Authority != nil { + in, out := &in.Authority, &out.Authority + if *in == nil { + *out = nil + } else { + *out = new(StringMatch) + **out = **in + } + } + if in.Headers != nil { + in, out := &in.Headers, &out.Headers + *out = make(map[string]StringMatch, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPMatchRequest. +func (in *HTTPMatchRequest) DeepCopy() *HTTPMatchRequest { + if in == nil { + return nil + } + out := new(HTTPMatchRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRedirect) DeepCopyInto(out *HTTPRedirect) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRedirect. +func (in *HTTPRedirect) DeepCopy() *HTTPRedirect { + if in == nil { + return nil + } + out := new(HTTPRedirect) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRetry) DeepCopyInto(out *HTTPRetry) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRetry. +func (in *HTTPRetry) DeepCopy() *HTTPRetry { + if in == nil { + return nil + } + out := new(HTTPRetry) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRewrite) DeepCopyInto(out *HTTPRewrite) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRewrite. +func (in *HTTPRewrite) DeepCopy() *HTTPRewrite { + if in == nil { + return nil + } + out := new(HTTPRewrite) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRoute) DeepCopyInto(out *HTTPRoute) { + *out = *in + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = make([]HTTPMatchRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Route != nil { + in, out := &in.Route, &out.Route + *out = make([]DestinationWeight, len(*in)) + copy(*out, *in) + } + if in.Redirect != nil { + in, out := &in.Redirect, &out.Redirect + if *in == nil { + *out = nil + } else { + *out = new(HTTPRedirect) + **out = **in + } + } + if in.Rewrite != nil { + in, out := &in.Rewrite, &out.Rewrite + if *in == nil { + *out = nil + } else { + *out = new(HTTPRewrite) + **out = **in + } + } + if in.Retries != nil { + in, out := &in.Retries, &out.Retries + if *in == nil { + *out = nil + } else { + *out = new(HTTPRetry) + **out = **in + } + } + if in.Fault != nil { + in, out := &in.Fault, &out.Fault + if *in == nil { + *out = nil + } else { + *out = new(HTTPFaultInjection) + (*in).DeepCopyInto(*out) + } + } + if in.Mirror != nil { + in, out := &in.Mirror, &out.Mirror + if *in == nil { + *out = nil + } else { + *out = new(Destination) + **out = **in + } + } + if in.AppendHeaders != nil { + in, out := &in.AppendHeaders, &out.AppendHeaders + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.RemoveResponseHeaders != nil { + in, out := &in.RemoveResponseHeaders, &out.RemoveResponseHeaders + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRoute. +func (in *HTTPRoute) DeepCopy() *HTTPRoute { + if in == nil { + return nil + } + out := new(HTTPRoute) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InjectAbort) DeepCopyInto(out *InjectAbort) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InjectAbort. +func (in *InjectAbort) DeepCopy() *InjectAbort { + if in == nil { + return nil + } + out := new(InjectAbort) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InjectDelay) DeepCopyInto(out *InjectDelay) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InjectDelay. +func (in *InjectDelay) DeepCopy() *InjectDelay { + if in == nil { + return nil + } + out := new(InjectDelay) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *L4MatchAttributes) DeepCopyInto(out *L4MatchAttributes) { + *out = *in + if in.SourceLabel != nil { + in, out := &in.SourceLabel, &out.SourceLabel + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new L4MatchAttributes. +func (in *L4MatchAttributes) DeepCopy() *L4MatchAttributes { + if in == nil { + return nil + } + out := new(L4MatchAttributes) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Port) DeepCopyInto(out *Port) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Port. +func (in *Port) DeepCopy() *Port { + if in == nil { + return nil + } + out := new(Port) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PortSelector) DeepCopyInto(out *PortSelector) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortSelector. +func (in *PortSelector) DeepCopy() *PortSelector { + if in == nil { + return nil + } + out := new(PortSelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Server) DeepCopyInto(out *Server) { + *out = *in + out.Port = in.Port + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + if *in == nil { + *out = nil + } else { + *out = new(TLSOptions) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Server. +func (in *Server) DeepCopy() *Server { + if in == nil { + return nil + } + out := new(Server) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StringMatch) DeepCopyInto(out *StringMatch) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StringMatch. +func (in *StringMatch) DeepCopy() *StringMatch { + if in == nil { + return nil + } + out := new(StringMatch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TCPRoute) DeepCopyInto(out *TCPRoute) { + *out = *in + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = make([]L4MatchAttributes, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + out.Route = in.Route + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPRoute. +func (in *TCPRoute) DeepCopy() *TCPRoute { + if in == nil { + return nil + } + out := new(TCPRoute) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TLSOptions) DeepCopyInto(out *TLSOptions) { + *out = *in + if in.SubjectAltNames != nil { + in, out := &in.SubjectAltNames, &out.SubjectAltNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TLSOptions. +func (in *TLSOptions) DeepCopy() *TLSOptions { + if in == nil { + return nil + } + out := new(TLSOptions) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualService) DeepCopyInto(out *VirtualService) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualService. +func (in *VirtualService) DeepCopy() *VirtualService { + if in == nil { + return nil + } + out := new(VirtualService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualService) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualServiceList) DeepCopyInto(out *VirtualServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]VirtualService, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualServiceList. +func (in *VirtualServiceList) DeepCopy() *VirtualServiceList { + if in == nil { + return nil + } + out := new(VirtualServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *VirtualServiceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualServiceSpec) DeepCopyInto(out *VirtualServiceSpec) { + *out = *in + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Gateways != nil { + in, out := &in.Gateways, &out.Gateways + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Http != nil { + in, out := &in.Http, &out.Http + *out = make([]HTTPRoute, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Tcp != nil { + in, out := &in.Tcp, &out.Tcp + *out = make([]TCPRoute, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualServiceSpec. +func (in *VirtualServiceSpec) DeepCopy() *VirtualServiceSpec { + if in == nil { + return nil + } + out := new(VirtualServiceSpec) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 5bf30f4e848..a0c79475406 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -22,7 +22,7 @@ import ( glog "github.com/golang/glog" channelsv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/channels/v1alpha1" feedsv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/feeds/v1alpha1" - configv1alpha2 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha2" + networkingv1alpha3 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha3" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -36,18 +36,18 @@ type Interface interface { FeedsV1alpha1() feedsv1alpha1.FeedsV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Feeds() feedsv1alpha1.FeedsV1alpha1Interface - ConfigV1alpha2() configv1alpha2.ConfigV1alpha2Interface + NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface // Deprecated: please explicitly pick a version if possible. - Config() configv1alpha2.ConfigV1alpha2Interface + Networking() networkingv1alpha3.NetworkingV1alpha3Interface } // Clientset contains the clients for groups. Each group has exactly one // version included in a Clientset. type Clientset struct { *discovery.DiscoveryClient - channelsV1alpha1 *channelsv1alpha1.ChannelsV1alpha1Client - feedsV1alpha1 *feedsv1alpha1.FeedsV1alpha1Client - configV1alpha2 *configv1alpha2.ConfigV1alpha2Client + channelsV1alpha1 *channelsv1alpha1.ChannelsV1alpha1Client + feedsV1alpha1 *feedsv1alpha1.FeedsV1alpha1Client + networkingV1alpha3 *networkingv1alpha3.NetworkingV1alpha3Client } // ChannelsV1alpha1 retrieves the ChannelsV1alpha1Client @@ -72,15 +72,15 @@ func (c *Clientset) Feeds() feedsv1alpha1.FeedsV1alpha1Interface { return c.feedsV1alpha1 } -// ConfigV1alpha2 retrieves the ConfigV1alpha2Client -func (c *Clientset) ConfigV1alpha2() configv1alpha2.ConfigV1alpha2Interface { - return c.configV1alpha2 +// NetworkingV1alpha3 retrieves the NetworkingV1alpha3Client +func (c *Clientset) NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface { + return c.networkingV1alpha3 } -// Deprecated: Config retrieves the default version of ConfigClient. +// Deprecated: Networking retrieves the default version of NetworkingClient. // Please explicitly pick a version. -func (c *Clientset) Config() configv1alpha2.ConfigV1alpha2Interface { - return c.configV1alpha2 +func (c *Clientset) Networking() networkingv1alpha3.NetworkingV1alpha3Interface { + return c.networkingV1alpha3 } // Discovery retrieves the DiscoveryClient @@ -107,7 +107,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } - cs.configV1alpha2, err = configv1alpha2.NewForConfig(&configShallowCopy) + cs.networkingV1alpha3, err = networkingv1alpha3.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -126,7 +126,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.channelsV1alpha1 = channelsv1alpha1.NewForConfigOrDie(c) cs.feedsV1alpha1 = feedsv1alpha1.NewForConfigOrDie(c) - cs.configV1alpha2 = configv1alpha2.NewForConfigOrDie(c) + cs.networkingV1alpha3 = networkingv1alpha3.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -137,7 +137,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.channelsV1alpha1 = channelsv1alpha1.New(c) cs.feedsV1alpha1 = feedsv1alpha1.New(c) - cs.configV1alpha2 = configv1alpha2.New(c) + cs.networkingV1alpha3 = networkingv1alpha3.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 9fb3afde711..6063fb22691 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -24,8 +24,8 @@ import ( fakechannelsv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/channels/v1alpha1/fake" feedsv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/feeds/v1alpha1" fakefeedsv1alpha1 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/feeds/v1alpha1/fake" - configv1alpha2 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha2" - fakeconfigv1alpha2 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake" + networkingv1alpha3 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha3" + fakenetworkingv1alpha3 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -94,12 +94,12 @@ func (c *Clientset) Feeds() feedsv1alpha1.FeedsV1alpha1Interface { return &fakefeedsv1alpha1.FakeFeedsV1alpha1{Fake: &c.Fake} } -// ConfigV1alpha2 retrieves the ConfigV1alpha2Client -func (c *Clientset) ConfigV1alpha2() configv1alpha2.ConfigV1alpha2Interface { - return &fakeconfigv1alpha2.FakeConfigV1alpha2{Fake: &c.Fake} +// NetworkingV1alpha3 retrieves the NetworkingV1alpha3Client +func (c *Clientset) NetworkingV1alpha3() networkingv1alpha3.NetworkingV1alpha3Interface { + return &fakenetworkingv1alpha3.FakeNetworkingV1alpha3{Fake: &c.Fake} } -// Config retrieves the ConfigV1alpha2Client -func (c *Clientset) Config() configv1alpha2.ConfigV1alpha2Interface { - return &fakeconfigv1alpha2.FakeConfigV1alpha2{Fake: &c.Fake} +// Networking retrieves the NetworkingV1alpha3Client +func (c *Clientset) Networking() networkingv1alpha3.NetworkingV1alpha3Interface { + return &fakenetworkingv1alpha3.FakeNetworkingV1alpha3{Fake: &c.Fake} } diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 65b8ac72114..0119be1fa56 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -21,7 +21,7 @@ package fake import ( channelsv1alpha1 "github.com/knative/eventing/pkg/apis/channels/v1alpha1" feedsv1alpha1 "github.com/knative/eventing/pkg/apis/feeds/v1alpha1" - configv1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" + networkingv1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -54,5 +54,5 @@ func init() { func AddToScheme(scheme *runtime.Scheme) { channelsv1alpha1.AddToScheme(scheme) feedsv1alpha1.AddToScheme(scheme) - configv1alpha2.AddToScheme(scheme) + networkingv1alpha3.AddToScheme(scheme) } diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index b3a31a8cfc2..b2217c61d37 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -21,7 +21,7 @@ package scheme import ( channelsv1alpha1 "github.com/knative/eventing/pkg/apis/channels/v1alpha1" feedsv1alpha1 "github.com/knative/eventing/pkg/apis/feeds/v1alpha1" - configv1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" + networkingv1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -54,5 +54,5 @@ func init() { func AddToScheme(scheme *runtime.Scheme) { channelsv1alpha1.AddToScheme(scheme) feedsv1alpha1.AddToScheme(scheme) - configv1alpha2.AddToScheme(scheme) + networkingv1alpha3.AddToScheme(scheme) } diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/fake_routerule.go b/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/fake_routerule.go deleted file mode 100644 index 2d3e2179751..00000000000 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/fake_routerule.go +++ /dev/null @@ -1,128 +0,0 @@ -/* -Copyright 2018 Google, Inc. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeRouteRules implements RouteRuleInterface -type FakeRouteRules struct { - Fake *FakeConfigV1alpha2 - ns string -} - -var routerulesResource = schema.GroupVersionResource{Group: "config.istio.io", Version: "v1alpha2", Resource: "routerules"} - -var routerulesKind = schema.GroupVersionKind{Group: "config.istio.io", Version: "v1alpha2", Kind: "RouteRule"} - -// Get takes name of the routeRule, and returns the corresponding routeRule object, and an error if there is any. -func (c *FakeRouteRules) Get(name string, options v1.GetOptions) (result *v1alpha2.RouteRule, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(routerulesResource, c.ns, name), &v1alpha2.RouteRule{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.RouteRule), err -} - -// List takes label and field selectors, and returns the list of RouteRules that match those selectors. -func (c *FakeRouteRules) List(opts v1.ListOptions) (result *v1alpha2.RouteRuleList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(routerulesResource, routerulesKind, c.ns, opts), &v1alpha2.RouteRuleList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha2.RouteRuleList{} - for _, item := range obj.(*v1alpha2.RouteRuleList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested routeRules. -func (c *FakeRouteRules) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(routerulesResource, c.ns, opts)) - -} - -// Create takes the representation of a routeRule and creates it. Returns the server's representation of the routeRule, and an error, if there is any. -func (c *FakeRouteRules) Create(routeRule *v1alpha2.RouteRule) (result *v1alpha2.RouteRule, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(routerulesResource, c.ns, routeRule), &v1alpha2.RouteRule{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.RouteRule), err -} - -// Update takes the representation of a routeRule and updates it. Returns the server's representation of the routeRule, and an error, if there is any. -func (c *FakeRouteRules) Update(routeRule *v1alpha2.RouteRule) (result *v1alpha2.RouteRule, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(routerulesResource, c.ns, routeRule), &v1alpha2.RouteRule{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.RouteRule), err -} - -// Delete takes name of the routeRule and deletes it. Returns an error if one occurs. -func (c *FakeRouteRules) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(routerulesResource, c.ns, name), &v1alpha2.RouteRule{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeRouteRules) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(routerulesResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v1alpha2.RouteRuleList{}) - return err -} - -// Patch applies the patch and returns the patched routeRule. -func (c *FakeRouteRules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.RouteRule, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(routerulesResource, c.ns, name, data, subresources...), &v1alpha2.RouteRule{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha2.RouteRule), err -} diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/routerule.go b/pkg/client/clientset/versioned/typed/istio/v1alpha2/routerule.go deleted file mode 100644 index d6fbcc0da2e..00000000000 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha2/routerule.go +++ /dev/null @@ -1,157 +0,0 @@ -/* -Copyright 2018 Google, Inc. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - v1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" - scheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// RouteRulesGetter has a method to return a RouteRuleInterface. -// A group's client should implement this interface. -type RouteRulesGetter interface { - RouteRules(namespace string) RouteRuleInterface -} - -// RouteRuleInterface has methods to work with RouteRule resources. -type RouteRuleInterface interface { - Create(*v1alpha2.RouteRule) (*v1alpha2.RouteRule, error) - Update(*v1alpha2.RouteRule) (*v1alpha2.RouteRule, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v1alpha2.RouteRule, error) - List(opts v1.ListOptions) (*v1alpha2.RouteRuleList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.RouteRule, err error) - RouteRuleExpansion -} - -// routeRules implements RouteRuleInterface -type routeRules struct { - client rest.Interface - ns string -} - -// newRouteRules returns a RouteRules -func newRouteRules(c *ConfigV1alpha2Client, namespace string) *routeRules { - return &routeRules{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the routeRule, and returns the corresponding routeRule object, and an error if there is any. -func (c *routeRules) Get(name string, options v1.GetOptions) (result *v1alpha2.RouteRule, err error) { - result = &v1alpha2.RouteRule{} - err = c.client.Get(). - Namespace(c.ns). - Resource("routerules"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of RouteRules that match those selectors. -func (c *routeRules) List(opts v1.ListOptions) (result *v1alpha2.RouteRuleList, err error) { - result = &v1alpha2.RouteRuleList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("routerules"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested routeRules. -func (c *routeRules) Watch(opts v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("routerules"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch() -} - -// Create takes the representation of a routeRule and creates it. Returns the server's representation of the routeRule, and an error, if there is any. -func (c *routeRules) Create(routeRule *v1alpha2.RouteRule) (result *v1alpha2.RouteRule, err error) { - result = &v1alpha2.RouteRule{} - err = c.client.Post(). - Namespace(c.ns). - Resource("routerules"). - Body(routeRule). - Do(). - Into(result) - return -} - -// Update takes the representation of a routeRule and updates it. Returns the server's representation of the routeRule, and an error, if there is any. -func (c *routeRules) Update(routeRule *v1alpha2.RouteRule) (result *v1alpha2.RouteRule, err error) { - result = &v1alpha2.RouteRule{} - err = c.client.Put(). - Namespace(c.ns). - Resource("routerules"). - Name(routeRule.Name). - Body(routeRule). - Do(). - Into(result) - return -} - -// Delete takes name of the routeRule and deletes it. Returns an error if one occurs. -func (c *routeRules) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("routerules"). - Name(name). - Body(options). - Do(). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *routeRules) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("routerules"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(). - Error() -} - -// Patch applies the patch and returns the patched routeRule. -func (c *routeRules) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.RouteRule, err error) { - result = &v1alpha2.RouteRule{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("routerules"). - SubResource(subresources...). - Name(name). - Body(data). - Do(). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/doc.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/doc.go similarity index 97% rename from pkg/client/clientset/versioned/typed/istio/v1alpha2/doc.go rename to pkg/client/clientset/versioned/typed/istio/v1alpha3/doc.go index e38ac2cb44e..727f5c05683 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha2/doc.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1alpha2 +package v1alpha3 diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/doc.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/doc.go rename to pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/doc.go diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_gateway.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_gateway.go new file mode 100644 index 00000000000..a42634d98a0 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_gateway.go @@ -0,0 +1,128 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeGateways implements GatewayInterface +type FakeGateways struct { + Fake *FakeNetworkingV1alpha3 + ns string +} + +var gatewaysResource = schema.GroupVersionResource{Group: "networking.istio.io", Version: "v1alpha3", Resource: "gateways"} + +var gatewaysKind = schema.GroupVersionKind{Group: "networking.istio.io", Version: "v1alpha3", Kind: "Gateway"} + +// Get takes name of the gateway, and returns the corresponding gateway object, and an error if there is any. +func (c *FakeGateways) Get(name string, options v1.GetOptions) (result *v1alpha3.Gateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(gatewaysResource, c.ns, name), &v1alpha3.Gateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.Gateway), err +} + +// List takes label and field selectors, and returns the list of Gateways that match those selectors. +func (c *FakeGateways) List(opts v1.ListOptions) (result *v1alpha3.GatewayList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(gatewaysResource, gatewaysKind, c.ns, opts), &v1alpha3.GatewayList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.GatewayList{} + for _, item := range obj.(*v1alpha3.GatewayList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested gateways. +func (c *FakeGateways) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(gatewaysResource, c.ns, opts)) + +} + +// Create takes the representation of a gateway and creates it. Returns the server's representation of the gateway, and an error, if there is any. +func (c *FakeGateways) Create(gateway *v1alpha3.Gateway) (result *v1alpha3.Gateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(gatewaysResource, c.ns, gateway), &v1alpha3.Gateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.Gateway), err +} + +// Update takes the representation of a gateway and updates it. Returns the server's representation of the gateway, and an error, if there is any. +func (c *FakeGateways) Update(gateway *v1alpha3.Gateway) (result *v1alpha3.Gateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(gatewaysResource, c.ns, gateway), &v1alpha3.Gateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.Gateway), err +} + +// Delete takes name of the gateway and deletes it. Returns an error if one occurs. +func (c *FakeGateways) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(gatewaysResource, c.ns, name), &v1alpha3.Gateway{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeGateways) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(gatewaysResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha3.GatewayList{}) + return err +} + +// Patch applies the patch and returns the patched gateway. +func (c *FakeGateways) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.Gateway, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(gatewaysResource, c.ns, name, data, subresources...), &v1alpha3.Gateway{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.Gateway), err +} diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/fake_istio_client.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_istio_client.go similarity index 65% rename from pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/fake_istio_client.go rename to pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_istio_client.go index e6d53ea0f87..1bff47a1a15 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha2/fake/fake_istio_client.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_istio_client.go @@ -19,22 +19,26 @@ limitations under the License. package fake import ( - v1alpha2 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha2" + v1alpha3 "github.com/knative/eventing/pkg/client/clientset/versioned/typed/istio/v1alpha3" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) -type FakeConfigV1alpha2 struct { +type FakeNetworkingV1alpha3 struct { *testing.Fake } -func (c *FakeConfigV1alpha2) RouteRules(namespace string) v1alpha2.RouteRuleInterface { - return &FakeRouteRules{c, namespace} +func (c *FakeNetworkingV1alpha3) Gateways(namespace string) v1alpha3.GatewayInterface { + return &FakeGateways{c, namespace} +} + +func (c *FakeNetworkingV1alpha3) VirtualServices(namespace string) v1alpha3.VirtualServiceInterface { + return &FakeVirtualServices{c, namespace} } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FakeConfigV1alpha2) RESTClient() rest.Interface { +func (c *FakeNetworkingV1alpha3) RESTClient() rest.Interface { var ret *rest.RESTClient return ret } diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go new file mode 100644 index 00000000000..dd0130bbcdf --- /dev/null +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/fake/fake_virtualservice.go @@ -0,0 +1,128 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeVirtualServices implements VirtualServiceInterface +type FakeVirtualServices struct { + Fake *FakeNetworkingV1alpha3 + ns string +} + +var virtualservicesResource = schema.GroupVersionResource{Group: "networking.istio.io", Version: "v1alpha3", Resource: "virtualservices"} + +var virtualservicesKind = schema.GroupVersionKind{Group: "networking.istio.io", Version: "v1alpha3", Kind: "VirtualService"} + +// Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. +func (c *FakeVirtualServices) Get(name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(virtualservicesResource, c.ns, name), &v1alpha3.VirtualService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.VirtualService), err +} + +// List takes label and field selectors, and returns the list of VirtualServices that match those selectors. +func (c *FakeVirtualServices) List(opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(virtualservicesResource, virtualservicesKind, c.ns, opts), &v1alpha3.VirtualServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha3.VirtualServiceList{} + for _, item := range obj.(*v1alpha3.VirtualServiceList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested virtualServices. +func (c *FakeVirtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(virtualservicesResource, c.ns, opts)) + +} + +// Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. +func (c *FakeVirtualServices) Create(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(virtualservicesResource, c.ns, virtualService), &v1alpha3.VirtualService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.VirtualService), err +} + +// Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. +func (c *FakeVirtualServices) Update(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(virtualservicesResource, c.ns, virtualService), &v1alpha3.VirtualService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.VirtualService), err +} + +// Delete takes name of the virtualService and deletes it. Returns an error if one occurs. +func (c *FakeVirtualServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(virtualservicesResource, c.ns, name), &v1alpha3.VirtualService{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeVirtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha3.VirtualServiceList{}) + return err +} + +// Patch applies the patch and returns the patched virtualService. +func (c *FakeVirtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(virtualservicesResource, c.ns, name, data, subresources...), &v1alpha3.VirtualService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha3.VirtualService), err +} diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/gateway.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/gateway.go new file mode 100644 index 00000000000..a1bbe00c60b --- /dev/null +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/gateway.go @@ -0,0 +1,157 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + scheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// GatewaysGetter has a method to return a GatewayInterface. +// A group's client should implement this interface. +type GatewaysGetter interface { + Gateways(namespace string) GatewayInterface +} + +// GatewayInterface has methods to work with Gateway resources. +type GatewayInterface interface { + Create(*v1alpha3.Gateway) (*v1alpha3.Gateway, error) + Update(*v1alpha3.Gateway) (*v1alpha3.Gateway, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha3.Gateway, error) + List(opts v1.ListOptions) (*v1alpha3.GatewayList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.Gateway, err error) + GatewayExpansion +} + +// gateways implements GatewayInterface +type gateways struct { + client rest.Interface + ns string +} + +// newGateways returns a Gateways +func newGateways(c *NetworkingV1alpha3Client, namespace string) *gateways { + return &gateways{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the gateway, and returns the corresponding gateway object, and an error if there is any. +func (c *gateways) Get(name string, options v1.GetOptions) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Get(). + Namespace(c.ns). + Resource("gateways"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Gateways that match those selectors. +func (c *gateways) List(opts v1.ListOptions) (result *v1alpha3.GatewayList, err error) { + result = &v1alpha3.GatewayList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested gateways. +func (c *gateways) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a gateway and creates it. Returns the server's representation of the gateway, and an error, if there is any. +func (c *gateways) Create(gateway *v1alpha3.Gateway) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Post(). + Namespace(c.ns). + Resource("gateways"). + Body(gateway). + Do(). + Into(result) + return +} + +// Update takes the representation of a gateway and updates it. Returns the server's representation of the gateway, and an error, if there is any. +func (c *gateways) Update(gateway *v1alpha3.Gateway) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Put(). + Namespace(c.ns). + Resource("gateways"). + Name(gateway.Name). + Body(gateway). + Do(). + Into(result) + return +} + +// Delete takes name of the gateway and deletes it. Returns an error if one occurs. +func (c *gateways) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("gateways"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *gateways) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("gateways"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched gateway. +func (c *gateways) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.Gateway, err error) { + result = &v1alpha3.Gateway{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("gateways"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/generated_expansion.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/generated_expansion.go similarity index 87% rename from pkg/client/clientset/versioned/typed/istio/v1alpha2/generated_expansion.go rename to pkg/client/clientset/versioned/typed/istio/v1alpha3/generated_expansion.go index 28db7e76e70..63fe55562a0 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha2/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/generated_expansion.go @@ -16,6 +16,8 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha2 +package v1alpha3 -type RouteRuleExpansion interface{} +type GatewayExpansion interface{} + +type VirtualServiceExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha2/istio_client.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/istio_client.go similarity index 58% rename from pkg/client/clientset/versioned/typed/istio/v1alpha2/istio_client.go rename to pkg/client/clientset/versioned/typed/istio/v1alpha3/istio_client.go index a0e84b27121..7e1b6b03ed9 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1alpha2/istio_client.go +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/istio_client.go @@ -16,31 +16,36 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1alpha2 +package v1alpha3 import ( - v1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" serializer "k8s.io/apimachinery/pkg/runtime/serializer" rest "k8s.io/client-go/rest" ) -type ConfigV1alpha2Interface interface { +type NetworkingV1alpha3Interface interface { RESTClient() rest.Interface - RouteRulesGetter + GatewaysGetter + VirtualServicesGetter } -// ConfigV1alpha2Client is used to interact with features provided by the config.istio.io group. -type ConfigV1alpha2Client struct { +// NetworkingV1alpha3Client is used to interact with features provided by the networking.istio.io group. +type NetworkingV1alpha3Client struct { restClient rest.Interface } -func (c *ConfigV1alpha2Client) RouteRules(namespace string) RouteRuleInterface { - return newRouteRules(c, namespace) +func (c *NetworkingV1alpha3Client) Gateways(namespace string) GatewayInterface { + return newGateways(c, namespace) } -// NewForConfig creates a new ConfigV1alpha2Client for the given config. -func NewForConfig(c *rest.Config) (*ConfigV1alpha2Client, error) { +func (c *NetworkingV1alpha3Client) VirtualServices(namespace string) VirtualServiceInterface { + return newVirtualServices(c, namespace) +} + +// NewForConfig creates a new NetworkingV1alpha3Client for the given config. +func NewForConfig(c *rest.Config) (*NetworkingV1alpha3Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -49,12 +54,12 @@ func NewForConfig(c *rest.Config) (*ConfigV1alpha2Client, error) { if err != nil { return nil, err } - return &ConfigV1alpha2Client{client}, nil + return &NetworkingV1alpha3Client{client}, nil } -// NewForConfigOrDie creates a new ConfigV1alpha2Client for the given config and +// NewForConfigOrDie creates a new NetworkingV1alpha3Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *ConfigV1alpha2Client { +func NewForConfigOrDie(c *rest.Config) *NetworkingV1alpha3Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -62,13 +67,13 @@ func NewForConfigOrDie(c *rest.Config) *ConfigV1alpha2Client { return client } -// New creates a new ConfigV1alpha2Client for the given RESTClient. -func New(c rest.Interface) *ConfigV1alpha2Client { - return &ConfigV1alpha2Client{c} +// New creates a new NetworkingV1alpha3Client for the given RESTClient. +func New(c rest.Interface) *NetworkingV1alpha3Client { + return &NetworkingV1alpha3Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1alpha2.SchemeGroupVersion + gv := v1alpha3.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} @@ -82,7 +87,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *ConfigV1alpha2Client) RESTClient() rest.Interface { +func (c *NetworkingV1alpha3Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go b/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go new file mode 100644 index 00000000000..1cd0fedb676 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/istio/v1alpha3/virtualservice.go @@ -0,0 +1,157 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + scheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// VirtualServicesGetter has a method to return a VirtualServiceInterface. +// A group's client should implement this interface. +type VirtualServicesGetter interface { + VirtualServices(namespace string) VirtualServiceInterface +} + +// VirtualServiceInterface has methods to work with VirtualService resources. +type VirtualServiceInterface interface { + Create(*v1alpha3.VirtualService) (*v1alpha3.VirtualService, error) + Update(*v1alpha3.VirtualService) (*v1alpha3.VirtualService, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha3.VirtualService, error) + List(opts v1.ListOptions) (*v1alpha3.VirtualServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) + VirtualServiceExpansion +} + +// virtualServices implements VirtualServiceInterface +type virtualServices struct { + client rest.Interface + ns string +} + +// newVirtualServices returns a VirtualServices +func newVirtualServices(c *NetworkingV1alpha3Client, namespace string) *virtualServices { + return &virtualServices{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. +func (c *virtualServices) Get(name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Get(). + Namespace(c.ns). + Resource("virtualservices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VirtualServices that match those selectors. +func (c *virtualServices) List(opts v1.ListOptions) (result *v1alpha3.VirtualServiceList, err error) { + result = &v1alpha3.VirtualServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("virtualservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested virtualServices. +func (c *virtualServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("virtualservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Watch() +} + +// Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. +func (c *virtualServices) Create(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Post(). + Namespace(c.ns). + Resource("virtualservices"). + Body(virtualService). + Do(). + Into(result) + return +} + +// Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. +func (c *virtualServices) Update(virtualService *v1alpha3.VirtualService) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("virtualservices"). + Name(virtualService.Name). + Body(virtualService). + Do(). + Into(result) + return +} + +// Delete takes name of the virtualService and deletes it. Returns an error if one occurs. +func (c *virtualServices) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("virtualservices"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *virtualServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("virtualservices"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched virtualService. +func (c *virtualServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha3.VirtualService, err error) { + result = &v1alpha3.VirtualService{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("virtualservices"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index ead8d02e798..ae5e614883d 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -127,7 +127,7 @@ type SharedInformerFactory interface { Channels() channels.Interface Feeds() feeds.Interface - Config() istio.Interface + Networking() istio.Interface } func (f *sharedInformerFactory) Channels() channels.Interface { @@ -138,6 +138,6 @@ func (f *sharedInformerFactory) Feeds() feeds.Interface { return feeds.New(f, f.namespace, f.tweakListOptions) } -func (f *sharedInformerFactory) Config() istio.Interface { +func (f *sharedInformerFactory) Networking() istio.Interface { return istio.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 5a7cbb84ed2..5e0742cbf58 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -23,7 +23,7 @@ import ( v1alpha1 "github.com/knative/eventing/pkg/apis/channels/v1alpha1" feeds_v1alpha1 "github.com/knative/eventing/pkg/apis/feeds/v1alpha1" - v1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -62,10 +62,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("subscriptions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Channels().V1alpha1().Subscriptions().Informer()}, nil - // Group=config.istio.io, Version=v1alpha2 - case v1alpha2.SchemeGroupVersion.WithResource("routerules"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Config().V1alpha2().RouteRules().Informer()}, nil - // Group=feeds.knative.dev, Version=v1alpha1 case feeds_v1alpha1.SchemeGroupVersion.WithResource("binds"): return &genericInformer{resource: resource.GroupResource(), informer: f.Feeds().V1alpha1().Binds().Informer()}, nil @@ -74,6 +70,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case feeds_v1alpha1.SchemeGroupVersion.WithResource("eventtypes"): return &genericInformer{resource: resource.GroupResource(), informer: f.Feeds().V1alpha1().EventTypes().Informer()}, nil + // Group=networking.istio.io, Version=v1alpha3 + case v1alpha3.SchemeGroupVersion.WithResource("gateways"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha3().Gateways().Informer()}, nil + case v1alpha3.SchemeGroupVersion.WithResource("virtualservices"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha3().VirtualServices().Informer()}, nil + } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/informers/externalversions/istio/interface.go b/pkg/client/informers/externalversions/istio/interface.go index b781c35e8a6..094e89c5ee0 100644 --- a/pkg/client/informers/externalversions/istio/interface.go +++ b/pkg/client/informers/externalversions/istio/interface.go @@ -16,17 +16,17 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package config +package networking import ( internalinterfaces "github.com/knative/eventing/pkg/client/informers/externalversions/internalinterfaces" - v1alpha2 "github.com/knative/eventing/pkg/client/informers/externalversions/istio/v1alpha2" + v1alpha3 "github.com/knative/eventing/pkg/client/informers/externalversions/istio/v1alpha3" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1alpha2 provides access to shared informers for resources in V1alpha2. - V1alpha2() v1alpha2.Interface + // V1alpha3 provides access to shared informers for resources in V1alpha3. + V1alpha3() v1alpha3.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1alpha2 returns a new v1alpha2.Interface. -func (g *group) V1alpha2() v1alpha2.Interface { - return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) +// V1alpha3 returns a new v1alpha3.Interface. +func (g *group) V1alpha3() v1alpha3.Interface { + return v1alpha3.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/istio/v1alpha2/routerule.go b/pkg/client/informers/externalversions/istio/v1alpha3/gateway.go similarity index 54% rename from pkg/client/informers/externalversions/istio/v1alpha2/routerule.go rename to pkg/client/informers/externalversions/istio/v1alpha3/gateway.go index 3c76a1930c3..edb5c4c40af 100644 --- a/pkg/client/informers/externalversions/istio/v1alpha2/routerule.go +++ b/pkg/client/informers/externalversions/istio/v1alpha3/gateway.go @@ -16,74 +16,74 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha2 +package v1alpha3 import ( time "time" - istio_v1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" + istio_v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" versioned "github.com/knative/eventing/pkg/client/clientset/versioned" internalinterfaces "github.com/knative/eventing/pkg/client/informers/externalversions/internalinterfaces" - v1alpha2 "github.com/knative/eventing/pkg/client/listers/istio/v1alpha2" + v1alpha3 "github.com/knative/eventing/pkg/client/listers/istio/v1alpha3" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" ) -// RouteRuleInformer provides access to a shared informer and lister for -// RouteRules. -type RouteRuleInformer interface { +// GatewayInformer provides access to a shared informer and lister for +// Gateways. +type GatewayInformer interface { Informer() cache.SharedIndexInformer - Lister() v1alpha2.RouteRuleLister + Lister() v1alpha3.GatewayLister } -type routeRuleInformer struct { +type gatewayInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } -// NewRouteRuleInformer constructs a new informer for RouteRule type. +// NewGatewayInformer constructs a new informer for Gateway type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewRouteRuleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredRouteRuleInformer(client, namespace, resyncPeriod, indexers, nil) +func NewGatewayInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredGatewayInformer(client, namespace, resyncPeriod, indexers, nil) } -// NewFilteredRouteRuleInformer constructs a new informer for RouteRule type. +// NewFilteredGatewayInformer constructs a new informer for Gateway type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredRouteRuleInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredGatewayInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ConfigV1alpha2().RouteRules(namespace).List(options) + return client.NetworkingV1alpha3().Gateways(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.ConfigV1alpha2().RouteRules(namespace).Watch(options) + return client.NetworkingV1alpha3().Gateways(namespace).Watch(options) }, }, - &istio_v1alpha2.RouteRule{}, + &istio_v1alpha3.Gateway{}, resyncPeriod, indexers, ) } -func (f *routeRuleInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredRouteRuleInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +func (f *gatewayInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredGatewayInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } -func (f *routeRuleInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&istio_v1alpha2.RouteRule{}, f.defaultInformer) +func (f *gatewayInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&istio_v1alpha3.Gateway{}, f.defaultInformer) } -func (f *routeRuleInformer) Lister() v1alpha2.RouteRuleLister { - return v1alpha2.NewRouteRuleLister(f.Informer().GetIndexer()) +func (f *gatewayInformer) Lister() v1alpha3.GatewayLister { + return v1alpha3.NewGatewayLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/istio/v1alpha2/interface.go b/pkg/client/informers/externalversions/istio/v1alpha3/interface.go similarity index 67% rename from pkg/client/informers/externalversions/istio/v1alpha2/interface.go rename to pkg/client/informers/externalversions/istio/v1alpha3/interface.go index c9df313ae30..68745b2dbb4 100644 --- a/pkg/client/informers/externalversions/istio/v1alpha2/interface.go +++ b/pkg/client/informers/externalversions/istio/v1alpha3/interface.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1alpha2 +package v1alpha3 import ( internalinterfaces "github.com/knative/eventing/pkg/client/informers/externalversions/internalinterfaces" @@ -24,8 +24,10 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // RouteRules returns a RouteRuleInformer. - RouteRules() RouteRuleInformer + // Gateways returns a GatewayInformer. + Gateways() GatewayInformer + // VirtualServices returns a VirtualServiceInformer. + VirtualServices() VirtualServiceInformer } type version struct { @@ -39,7 +41,12 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// RouteRules returns a RouteRuleInformer. -func (v *version) RouteRules() RouteRuleInformer { - return &routeRuleInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +// Gateways returns a GatewayInformer. +func (v *version) Gateways() GatewayInformer { + return &gatewayInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// VirtualServices returns a VirtualServiceInformer. +func (v *version) VirtualServices() VirtualServiceInformer { + return &virtualServiceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } diff --git a/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go b/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go new file mode 100644 index 00000000000..be8fd9634d1 --- /dev/null +++ b/pkg/client/informers/externalversions/istio/v1alpha3/virtualservice.go @@ -0,0 +1,89 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + time "time" + + istio_v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + versioned "github.com/knative/eventing/pkg/client/clientset/versioned" + internalinterfaces "github.com/knative/eventing/pkg/client/informers/externalversions/internalinterfaces" + v1alpha3 "github.com/knative/eventing/pkg/client/listers/istio/v1alpha3" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// VirtualServiceInformer provides access to a shared informer and lister for +// VirtualServices. +type VirtualServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha3.VirtualServiceLister +} + +type virtualServiceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewVirtualServiceInformer constructs a new informer for VirtualService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewVirtualServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredVirtualServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredVirtualServiceInformer constructs a new informer for VirtualService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredVirtualServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha3().VirtualServices(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha3().VirtualServices(namespace).Watch(options) + }, + }, + &istio_v1alpha3.VirtualService{}, + resyncPeriod, + indexers, + ) +} + +func (f *virtualServiceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredVirtualServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *virtualServiceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&istio_v1alpha3.VirtualService{}, f.defaultInformer) +} + +func (f *virtualServiceInformer) Lister() v1alpha3.VirtualServiceLister { + return v1alpha3.NewVirtualServiceLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/istio/v1alpha2/routerule.go b/pkg/client/listers/istio/v1alpha2/routerule.go deleted file mode 100644 index f146e158be7..00000000000 --- a/pkg/client/listers/istio/v1alpha2/routerule.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright 2018 Google, Inc. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - v1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// RouteRuleLister helps list RouteRules. -type RouteRuleLister interface { - // List lists all RouteRules in the indexer. - List(selector labels.Selector) (ret []*v1alpha2.RouteRule, err error) - // RouteRules returns an object that can list and get RouteRules. - RouteRules(namespace string) RouteRuleNamespaceLister - RouteRuleListerExpansion -} - -// routeRuleLister implements the RouteRuleLister interface. -type routeRuleLister struct { - indexer cache.Indexer -} - -// NewRouteRuleLister returns a new RouteRuleLister. -func NewRouteRuleLister(indexer cache.Indexer) RouteRuleLister { - return &routeRuleLister{indexer: indexer} -} - -// List lists all RouteRules in the indexer. -func (s *routeRuleLister) List(selector labels.Selector) (ret []*v1alpha2.RouteRule, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.RouteRule)) - }) - return ret, err -} - -// RouteRules returns an object that can list and get RouteRules. -func (s *routeRuleLister) RouteRules(namespace string) RouteRuleNamespaceLister { - return routeRuleNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// RouteRuleNamespaceLister helps list and get RouteRules. -type RouteRuleNamespaceLister interface { - // List lists all RouteRules in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v1alpha2.RouteRule, err error) - // Get retrieves the RouteRule from the indexer for a given namespace and name. - Get(name string) (*v1alpha2.RouteRule, error) - RouteRuleNamespaceListerExpansion -} - -// routeRuleNamespaceLister implements the RouteRuleNamespaceLister -// interface. -type routeRuleNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all RouteRules in the indexer for a given namespace. -func (s routeRuleNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.RouteRule, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.RouteRule)) - }) - return ret, err -} - -// Get retrieves the RouteRule from the indexer for a given namespace and name. -func (s routeRuleNamespaceLister) Get(name string) (*v1alpha2.RouteRule, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha2.Resource("routerule"), name) - } - return obj.(*v1alpha2.RouteRule), nil -} diff --git a/pkg/client/listers/istio/v1alpha3/expansion_generated.go b/pkg/client/listers/istio/v1alpha3/expansion_generated.go new file mode 100644 index 00000000000..a0441ca4a07 --- /dev/null +++ b/pkg/client/listers/istio/v1alpha3/expansion_generated.go @@ -0,0 +1,35 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha3 + +// GatewayListerExpansion allows custom methods to be added to +// GatewayLister. +type GatewayListerExpansion interface{} + +// GatewayNamespaceListerExpansion allows custom methods to be added to +// GatewayNamespaceLister. +type GatewayNamespaceListerExpansion interface{} + +// VirtualServiceListerExpansion allows custom methods to be added to +// VirtualServiceLister. +type VirtualServiceListerExpansion interface{} + +// VirtualServiceNamespaceListerExpansion allows custom methods to be added to +// VirtualServiceNamespaceLister. +type VirtualServiceNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/istio/v1alpha3/gateway.go b/pkg/client/listers/istio/v1alpha3/gateway.go new file mode 100644 index 00000000000..9fbb636e2cb --- /dev/null +++ b/pkg/client/listers/istio/v1alpha3/gateway.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// GatewayLister helps list Gateways. +type GatewayLister interface { + // List lists all Gateways in the indexer. + List(selector labels.Selector) (ret []*v1alpha3.Gateway, err error) + // Gateways returns an object that can list and get Gateways. + Gateways(namespace string) GatewayNamespaceLister + GatewayListerExpansion +} + +// gatewayLister implements the GatewayLister interface. +type gatewayLister struct { + indexer cache.Indexer +} + +// NewGatewayLister returns a new GatewayLister. +func NewGatewayLister(indexer cache.Indexer) GatewayLister { + return &gatewayLister{indexer: indexer} +} + +// List lists all Gateways in the indexer. +func (s *gatewayLister) List(selector labels.Selector) (ret []*v1alpha3.Gateway, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.Gateway)) + }) + return ret, err +} + +// Gateways returns an object that can list and get Gateways. +func (s *gatewayLister) Gateways(namespace string) GatewayNamespaceLister { + return gatewayNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// GatewayNamespaceLister helps list and get Gateways. +type GatewayNamespaceLister interface { + // List lists all Gateways in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha3.Gateway, err error) + // Get retrieves the Gateway from the indexer for a given namespace and name. + Get(name string) (*v1alpha3.Gateway, error) + GatewayNamespaceListerExpansion +} + +// gatewayNamespaceLister implements the GatewayNamespaceLister +// interface. +type gatewayNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Gateways in the indexer for a given namespace. +func (s gatewayNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.Gateway, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.Gateway)) + }) + return ret, err +} + +// Get retrieves the Gateway from the indexer for a given namespace and name. +func (s gatewayNamespaceLister) Get(name string) (*v1alpha3.Gateway, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("gateway"), name) + } + return obj.(*v1alpha3.Gateway), nil +} diff --git a/pkg/client/listers/istio/v1alpha3/virtualservice.go b/pkg/client/listers/istio/v1alpha3/virtualservice.go new file mode 100644 index 00000000000..7534e03ae60 --- /dev/null +++ b/pkg/client/listers/istio/v1alpha3/virtualservice.go @@ -0,0 +1,94 @@ +/* +Copyright 2018 Google, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha3 + +import ( + v1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// VirtualServiceLister helps list VirtualServices. +type VirtualServiceLister interface { + // List lists all VirtualServices in the indexer. + List(selector labels.Selector) (ret []*v1alpha3.VirtualService, err error) + // VirtualServices returns an object that can list and get VirtualServices. + VirtualServices(namespace string) VirtualServiceNamespaceLister + VirtualServiceListerExpansion +} + +// virtualServiceLister implements the VirtualServiceLister interface. +type virtualServiceLister struct { + indexer cache.Indexer +} + +// NewVirtualServiceLister returns a new VirtualServiceLister. +func NewVirtualServiceLister(indexer cache.Indexer) VirtualServiceLister { + return &virtualServiceLister{indexer: indexer} +} + +// List lists all VirtualServices in the indexer. +func (s *virtualServiceLister) List(selector labels.Selector) (ret []*v1alpha3.VirtualService, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.VirtualService)) + }) + return ret, err +} + +// VirtualServices returns an object that can list and get VirtualServices. +func (s *virtualServiceLister) VirtualServices(namespace string) VirtualServiceNamespaceLister { + return virtualServiceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// VirtualServiceNamespaceLister helps list and get VirtualServices. +type VirtualServiceNamespaceLister interface { + // List lists all VirtualServices in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha3.VirtualService, err error) + // Get retrieves the VirtualService from the indexer for a given namespace and name. + Get(name string) (*v1alpha3.VirtualService, error) + VirtualServiceNamespaceListerExpansion +} + +// virtualServiceNamespaceLister implements the VirtualServiceNamespaceLister +// interface. +type virtualServiceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all VirtualServices in the indexer for a given namespace. +func (s virtualServiceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.VirtualService, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha3.VirtualService)) + }) + return ret, err +} + +// Get retrieves the VirtualService from the indexer for a given namespace and name. +func (s virtualServiceNamespaceLister) Get(name string) (*v1alpha3.VirtualService, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha3.Resource("virtualservice"), name) + } + return obj.(*v1alpha3.VirtualService), nil +} diff --git a/pkg/controller/bus/controller.go b/pkg/controller/bus/controller.go index 823d969f1e3..acde824c29b 100644 --- a/pkg/controller/bus/controller.go +++ b/pkg/controller/bus/controller.go @@ -47,7 +47,8 @@ import ( channelscheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" informers "github.com/knative/eventing/pkg/client/informers/externalversions" listers "github.com/knative/eventing/pkg/client/listers/channels/v1alpha1" - elainformers "github.com/knative/serving/pkg/client/informers/externalversions" + + servinginformers "github.com/knative/serving/pkg/client/informers/externalversions" channelsv1alpha1 "github.com/knative/eventing/pkg/apis/channels/v1alpha1" ) @@ -104,7 +105,7 @@ func NewController( busclientset clientset.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, busInformerFactory informers.SharedInformerFactory, - routeInformerFactory elainformers.SharedInformerFactory) controller.Interface { + routeInformerFactory servinginformers.SharedInformerFactory) controller.Interface { // obtain references to shared index informers for the Bus, Deployment and Service // types. diff --git a/pkg/controller/channel/controller.go b/pkg/controller/channel/controller.go index 5156380f6af..45eb39850ee 100644 --- a/pkg/controller/channel/controller.go +++ b/pkg/controller/channel/controller.go @@ -21,14 +21,12 @@ import ( "time" "github.com/golang/glog" - istiolisters "github.com/knative/eventing/pkg/client/listers/istio/v1alpha2" + istiolisters "github.com/knative/eventing/pkg/client/listers/istio/v1alpha3" "github.com/knative/eventing/pkg/controller" corev1 "k8s.io/api/core/v1" - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" kubeinformers "k8s.io/client-go/informers" @@ -36,7 +34,6 @@ import ( "k8s.io/client-go/kubernetes/scheme" typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" corelisters "k8s.io/client-go/listers/core/v1" - extensionslisters "k8s.io/client-go/listers/extensions/v1beta1" "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" @@ -45,10 +42,10 @@ import ( channelscheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" informers "github.com/knative/eventing/pkg/client/informers/externalversions" listers "github.com/knative/eventing/pkg/client/listers/channels/v1alpha1" - elainformers "github.com/knative/serving/pkg/client/informers/externalversions" + servinginformers "github.com/knative/serving/pkg/client/informers/externalversions" channelsv1alpha1 "github.com/knative/eventing/pkg/apis/channels/v1alpha1" - istiov1alpha2 "github.com/knative/eventing/pkg/apis/istio/v1alpha2" + istiov1alpha3 "github.com/knative/eventing/pkg/apis/istio/v1alpha3" ) const controllerAgentName = "channel-controller" @@ -68,6 +65,11 @@ const ( MessageResourceSynced = "Channel synced successfully" ) +const ( + PortNumber = 80 + PortName = "http" +) + // Controller is the controller implementation for Channel resources type Controller struct { // kubeclientset is a standard kubernetes clientset @@ -75,14 +77,12 @@ type Controller struct { // channelclientset is a clientset for our own API group channelclientset clientset.Interface - ingressesLister extensionslisters.IngressLister - ingressesSynced cache.InformerSynced - routerulesLister istiolisters.RouteRuleLister - routerulesSynced cache.InformerSynced - servicesLister corelisters.ServiceLister - servicesSynced cache.InformerSynced - channelsLister listers.ChannelLister - channelsSynced cache.InformerSynced + virtualservicesLister istiolisters.VirtualServiceLister + virtualservicesSynced cache.InformerSynced + servicesLister corelisters.ServiceLister + servicesSynced cache.InformerSynced + channelsLister listers.ChannelLister + channelsSynced cache.InformerSynced // workqueue is a rate limited work queue. This is used to queue work to be // processed instead of performing it as soon as a change happens. This @@ -101,12 +101,10 @@ func NewController( channelclientset clientset.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, channelInformerFactory informers.SharedInformerFactory, - routeInformerFactory elainformers.SharedInformerFactory) controller.Interface { + routeInformerFactory servinginformers.SharedInformerFactory) controller.Interface { - // obtain references to shared index informers for the Ingress, Service and Channel - // types. - ingressInformer := kubeInformerFactory.Extensions().V1beta1().Ingresses() - routeruleInformer := channelInformerFactory.Config().V1alpha2().RouteRules() + // obtain references to shared index informers for the Service and Channel types. + virtualserviceInformer := channelInformerFactory.Networking().V1alpha3().VirtualServices() serviceInformer := kubeInformerFactory.Core().V1().Services() channelInformer := channelInformerFactory.Channels().V1alpha1().Channels() @@ -121,18 +119,16 @@ func NewController( recorder := eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: controllerAgentName}) controller := &Controller{ - kubeclientset: kubeclientset, - channelclientset: channelclientset, - ingressesLister: ingressInformer.Lister(), - ingressesSynced: ingressInformer.Informer().HasSynced, - routerulesLister: routeruleInformer.Lister(), - routerulesSynced: routeruleInformer.Informer().HasSynced, - servicesLister: serviceInformer.Lister(), - servicesSynced: serviceInformer.Informer().HasSynced, - channelsLister: channelInformer.Lister(), - channelsSynced: channelInformer.Informer().HasSynced, - workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "Channels"), - recorder: recorder, + kubeclientset: kubeclientset, + channelclientset: channelclientset, + virtualservicesLister: virtualserviceInformer.Lister(), + virtualservicesSynced: virtualserviceInformer.Informer().HasSynced, + servicesLister: serviceInformer.Lister(), + servicesSynced: serviceInformer.Informer().HasSynced, + channelsLister: channelInformer.Lister(), + channelsSynced: channelInformer.Informer().HasSynced, + workqueue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "Channels"), + recorder: recorder, } glog.Info("Setting up event handlers") @@ -180,7 +176,7 @@ func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error { // Wait for the caches to be synced before starting workers glog.Info("Waiting for informer caches to sync") - if ok := cache.WaitForCacheSync(stopCh, c.ingressesSynced, c.servicesSynced, c.channelsSynced); !ok { + if ok := cache.WaitForCacheSync(stopCh, c.servicesSynced, c.channelsSynced); !ok { return fmt.Errorf("failed to wait for caches to sync") } @@ -288,21 +284,15 @@ func (c *Controller) syncHandler(key string) error { return err } - // Sync RouteRule derived from a Channel - routeRule, err := c.syncChannelRouteRule(channel) - if err != nil { - return err - } - - // Sync Ingress derived from the Channel - ingress, err := c.syncChannelIngress(channel) + // Sync VirtualService derived from a Channel + virtualService, err := c.syncChannelVirtualService(channel) if err != nil { return err } // Finally, we update the status block of the Channel resource to reflect the // current state of the world - err = c.updateChannelStatus(channel, service, ingress, routeRule) + err = c.updateChannelStatus(channel, service, virtualService) if err != nil { return err } @@ -338,14 +328,14 @@ func (c *Controller) syncChannelService(channel *channelsv1alpha1.Channel) (*cor return service, nil } -func (c *Controller) syncChannelRouteRule(channel *channelsv1alpha1.Channel) (*istiov1alpha2.RouteRule, error) { - // Get the RouteRule with the specified Channel name - routeruleName := controller.ChannelRouteRuleName(channel.ObjectMeta.Name) - routerule, err := c.routerulesLister.RouteRules(channel.Namespace).Get(routeruleName) +func (c *Controller) syncChannelVirtualService(channel *channelsv1alpha1.Channel) (*istiov1alpha3.VirtualService, error) { + // Get the VirtualService with the specified Channel name + virtualserviceName := controller.ChannelVirtualServiceName(channel.ObjectMeta.Name) + virtualservice, err := c.virtualservicesLister.VirtualServices(channel.Namespace).Get(virtualserviceName) // If the resource doesn't exist, we'll create it if errors.IsNotFound(err) { - routerule, err = c.channelclientset.ConfigV1alpha2().RouteRules(channel.Namespace).Create(newRouteRule(channel)) + virtualservice, err = c.channelclientset.NetworkingV1alpha3().VirtualServices(channel.Namespace).Create(newVirtualService(channel)) } // If an error occurs during Get/Create, we'll requeue the item so we can @@ -357,45 +347,16 @@ func (c *Controller) syncChannelRouteRule(channel *channelsv1alpha1.Channel) (*i // If the Service is not controlled by this Channel resource, we should log // a warning to the event recorder and return - if !metav1.IsControlledBy(routerule, channel) { - msg := fmt.Sprintf(MessageResourceExists, routerule.Name) + if !metav1.IsControlledBy(virtualservice, channel) { + msg := fmt.Sprintf(MessageResourceExists, virtualservice.Name) c.recorder.Event(channel, corev1.EventTypeWarning, ErrResourceExists, msg) return nil, fmt.Errorf(msg) } - return routerule, nil + return virtualservice, nil } -func (c *Controller) syncChannelIngress(channel *channelsv1alpha1.Channel) (*extensionsv1beta1.Ingress, error) { - // TODO make ingress optional - - // Get the ingress with the specified ingress name - ingressName := controller.ChannelIngressName(channel.ObjectMeta.Name) - ingress, err := c.ingressesLister.Ingresses(channel.Namespace).Get(ingressName) - // If the resource doesn't exist, we'll create it - if errors.IsNotFound(err) { - ingress, err = c.kubeclientset.ExtensionsV1beta1().Ingresses(channel.Namespace).Create(newIngress(channel)) - } - - // If an error occurs during Get/Create, we'll requeue the item so we can - // attempt processing again later. This could have been caused by a - // temporary network failure, or any other transient reason. - if err != nil { - return nil, err - } - - // If the Ingress is not controlled by this Channel resource, we should log - // a warning to the event recorder and return - if !metav1.IsControlledBy(ingress, channel) { - msg := fmt.Sprintf(MessageResourceExists, ingress.Name) - c.recorder.Event(channel, corev1.EventTypeWarning, ErrResourceExists, msg) - return nil, fmt.Errorf(msg) - } - - return ingress, nil -} - -func (c *Controller) updateChannelStatus(channel *channelsv1alpha1.Channel, service *corev1.Service, ingress *extensionsv1beta1.Ingress, routeRule *istiov1alpha2.RouteRule) error { +func (c *Controller) updateChannelStatus(channel *channelsv1alpha1.Channel, service *corev1.Service, virtualService *istiov1alpha3.VirtualService) error { // NEVER modify objects from the store. It's a read-only, local cache. // You can use DeepCopy() to make a deep copy of original object and modify this copy // Or create a copy manually for better performance @@ -483,23 +444,23 @@ func newService(channel *channelsv1alpha1.Channel) *corev1.Service { }, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ - {Name: "http", Port: 80}, + {Name: PortName, Port: PortNumber}, }, }, } } -// newRouteRule creates a new RouteRule for a Channel resource. It also sets +// newVirtualService creates a new VirtualService for a Channel resource. It also sets // the appropriate OwnerReferences on the resource so handleObject can discover // the Channel resource that 'owns' it. -func newRouteRule(channel *channelsv1alpha1.Channel) *istiov1alpha2.RouteRule { +func newVirtualService(channel *channelsv1alpha1.Channel) *istiov1alpha3.VirtualService { labels := map[string]string{ "bus": channel.Spec.Bus, "channel": channel.Name, } - return &istiov1alpha2.RouteRule{ + return &istiov1alpha3.VirtualService{ ObjectMeta: metav1.ObjectMeta{ - Name: controller.ChannelRouteRuleName(channel.Name), + Name: controller.ChannelVirtualServiceName(channel.Name), Namespace: channel.Namespace, Labels: labels, OwnerReferences: []metav1.OwnerReference{ @@ -510,63 +471,20 @@ func newRouteRule(channel *channelsv1alpha1.Channel) *istiov1alpha2.RouteRule { }), }, }, - Spec: istiov1alpha2.RouteRuleSpec{ - Destination: istiov1alpha2.IstioService{ - Name: controller.ChannelServiceName(channel.Name), + Spec: istiov1alpha3.VirtualServiceSpec{ + Hosts: []string{ + controller.ServiceHostName(controller.ChannelServiceName(channel.Name), channel.Namespace), + controller.ChannelHostName(channel.Name, channel.Namespace), }, - Route: []istiov1alpha2.DestinationWeight{ + Http: []istiov1alpha3.HTTPRoute{ { - Destination: istiov1alpha2.IstioService{ - Name: controller.BusDispatcherServiceName(channel.Spec.Bus), + Rewrite: &istiov1alpha3.HTTPRewrite{ + Authority: controller.ChannelHostName(channel.Name, channel.Namespace), }, - Weight: 100, - }, - }, - Rewrite: istiov1alpha2.HTTPRewrite{ - Authority: fmt.Sprintf("%s.%s.channels.cluster.local", channel.Name, channel.Namespace), - }, - }, - } -} - -// newIngress creates a new Ingress for a Channel resource. It also sets -// the appropriate OwnerReferences on the resource so handleObject can discover -// the Channel resource that 'owns' it. -func newIngress(channel *channelsv1alpha1.Channel) *extensionsv1beta1.Ingress { - labels := map[string]string{ - "channel": channel.Name, - } - annotations := map[string]string{ - "kubernetes.io/ingress.class": "istio", - } - return &extensionsv1beta1.Ingress{ - ObjectMeta: metav1.ObjectMeta{ - Name: controller.ChannelIngressName(channel.ObjectMeta.Name), - Namespace: channel.Namespace, - Labels: labels, - Annotations: annotations, - OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(channel, schema.GroupVersionKind{ - Group: channelsv1alpha1.SchemeGroupVersion.Group, - Version: channelsv1alpha1.SchemeGroupVersion.Version, - Kind: "Channel", - }), - }, - }, - Spec: extensionsv1beta1.IngressSpec{ - Rules: []extensionsv1beta1.IngressRule{ - { - // TODO make host name configurable - Host: channel.ObjectMeta.Name, - IngressRuleValue: extensionsv1beta1.IngressRuleValue{ - HTTP: &extensionsv1beta1.HTTPIngressRuleValue{ - Paths: []extensionsv1beta1.HTTPIngressPath{ - { - Backend: extensionsv1beta1.IngressBackend{ - ServiceName: controller.ChannelServiceName(channel.ObjectMeta.Name), - ServicePort: intstr.FromString("http"), - }, - }, + Route: []istiov1alpha3.DestinationWeight{ + { + Destination: istiov1alpha3.Destination{ + Host: controller.ServiceHostName(controller.BusDispatcherServiceName(channel.Spec.Bus), channel.Namespace), }, }, }, diff --git a/pkg/controller/names.go b/pkg/controller/names.go index 587d151e13a..3b8a90e89d4 100644 --- a/pkg/controller/names.go +++ b/pkg/controller/names.go @@ -38,14 +38,18 @@ func BusDispatcherServiceName(busName string) string { return fmt.Sprintf("%s-bus", busName) } -func ChannelRouteRuleName(channelName string) string { +func ChannelVirtualServiceName(channelName string) string { return fmt.Sprintf("%s-channel", channelName) } -func ChannelIngressName(channelName string) string { +func ChannelServiceName(channelName string) string { return fmt.Sprintf("%s-channel", channelName) } -func ChannelServiceName(channelName string) string { - return fmt.Sprintf("%s-channel", channelName) +func ChannelHostName(channelName, namespace string) string { + return fmt.Sprintf("%s.%s.channels.cluster.local", channelName, namespace) +} + +func ServiceHostName(serviceName, namespace string) string { + return fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, namespace) } diff --git a/sample/hello/README.md b/sample/hello/README.md index 40c8f9d25cc..c7988f13e68 100644 --- a/sample/hello/README.md +++ b/sample/hello/README.md @@ -62,11 +62,11 @@ kail -d stub-bus -c dispatcher To invoke the function via the channel: ``` -# Put the Ingress Host name into an environment variable. -$ export SERVICE_HOST=`kubectl get ingress aloha-channel -o jsonpath="{.spec.rules[0].host}"` +# Put the channel hostname into an environment variable. +$ export SERVICE_HOST=`kubectl get gateway aloha-channel -o jsonpath="{.spec.servers[0].hosts[0]}"` -# Put the Ingress IP into an environment variable. -$ export SERVICE_IP=`kubectl get ingress aloha-channel -o jsonpath="{.status.loadBalancer.ingress[*]['ip']}"` +# Put the Istio IngressGateway IP into an environment variable. +$ export SERVICE_IP=`kubectl get svc -l istio=ingressgateway --all-namespaces -o jsonpath="{.items[0].status.loadBalancer.ingress[0].ip}"` # Curl the Ingress IP "as-if" DNS were properly configured. $ curl -H "Host: $SERVICE_HOST" -H "Content-Type: text/plain" $SERVICE_IP -d "Knative"