Istio ... why?
Looking at post history in r/kubernetes it seems like Istio is all the rage in recent months - yet another 'getting started with Istio' blog post gets linked pretty much every week. But why would I actually need istio in kubernetes? Lets start with supposed upsides:
- service discovery - kubernetes does that OOTB with DNS or env variables
- load balancing - handled by kubernetes services
- traffic shaping - ok, could be useful for canary deployments. Without istio I can only direct percentage of traffic based on number of pods
- security - it is a different approach than mTLS, but I can use network policies instead
- distributed tracing - it is useful I guess, but not really something unique to Istio. I am currently using Spring Boot + Sleuth, which is quite painless to set up
Now disadvantages:
- mixer, envoy, pilot, citadel, galley - that's a lot of moving parts. Which means that when stuff breaks I will have one more complicated system to debug
- performance - according to istio docs, using envoy comes with extra 8-20ms (for 15-60 connections). Not a big deal for calling a slow webservice, but definitely a big deal if I wanted to use Istio for Redis access as well
It seems to me that Istio could be quite useful for EC2/GCE clusters, but in case of kubernetes it just replicates a lot of built-in functionality in a different way.
Posted Aug 15, 2019, 4:07 PM UTC
The goal with all service meshes is always to separate network failures from application failures. This is why they gained traction in the first place, so you don't have to bake network-aware logic into an application and require applications to then be aware of how the rest of the cluster is orchestrated.
Unfortunately, Kubernetes by itself doesn't do a perfect job of isolating network failure from application failure. Take your own example of how Kubernetes native services discover each other, via DNS or env variables.
Env variables are static and baked into the container; if an upstream service changes its ClusterIp (happens a lot if you update Deployments), then your env variables no longer resolve correctly until you restart your service
Similarly, DNS in Kubernetes is very dumb - in a single cluster, you can get away with <service>.svc URLs, but when you have multi-cluster you now need to also specify the exact cluster in which your service is hosted in for DNS to resolve correctly, which you cannot discover upfront. (Also, K8s DNS relies on an ndots hack in /etc/resolv.conf in containers which means the .svc URL is actually recursively expanded by kube-dns/CoreDNS until it matches the FQDN for the service in the cluster, which can take upto 5 or more round-robin queries to resolve - just an interesting note if you ever have to resolve a performance issue with DNS as I have had to :))
Service meshes improve on this by:
a) registering an arbitrary number of hostnames for any service rather than just a single DNS entry you can't control,
b) identifying how much in-cluster traffic should go to which services, which is great for more than just canarying (sharding data across StatefulSets and routing to the correct shard comes to mind)
c) ensuring communication between services is abstracted out from the service itself. This is the big win, and it means you get logging, metrics, and tracing instrumentation for free, rather than relying on access logs as a proxy.
d) doing crazy things at the network level like circuit breaking, packet filtering, etc. for quicker time to repair.
The main reason people gravitate towards Istio is because it provides all of these and other benefits in one place. You can certainly build your own piecemeal solution to one problem at a time, but sooner or later you need a service mesh. There are other service meshes besides Istio; Istio just happens to be the service mesh du jour just like K8s is the orchestration platform du jour.
Some companies need it sooner than others depending on how many services they're running and how many clusters they're operating - if you're curious about whether you've hit that point, look at how many of your SLO/SLA violations across all applications can be attributed to applications losing connectivity with each other that isn't because of the application itself. If it accounts for at least a tenth, I'd say you've hit that point.
This is a great summary on why to use Istio!