Gateway
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 configuration sets up a proxy to act as a load balancer exposing port 80 and 9080 (http), 443 (https), 9443(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/v1alpha3kind: Gatewaymetadata:name: my-gatewaynamespace: some-config-namespacespec:selector:app: my-gateway-controllerservers:- port:number: 80name: httpprotocol: HTTPhosts:- uk.bookinfo.com- eu.bookinfo.comtls:httpsRedirect: true # sends 301 redirect for http requests- port:number: 443name: https-443protocol: HTTPShosts:- uk.bookinfo.com- eu.bookinfo.comtls:mode: SIMPLE # enables HTTPS on this portserverCertificate: /etc/certs/servercert.pemprivateKey: /etc/certs/privatekey.pem- port:number: 9443name: https-9443protocol: HTTPShosts:- "bookinfo-namespace/*.bookinfo.com"tls:mode: SIMPLE # enables HTTPS on this portcredentialName: bookinfo-secret # fetches certs from Kubernetes secret- port:number: 9080name: http-wildcardprotocol: HTTPhosts:- "*"- port:number: 2379 # to expose internal service via external port 2379name: mongoprotocol: MONGOhosts:- "*"
apiVersion: networking.istio.io/v1beta1kind: Gatewaymetadata:name: my-gatewaynamespace: some-config-namespacespec:selector:app: my-gateway-controllerservers:- port:number: 80name: httpprotocol: HTTPhosts:- uk.bookinfo.com- eu.bookinfo.comtls:httpsRedirect: true # sends 301 redirect for http requests- port:number: 443name: https-443protocol: HTTPShosts:- uk.bookinfo.com- eu.bookinfo.comtls:mode: SIMPLE # enables HTTPS on this portserverCertificate: /etc/certs/servercert.pemprivateKey: /etc/certs/privatekey.pem- port:number: 9443name: https-9443protocol: HTTPShosts:- "bookinfo-namespace/*.bookinfo.com"tls:mode: SIMPLE # enables HTTPS on this portcredentialName: bookinfo-secret # fetches certs from Kubernetes secret- port:number: 9080name: http-wildcardprotocol: HTTPhosts:- "*"- port:number: 2379 # to expose internal service via external port 2379name: mongoprotocol: MONGOhosts:- "*"
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.svc.cluster.local” 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/v1alpha3kind: VirtualServicemetadata:name: bookinfo-rulenamespace: bookinfo-namespacespec:hosts:- reviews.prod.svc.cluster.local- uk.bookinfo.com- eu.bookinfo.comgateways:- some-config-namespace/my-gateway- mesh # applies to all the sidecars in the meshhttp:- match:- headers:cookie:exact: "user=dev-123"route:- destination:port:number: 7777host: reviews.qa.svc.cluster.local- match:- uri:prefix: /reviews/route:- destination:port:number: 9080 # can be omitted if it's the only port for reviewshost: reviews.prod.svc.cluster.localweight: 80- destination:host: reviews.qa.svc.cluster.localweight: 20
apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata:name: bookinfo-rulenamespace: bookinfo-namespacespec:hosts:- reviews.prod.svc.cluster.local- uk.bookinfo.com- eu.bookinfo.comgateways:- some-config-namespace/my-gateway- mesh # applies to all the sidecars in the meshhttp:- match:- headers:cookie:exact: "user=dev-123"route:- destination:port:number: 7777host: reviews.qa.svc.cluster.local- match:- uri:prefix: /reviews/route:- destination:port:number: 9080 # can be omitted if it's the only port for reviewshost: reviews.prod.svc.cluster.localweight: 80- destination:host: reviews.qa.svc.cluster.localweight: 20
The following VirtualService forwards traffic arriving at (external) port 27017 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/v1alpha3kind: VirtualServicemetadata:name: bookinfo-mongonamespace: bookinfo-namespacespec:hosts:- mongosvr.prod.svc.cluster.local # name of internal Mongo servicegateways:- some-config-namespace/my-gateway # can omit the namespace if gateway is in same namespace as virtual service.tcp:- match:- port: 27017route:- destination:host: mongo.prod.svc.cluster.localport:number: 5555
apiVersion: networking.istio.io/v1beta1kind: VirtualServicemetadata:name: bookinfo-mongonamespace: bookinfo-namespacespec:hosts:- mongosvr.prod.svc.cluster.local # name of internal Mongo servicegateways:- some-config-namespace/my-gateway # can omit the namespace if gateway is in same namespace as virtual service.tcp:- match:- port: 27017route:- destination:host: mongo.prod.svc.cluster.localport:number: 5555
It is possible to restrict the set of virtual services that can bind to a gateway server using the namespace/hostname syntax in the hosts field. For example, the following Gateway allows any virtual service in the ns1 namespace to bind to it, while restricting only the virtual service with foo.bar.com host in the ns2 namespace to bind to it.
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:name: my-gatewaynamespace: some-config-namespacespec:selector:app: my-gateway-controllerservers:- port:number: 80name: httpprotocol: HTTPhosts:- "ns1/*"- "ns2/foo.bar.com"
apiVersion: networking.istio.io/v1beta1kind: Gatewaymetadata:name: my-gatewaynamespace: some-config-namespacespec:selector:app: my-gateway-controllerservers:- port:number: 80name: httpprotocol: HTTPhosts:- "ns1/*"- "ns2/foo.bar.com"
Gateway
Gateway describes a load balancer operating at the edge of the mesh receiving incoming or outgoing HTTP/TCP connections.
| Field | Type | Description | Required |
|---|---|---|---|
servers | Server[] | A list of server specifications. | Yes |
selector | map<string, string> | One or more labels that indicate a specific set of pods/VMs on which this gateway configuration should be applied. By default workloads are searched across all namespaces based on label selectors. This implies that a gateway resource in the namespace “foo” can select pods in the namespace “bar” based on labels. This behavior can be controlled via the | Yes |
Server
Server describes the properties of the proxy on a given load balancer port. For example,
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:name: my-ingressspec:selector:app: my-ingressgatewayservers:- port:number: 80name: http2protocol: HTTP2hosts:- "*"
apiVersion: networking.istio.io/v1beta1kind: Gatewaymetadata:name: my-ingressspec:selector:app: my-ingressgatewayservers:- port:number: 80name: http2protocol: HTTP2hosts:- "*"
Another example
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:name: my-tcp-ingressspec:selector:app: my-tcp-ingressgatewayservers:- port:number: 27018name: mongoprotocol: MONGOhosts:- "*"
apiVersion: networking.istio.io/v1beta1kind: Gatewaymetadata:name: my-tcp-ingressspec:selector:app: my-tcp-ingressgatewayservers:- port:number: 27018name: mongoprotocol: MONGOhosts:- "*"
The following is an example of TLS configuration for port 443
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:name: my-tls-ingressspec:selector:app: my-tls-ingressgatewayservers:- port:number: 443name: httpsprotocol: HTTPShosts:- "*"tls:mode: SIMPLEcredentialName: tls-cert
apiVersion: networking.istio.io/v1beta1kind: Gatewaymetadata:name: my-tls-ingressspec:selector:app: my-tls-ingressgatewayservers:- port:number: 443name: httpsprotocol: HTTPShosts:- "*"tls:mode: SIMPLEcredentialName: tls-cert
| Field | Type | Description | Required |
|---|---|---|---|
port | Port | The Port on which the proxy should listen for incoming connections. | Yes |
bind | string | The ip or the Unix domain socket to which the listener should be bound to. Format: | No |
hosts | string[] | One or more hosts exposed by this gateway. While typically applicable to HTTP services, it can also be used for TCP services using TLS with SNI. A host is specified as a The A NOTE: Only virtual services exported to the gateway’s namespace (e.g., | Yes |
tls | ServerTLSSettings | 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. | No |
name | string | An optional name of the server, when set must be unique across all servers. This will be used for variety of purposes like prefixing stats generated with this name etc. | No |
Port
Port describes the properties of a specific port of a service.
| Field | Type | Description | Required |
|---|---|---|---|
number | uint32 | A valid non-negative integer port number. | Yes |
protocol | string | The protocol exposed on the port. MUST BE one of HTTP|HTTPS|GRPC|HTTP2|MONGO|TCP|TLS. TLS can be either used to terminate non-HTTP based connections on a specific port or to route traffic based on SNI header to the destination without terminating the TLS connection. | Yes |
name | string | Label assigned to the port. | Yes |
ServerTLSSettings
| Field | Type | Description | Required |
|---|---|---|---|
httpsRedirect | bool | If set to true, the load balancer will send a 301 redirect for all http connections, asking the clients to use HTTPS. | No |
mode | TLSmode | Optional: Indicates whether connections to this port should be secured using TLS. The value of this field determines how TLS is enforced. | No |
serverCertificate | string | REQUIRED if mode is | No |
privateKey | string | REQUIRED if mode is | No |
caCertificates | string | REQUIRED if mode is | No |
credentialName | string | For gateways running on Kubernetes, the name of the secret that holds the TLS certs including the CA certificates. Applicable only on Kubernetes. An Opaque secret should contain the following keys and values: | No |
subjectAltNames | string[] | A list of alternate names to verify the subject identity in the certificate presented by the client. | No |
verifyCertificateSpki | string[] | An optional list of base64-encoded SHA-256 hashes of the SPKIs of authorized client certificates. Note: When both verify_certificate_hash and verify_certificate_spki are specified, a hash matching either value will result in the certificate being accepted. | No |
verifyCertificateHash | string[] | An optional list of hex-encoded SHA-256 hashes of the authorized client certificates. Both simple and colon separated formats are acceptable. Note: When both verify_certificate_hash and verify_certificate_spki are specified, a hash matching either value will result in the certificate being accepted. | No |
minProtocolVersion | TLSProtocol | Optional: Minimum TLS protocol version. By default, it is Note: Using TLS protocol versions below TLSV1_2 has serious security risks. | No |
maxProtocolVersion | TLSProtocol | Optional: Maximum TLS protocol version. | No |
cipherSuites | string[] | Optional: If specified, only support the specified cipher list. Otherwise default to the default cipher list supported by Envoy as specified here. The supported list of ciphers are:
| No |
ServerTLSSettings.TLSmode
TLS modes enforced by the proxy
| Name | Description |
|---|---|
PASSTHROUGH | The SNI string presented by the client will be used as the match criterion in a VirtualService TLS route to determine the destination service from the service registry. |
SIMPLE | Secure connections with standard TLS semantics. |
MUTUAL | Secure connections to the downstream using mutual TLS by presenting server certificates for authentication. |
AUTO_PASSTHROUGH | Similar to the passthrough mode, except servers with this TLS mode do not require an associated VirtualService to map from the SNI value to service in the registry. The destination details such as the service/subset/port are encoded in the SNI value. The proxy will forward to the upstream (Envoy) cluster (a group of endpoints) specified by the SNI value. This server is typically used to provide connectivity between services in disparate L3 networks that otherwise do not have direct connectivity between their respective endpoints. Use of this mode assumes that both the source and the destination are using Istio mTLS to secure traffic. |
ISTIO_MUTUAL | Secure connections from the downstream using mutual TLS by presenting server certificates for authentication. Compared to Mutual mode, this mode uses certificates, representing gateway workload identity, generated automatically by Istio for mTLS authentication. When this mode is used, all other fields in |
ServerTLSSettings.TLSProtocol
TLS protocol versions.
| Name | Description |
|---|---|
TLS_AUTO | Automatically choose the optimal TLS version. |
TLSV1_0 | TLS version 1.0 |
TLSV1_1 | TLS version 1.1 |
TLSV1_2 | TLS version 1.2 |
TLSV1_3 | TLS version 1.3 |