Istio’s Networking API Explained
Istio version 1.0
comes with a networking API that comprises a lot of features and covers a variety of scenarios. The networking API has evolved in the last couple of months and might not be self-explanatory, right away. What are the concepts and building blocks of this API, and how do we use the individual Istio resource types in order to route traffic through our service mesh?
Although the documentation provides a huge amount of helpful information, I wanted to describe and explain the traffic routing in my own words. I had to struggle quite a bit to grasp what the concepts and motivations are, and especially how to apply the individual building blocks.
The following video aims to explain what the concepts of Istio’s networking (v3alpha
) API are, and how the building blocks are typically applied. It shows a visual model of the individual components in a service mesh that hopefully helps you in understanding and using Istio.
When to use which
Virtual services: To route traffic for a service that is part of the mesh to a specific destination, or subsets thereof, and/or to annotate HTTP (default) routes with certain behavior, such as timeouts.
Destination rules: To set policies on routed traffic, such as TLS settings, outlier detection, or load balancer settings, and/or to define subsets of services that are part of the mesh.
Service entries: To add additional services to Istio’s internal service registry, which is required to route traffic to external services. The added services can be enhanced with virtual services and destination rules.
Gateways (ingress): To route ingress traffic into the service mesh. The gateway needs to be bound to a virtual service which defines where the ingress traffic will be routed to.
Gateways (egress): To define a single point of exit where all egress traffic that leaves the mesh can be routed through. May be required for scenarios where only particular nodes can or should access external networks.
Insights & “Gotchas”
A few of my own insights that you might want to take into account once you start using Istio’s networking features. Some of them sound obvious but might contain a “gotcha” effect.
- Virtual services as well as destination rules don’t have to match platform (Kubernetes) services 1:1.
- HTTP and HTTPS/TLS is tread differently, especially in regards to routing rules and other “enhancements”, mostly due to the encrypted nature of the traffic. E.g.
- HTTPS traffic needs to be routed via TLS rules (using port & SNI), not HTTP rules.
- Resiliency features are only available for HTTP rules.
- Monitoring also displays either unencrypted HTTP traffic or just TCP, respectively. The latter naturally contains less information.
- To make use of all routing features, it makes sense to use unencrypted HTTP inside the service mesh.
- Istio’s optional mTLS still ensures that mesh-internal traffic is encrypted without requiring application-level HTTPS/TLS.
- Egress traffic can be encrypted via TLS once it leaves the mesh (see TLS origination).
- No external traffic is allowed to (undefined) services outside the mesh per default. Service entries are required.
- Ingress or egress gateway can be responsible for multiple platform (Kubernetes) services but needs to be bound to a single virtual service definition.
- It’s possible to control or “enhance” egress traffic via both virtual services or destination rules that are defined for the external host names.
- Traffic to hosts specified in service entries can be re-routed to internal services.
- External service entries are monitored as individual services, as long as the entry isn’t redirected to another, internal service.
- Istio doesn’t perform DNS resolution, however, proxies will route traffic according to host names.
- Istio proxies regard host names as well as SNI names and can re-route traffic to internal or external services.
- It might make sense to define external services via platform (Kubernetes) external services, to resolve external service names via DNS. Especially TCP host names are typically resolved by the application.
I hope this clarifies Istio’s networking features a bit more. I’d be happy to receive your feedback!
More information
- Traffic Management (Istio documentation)
- API reference
- Introducing the Istio v1alpha3 routing API (Istio blog post)
- Coffee example project
Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: Istio’s Networking API Explained Opinions expressed by Java Code Geeks contributors are their own. |