What Is a Service Mesh?
It pains me to see that the concept of a service mesh often become Kubernetes centric, because I believe that they can be useful even with other, simpler orchestrators (Docker Swarm or Hashicorp Nomad, or just running any container runtime where you have overlay networks and such across possibly multiple nodes), or even when you don&#x27;t use containers at all.<p>For example, to me it feels that even with something simpler like Docker Compose&#x2F;Swarm and a bit of configuration for the web server of your choice (which might work as an ingress that&#x27;s bound to ports 80 and 443, without even needing to learn of the Kubernetes Ingress Controller concept), you can get many of the benefits. I am actually using the decidedly old school Apache httpd web server (previously used Caddy) for something like that in my own personal deployments, in front of every single one of my sites, here&#x27;s a quick look into some common configurations: <a href="https:&#x2F;&#x2F;blog.kronis.dev&#x2F;tutorials&#x2F;how-and-why-to-use-apache-httpd-in-2022" rel="nofollow">https:&#x2F;&#x2F;blog.kronis.dev&#x2F;tutorials&#x2F;how-and-why-to-use-apache-...</a><p>Let me give you a few examples (if you think these are silly, my summary is at the bottom):<p>&gt; Service discovery<p>Docker actually provides you with DNS out of the box, so your web server can easily refer to services, like such:<p><pre><code>  ProxyPass &quot;&#x2F;&quot; &quot;http:&#x2F;&#x2F;my_application:80&#x2F;&quot;
</code></pre>
More information: <a href="https:&#x2F;&#x2F;docs.docker.com&#x2F;network&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.docker.com&#x2F;network&#x2F;</a><p>&gt; Load balancing<p>The above will also distribute the traffic based on how many instances you have running, from as many web servers as you have running. Throw in health checks (such as the container running curl against itself, to check that the API&#x2F;web interface is available when starting up, as well as periodically during operation) so no traffic gets routed before your application can receive them and you&#x27;re good for the most part: <a href="https:&#x2F;&#x2F;docs.docker.com&#x2F;engine&#x2F;swarm&#x2F;services&#x2F;#publish-ports" rel="nofollow">https:&#x2F;&#x2F;docs.docker.com&#x2F;engine&#x2F;swarm&#x2F;services&#x2F;#publish-ports</a><p>&gt; TLS encryption<p>Let&#x27;s Encrypt as well as your own custom certificates are supported by most web servers out there rather easily, even Apache now has mod_md for automating this: <a href="https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;trunk&#x2F;mod&#x2F;mod_md.html" rel="nofollow">https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;trunk&#x2F;mod&#x2F;mod_md.html</a><p>Also, if you want, you can encrypt the network traffic between the nodes as well and not worry about having to manage the internal certificates manually either: <a href="https:&#x2F;&#x2F;docs.docker.com&#x2F;engine&#x2F;swarm&#x2F;networking&#x2F;#customize-an-overlay-network" rel="nofollow">https:&#x2F;&#x2F;docs.docker.com&#x2F;engine&#x2F;swarm&#x2F;networking&#x2F;#customize-a...</a><p>&gt; Authentication and authorization<p>Once again, web servers are pretty good at this, you can configure most forms or auth easily and even the aforementioned Apache now has mod_auth_openidc which supports OpenID Connect, so you can even configure it to be a Relying Party and not worry <i>as much</i> about letting your applications themselves manage that (given that if you have 5 different tech stacks running, you&#x27;d need 5 bits of separate configuration and libraries for that): <a href="https:&#x2F;&#x2F;github.com&#x2F;zmartzone&#x2F;mod_auth_openidc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;zmartzone&#x2F;mod_auth_openidc</a><p>&gt; Metrics aggregation, such as request throughput and response time, Distributed tracing<p>This might be a little bit more tricky! The old Apache outputs its server status with a handler that you can configure (see a live example here: <a href="https:&#x2F;&#x2F;issues.apache.org&#x2F;server-status" rel="nofollow">https:&#x2F;&#x2F;issues.apache.org&#x2F;server-status</a> ) thanks to mod-status: <a href="https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.4&#x2F;mod&#x2F;mod_status.html" rel="nofollow">https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.4&#x2F;mod&#x2F;mod_status.html</a> and there&#x27;s similar output for the ACME certificate status as well, which you can configure. The logs also contain metrics about the requests, which once again are configurable.<p>Other web servers might give you more functionality in that regard (or you might shop around for Apache modules), Traefik, Caddy as well as Nginx Proxy Manager might all be good choices both when you&#x27;re looking to hook up for something external to aggregate the metrics with minimal work, or want a dashboard of some sort, for example: <a href="https:&#x2F;&#x2F;doc.traefik.io&#x2F;traefik&#x2F;operations&#x2F;dashboard&#x2F;" rel="nofollow">https:&#x2F;&#x2F;doc.traefik.io&#x2F;traefik&#x2F;operations&#x2F;dashboard&#x2F;</a><p>&gt; Rate limiting<p>In Apache, it&#x27;s a bit more troublesome (other servers do this better most of the time), depending on which approach you use, but something basic isn&#x27;t too hard to set up: <a href="https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.4&#x2F;mod&#x2F;mod_ratelimit.html" rel="nofollow">https:&#x2F;&#x2F;httpd.apache.org&#x2F;docs&#x2F;2.4&#x2F;mod&#x2F;mod_ratelimit.html</a><p>&gt; Routing and traffic management, Traffic splitting, Request retries<p>I&#x27;m grouping these together, because what people expect from this sort of functionality might vary a lot. You can get most of the basic stuff out of most web servers, which will be enough for the majority of the web servers out there.<p>Something like blue&#x2F;green deployments, A&#x2F;B testing or circuit breaking logic is possible with a bit more work, but here I&#x27;ll concede that for the more advanced setups out there something like Istio and Kiali would be better solutions. Then again, those projects won&#x27;t be the majority of the ones out there.<p>&gt; Error handling<p>Depends on what you want to do here, custom error pages (or handlers), or something in regards to routing or checking for the presence of resources isn&#x27;t too hard and has been done for years.<p>Summary:<p>But what&#x27;s my point here? Should everyone abandon using Linkerd or Istio? Not at all! I&#x27;m just saying that even with lightweight technologies and for simpler tech stacks, having and ingress as well as something that covers most of what a service mesh would (e.g. the aforementioned Docker overlay networking, or similar solutions) can be immensely useful.<p>After putting Nginx in front of many of the services for projects at work, path rewriting, as well as handling special rules for certain apps has become way easier, certificate management is a breeze since it can be done with Ansible just against a single type of service, in addition to something like client certs or OIDC (though admittedly, that&#x27;s mostly on my homelab, with Apache).<p>Once you actually grow past that, or have your entire business built on Kubernetes, then feel free to adopt whatever solutions you deem necessary! But don&#x27;t shy away from things like this even when you have &lt;10 applications running in about as many containers (or when you have <i>some</i> horizontal scalability across your nodes).<p>Note: you can still have HAProxy or some fancy WAF solution for your org, or anything of that sort as well - I was talking more about the scale of individual projects&#x2F;applications here. It&#x27;s really nice that you can layer whatever you need.