Latest / CyberSecurity Summary / Traefik API Gateway for Microservices: With Java and Python Microservices Deployed in Kubernetes
Transcript
- 0:00Speaker 1: Welcome back to the deep dive. Today, we are wrestling with, uh,
- 0:05Speaker 1: probably the defining architectural challenge of the last few years,
- 0:09Speaker 1: maybe the.
- 0:09Speaker 2: Decade definitely feels like it.
- 0:11Speaker 1: How do you reliably route traffic when the ground beneath
- 0:15Speaker 1: your feet is constantly shifting. We're talking about the shift
- 0:17Speaker 1: from stable, predictable monoliths.
- 0:19Speaker 2: Right, the quarterly release cycle kind of.
- 0:22Speaker 1: Thing exactly, to this well sometimes chaotic world of micro
- 0:26Speaker 1: services that scale up and down constantly.
- 0:28Speaker 2: Yeah, it's like comparing I don't know, a printed map
- 0:31Speaker 2: from the nineties to Google Maps in a city where
- 0:34Speaker 2: roads just appear and disappear every few minutes and buildings
- 0:38Speaker 2: resize themselves.
- 0:39Speaker 1: That's a great analogy. And those older load balancers, the
- 0:42Speaker 1: ones built for the static map, they just can't cope.
- 0:45Speaker 2: They're stuck in that static config mindset. They pretty much
- 0:48Speaker 2: melt down when faced with how dynamic a modern cloud
- 0:52Speaker 2: environment really.
- 0:52Speaker 1: Is and that operational headache. That's why we're diving deep
- 0:56Speaker 1: into Treevik today. It's an open source API gateway and
- 0:59Speaker 1: it's build specific to handle that dynamic complexity.
- 1:02Speaker 2: Right. The idea is to simplify deploy micro services, especially
- 1:05Speaker 2: if you're in the kuber eddies world, which, let's face it, many.
- 1:08Speaker 1: Are so our mission today.
- 1:10Speaker 2: Our mission is to unpack how trific acts as this
- 1:14Speaker 2: crucial link. Think of it as the intelligent gateway tier.
- 1:18Speaker 2: It connects that volatile ecosystem of services to the outside world.
- 1:23Speaker 1: And by the end you listening should have a pretty
- 1:26Speaker 1: good handle on the cutting edge of network routing.
- 1:29Speaker 2: A shortcut maybe, yeah, a shortcut to being well informed
- 1:32Speaker 2: about this stuff. Resilience patterns too.
- 1:34Speaker 1: Okay, let's start with the big picture, the monolith problem.
- 1:37Speaker 1: We probably all remember it, right, tight coupling.
- 1:39Speaker 2: Slow releases, Oh the.
- 1:42Speaker 1: Pain, and that really expensive all or nothing scaling. Need
- 1:46Speaker 1: more horsepower for login scale.
- 1:48Speaker 2: The whole thing, huge waste of resources. That worked. Okay,
- 1:51Speaker 2: I guess with the classic three tier model presentation, application data, simple.
- 1:56Speaker 1: Enough, but micro services break that model completely.
- 1:59Speaker 2: When you shatter that happened to I don't know, dozens
- 2:01Speaker 2: hundreds of tiny services. You need a different architecture.
- 2:04Speaker 1: You have to evolve the four tier model.
- 2:06Speaker 2: Exactly, build for distributed systems.
- 2:08Speaker 1: And that fourth tier is where Trafiic lives, right, that's.
- 2:11Speaker 2: His home turf. Right, So the four tiers you really
- 2:13Speaker 2: need are first, content delivery, the UI, the client stuff.
- 2:17Speaker 1: Okay.
- 2:17Speaker 2: Second, the gateway tier, that's STRAFIK, discovery, routing, correlating requests,
- 2:23Speaker 2: aggregating responses sometimes all that happens here the traffic hap
- 2:27Speaker 2: sort of. Yeah. Then third is the services tier, your
- 2:30Speaker 2: actual decoupled business logic units, high cohesion, loose coupling, all
- 2:35Speaker 2: that good stuff. And finally, the data tier databases, message queues,
- 2:40Speaker 2: but now ideally exclusive to the services that own that data.
- 2:43Speaker 1: Okay, So the gateway tier is critical, it's the front door.
- 2:47Speaker 1: What does a modern gateway like trafic absolutely have to
- 2:50Speaker 1: do to handle that chaos in tier three?
- 2:52Speaker 2: Right, It's got to be more than just a simple
- 2:54Speaker 2: port forwarder. Layer seven routing is non negotiable.
- 2:56Speaker 1: Where seven meaning application layer.
- 2:59Speaker 2: Exactly routing based on HTDP headers, host names, paths, maybe
- 3:03Speaker 2: even stuff in the request body, not just layer four
- 3:05Speaker 2: like TCP or UDP ports. And it needs to speak
- 3:08Speaker 2: different languages essentially HDTP one, HGDP two, gRPC rest it
- 3:11Speaker 2: shouldn't care.
- 3:12Speaker 1: And security that feels like a huge piece, especially with
- 3:15Speaker 1: all those services chattering away behind the gateway.
- 3:18Speaker 2: Oh massive, Absolutely, the gateway must handle TLS termination, you know,
- 3:23Speaker 2: decrypting the incoming.
- 3:25Speaker 1: Public traffic standard stuff, right, But.
- 3:27Speaker 2: Then inside the cluster for service to service chat you
- 3:31Speaker 2: need mutual tls MTLs.
- 3:33Speaker 1: So both sides prove who they are precisely.
- 3:36Speaker 2: It's not just the client showing ID. The server demands
- 3:39Speaker 2: ID back, show me your papers too. It's essential for
- 3:42Speaker 2: locking things down inside your perimeter if something goes wrong,
- 3:45Speaker 2: limits the blast radius.
- 3:47Speaker 1: Okay, that makes sense, which leads us right to maybe
- 3:49Speaker 1: the killer feature, autoconfiguration. Because, like you said, hundreds of services,
- 3:53Speaker 1: maybe thousands of instances, updating config files byhand impossible right there, It.
- 3:59Speaker 2: Just doesn't scale. That's where Treyfik fundamentally solves the service
- 4:02Speaker 2: discovery problem. Instead of a human editing.
- 4:05Speaker 1: A file, which is always error prone.
- 4:07Speaker 2: Always, instead, Trephi talks directly to a service registry. Think Console,
- 4:11Speaker 2: etca a Kubernetes itself. These things are like near real
- 4:15Speaker 2: time databases of where every active service instance lives on
- 4:18Speaker 2: the network.
- 4:19Speaker 1: Ah, so Triffic doesn't need its own map. It just
- 4:21Speaker 1: asks the map maker constantly.
- 4:23Speaker 2: Exactly perfect analogy. Treyfik calls these map makers providers. It
- 4:27Speaker 2: has first class support baked in, just sits there and
- 4:29Speaker 2: watches the provider. A new service instance spins up. Treyfix
- 4:33Speaker 2: C is it yep, an old one dies, treyfix E
- 4:36Speaker 2: is that too, and it automatically reconfigures its own routing
- 4:39Speaker 2: tables crucially without needing a restart or dropping existing connections.
- 4:44Speaker 1: Hot reloads zero downtime. That's the dream.
- 4:47Speaker 2: That's critical. Dynamic configuration and hot reloads are absolutely key.
- 4:52Speaker 1: How tricky is it if you're running say, Docker and
- 4:55Speaker 1: Kubernetes and maybe console, can one Trafiic instance watch all
- 4:59Speaker 1: of them?
- 5:00Speaker 2: Yeah? Surprisingly easily. That's the beauty of the provider concept.
- 5:04Speaker 2: Trayfik kind of abstracts away the specific details of talking
- 5:08Speaker 2: to Kubernetes versus talking to Console, so you can centralize
- 5:11Speaker 2: routing even in a mixed environment.
- 5:13Speaker 1: So developers just deploy to whatever platform.
- 5:15Speaker 2: They use, and Treyfik figures out how to find it
- 5:17Speaker 2: and send traffic there. Developers focus on code. Treefiic handles
- 5:21Speaker 2: the routing complexity.
- 5:22Speaker 1: Okay, so Treyfik knows where everything is. Now let's talk
- 5:26Speaker 1: about actually sending the traffic efficiently. We all know basic
- 5:30Speaker 1: round robin, right, just deal them out equally fine for
- 5:34Speaker 1: stateless stuff.
- 5:35Speaker 2: Yeah, simple, effective, if all your servers are identical, but.
- 5:38Speaker 1: They rarely are so weighted Round Robin WRR. How does
- 5:42Speaker 1: that work?
- 5:42Speaker 2: Right? WRR is about being smarter with resources. Maybe you
- 5:46Speaker 2: have an older, cheaper server with less CPU. You don't
- 5:49Speaker 2: want to getting the same traffic as your brand new
- 5:52Speaker 2: beat cloud instance makes sense, So WRR lets you assign weights.
- 5:56Speaker 2: You could say, send three requests to the powerful guests
- 5:59Speaker 2: B one group for every one request you send to
- 6:01Speaker 2: the older guest D two, a three point one ratio
- 6:04Speaker 2: for example.
- 6:04Speaker 1: So it's not just load balancing, it's cost optimization too.
- 6:08Speaker 2: Definitely in the cloud especially, WRR helps you squeeze maximum
- 6:12Speaker 2: value out of cheaper or older instances alongside the new ones.
- 6:15Speaker 2: Keeps everything utilized efficiently, saves money, no resource just sitting
- 6:19Speaker 2: idle or getting totally slammed.
- 6:21Speaker 1: Okay, let's flip that. What about apps where the user's
- 6:23Speaker 1: state matters, like a shopping cart stored in memory on
- 6:26Speaker 1: one specific server instance, Round Robin would break that.
- 6:30Speaker 2: Yeah, that needs sticky sessions. If a user's second request
- 6:33Speaker 2: hits a different server, poof their cart is gone or
- 6:36Speaker 2: they get logged out. Bad experience.
- 6:39Speaker 1: So how does trophy candle that it uses cookies.
- 6:41Speaker 2: Typically when the first request hits a back end instance,
- 6:45Speaker 2: treefix sets a cookie in the response for subsequent requests
- 6:48Speaker 2: from that same user, trific reads the cookie and make
- 6:51Speaker 2: sure to send the request back to that same original instance.
- 6:54Speaker 2: Keeps a session alive.
- 6:55Speaker 1: Okay, sticky sessions makes sense, But underlying all this balancing,
- 6:59Speaker 1: you need health right. Making sure you're not sending traffic
- 7:02Speaker 1: to a dead.
- 7:03Speaker 2: Server absolutely fundamental. You only want to route traffic to
- 7:06Speaker 2: instances that are actually healthy, usually meaning they return a
- 7:10Speaker 2: two XX or a three X HTTP status code. Anything
- 7:14Speaker 2: else is an error.
- 7:15Speaker 1: Doesn't constantly poking every instance ad overhead though a performance tax.
- 7:19Speaker 2: That's a fair question. It's a trade off. Trefik does
- 7:22Speaker 2: use active checks where it sends a probe and passive
- 7:25Speaker 2: checks watching responses. But you can figure the interval. You
- 7:28Speaker 2: tune it so you find a balance, right, you said it, so.
- 7:32Speaker 2: The monitoring overhead isn't painful, but it's frequent enough to
- 7:35Speaker 2: pull an unhealthy instance out of the pool quickly when
- 7:38Speaker 2: it does fail. It's crucial for the stability of things
- 7:41Speaker 2: like round robin.
- 7:42Speaker 1: Let's shift gears a bit to more advanced resilience patterns.
- 7:46Speaker 1: Traffic mirroring sometimes called shadowing, sounds useful for testing.
- 7:49Speaker 2: Oh, it's fantastic for canary deployments, really safe testing. The
- 7:52Speaker 2: idea is you take your live production traffic, the real stuff,
- 7:56Speaker 2: the real stuff, and you copy a small percentage of it,
- 7:59Speaker 2: say ten percent, and send that copy asynchronously to a
- 8:02Speaker 2: new test environment, maybe your guess V two.
- 8:05Speaker 1: Version, asynchronously, so the original user isn't waiting exactly.
- 8:09Speaker 2: And critically trafiic ignores the response from that mirror request.
- 8:13Speaker 2: It just fires it off and forgets about it unless
- 8:16Speaker 2: you see how your new code behaves under real load stability,
- 8:19Speaker 2: resource use without any risk to the actual user experience.
- 8:23Speaker 1: That's clever. Okay, so we've handled load and safe testing.
- 8:26Speaker 1: But what about when things actually fail, not just one instance,
- 8:29Speaker 1: but maybe a whole downstream database or API becomes slow
- 8:33Speaker 1: or unresponsive in a micro services world. That seems like
- 8:37Speaker 1: it could cause chaos.
- 8:38Speaker 2: It absolutely can. That's the dreaded cascading failure scenario. One
- 8:43Speaker 2: slow dependency makes its callers wait, they.
- 8:45Speaker 1: Run out of threads or connections.
- 8:47Speaker 2: Exactly, and then they fail, taking down the services to
- 8:50Speaker 2: call them. It ripples outwards.
- 8:52Speaker 1: So how does trific act as a ble kid prevent
- 8:54Speaker 1: that ripple.
- 8:55Speaker 2: That's the job of the circuit breaker pattern. Trafic middleware
- 8:58Speaker 2: can implement this. It watches for failures going to a
- 9:01Speaker 2: particular back end service.
- 9:03Speaker 1: Failure is meaning errors or timeouts.
- 9:06Speaker 2: Both typically yeah, if the failure rate or maybe latency
- 9:10Speaker 2: crosses a threshold you.
- 9:11Speaker 1: Define like too many errors in the last minute.
- 9:13Speaker 2: Right, or responses are taking too long. If that happens,
- 9:16Speaker 2: Trefix trips the breaker. It stops sending requests to that
- 9:20Speaker 2: struggling service altogether for.
- 9:21Speaker 1: A period and just returns an error immediately.
- 9:23Speaker 2: Yep, usually a five zero three service unavailable. It does
- 9:26Speaker 2: this instantly without even trying the failing service. This protects
- 9:30Speaker 2: the calling services from getting bogged down and saves resources
- 9:34Speaker 2: across the system. It's like the system saying nope, that
- 9:36Speaker 2: are closed for now, try again later.
- 9:38Speaker 1: And the conditions for tripping. It can be quite sophisticated.
- 9:41Speaker 2: I saw yeah. Treefix implementation is pretty powerful. It's not
- 9:44Speaker 2: just simple failure counts. You could use expressions like trip
- 9:48Speaker 2: if latency at quantil ms fifty point zero hundred meaning
- 9:52Speaker 2: the meeting response time is over one hundred.
- 9:54Speaker 1: Milliseconds, or based on error ratio exactly.
- 9:57Speaker 2: Response cut a ratio five hundred, six hundred point twenty
- 9:59Speaker 2: five trip if more than twenty five percent of recent
- 10:01Speaker 2: responses were five xx errors gives you fine grain control.
- 10:05Speaker 1: Okay, circuit breakers handle the big failures. What about those
- 10:08Speaker 1: little annoying transient glitches like a brief network kickup that
- 10:12Speaker 1: just needs a quick retry.
- 10:14Speaker 2: Perfect use case for retries middleware, Just like getting refresh
- 10:17Speaker 2: in your browser when it page times out right, TRIFIC
- 10:19Speaker 2: could be configured to automatically retry a request, maybe once
- 10:22Speaker 2: or twice if it fails with specific errors like a
- 10:25Speaker 2: connection timeout or maybe a five h two bad gateway.
- 10:28Speaker 2: It provides a basic level of self healing for those
- 10:30Speaker 2: intermitt network blips.
- 10:31Speaker 1: Makes sense. So we've got routing balancing resilience. But when
- 10:35Speaker 1: things do go wrong despite all this, we need to
- 10:38Speaker 1: figure out why. Let's talk observability.
- 10:41Speaker 2: Crucial observability isn't just knowing that something is wrong, but
- 10:45Speaker 2: having the data to understand why. And TRIFIC, sitting at
- 10:49Speaker 2: the entry point, is perfectly placed to collect that data.
- 10:53Speaker 1: Across the three pillars right, logs, traces, metrics exactly.
- 10:57Speaker 2: Let's start with logs.
- 10:59Speaker 1: Now people off and say application logs alone aren't enough
- 11:02Speaker 1: in micro services. What makes trifix logs actually useful here?
- 11:06Speaker 2: Well, it generates standard error logs, of course, but the
- 11:09Speaker 2: real value is often in the access logs. The trick
- 11:12Speaker 2: is logging everything for every request can be really resource intensive.
- 11:16Speaker 1: Yeah, generates huge amounts of data.
- 11:18Speaker 2: So trific lets you filter them intelligently. You might say,
- 11:21Speaker 2: only lawged requests that resulted in a redirect status codes
- 11:24Speaker 2: three hundred to three h two, or only log requests
- 11:27Speaker 2: that took longer than say, five seconds to complete using
- 11:31Speaker 2: a mind duration filter.
- 11:32Speaker 1: Ah, so you capture the interesting or problematic events without
- 11:35Speaker 1: drowning and routine data.
- 11:37Speaker 2: Precisely optimizes performance, gets you the diagnostic data you actually need.
- 11:40Speaker 1: Okay, logs tell us what happened at the edge, But
- 11:42Speaker 1: to follow a request through multiple services, we need tracing.
- 11:46Speaker 2: Right request tracing stitches the whole journey together. Each piece
- 11:50Speaker 2: of work done by a service is a span. All
- 11:53Speaker 2: the spans for one user request combine into a single trace, like.
- 11:57Speaker 1: A timeline of the request's life.
- 11:59Speaker 2: Exactly, and Trafik being the first point of contact, can
- 12:03Speaker 2: generate standardized trace headers, often B three propagation headers, things
- 12:08Speaker 2: like XB three trace seed. Think of them like a digital.
- 12:10Speaker 1: Passport, and it passes that passport along.
- 12:13Speaker 2: It injects those headers into the request before forwarding it
- 12:16Speaker 2: to the first back end service. That service, if it's
- 12:19Speaker 2: trace aware, adds its own span and passes the headers on.
- 12:22Speaker 2: So even if the request hits five different micro services,
- 12:25Speaker 2: you can.
- 12:25Speaker 1: See the whole chain in a system like Zipkin or
- 12:28Speaker 1: Jaeger exactly.
- 12:29Speaker 2: End to end visibility invaluable for debugging distributed systems.
- 12:32Speaker 1: And the third pillar metrics the numbers yep.
- 12:35Speaker 2: Treyfix exposes key application level metrics, things like total request counts,
- 12:39Speaker 2: request latencies, average quantiles, error rates, information about the.
- 12:43Speaker 1: Back end servers, and you feed that into.
- 12:45Speaker 2: Standard monitoring systems, typically Prometheus. Prometheus scrapes these metrics from
- 12:50Speaker 2: Treyfi periodically. Then you can use tools like Rafona to
- 12:53Speaker 2: visualize trends, plan capacity, and set up automated alerts if say,
- 12:58Speaker 2: aer rates spike or latency degrades.
- 13:01Speaker 1: Got it? Okay, let's bring this home to the place
- 13:03Speaker 1: where treefix seems most popular. Kubernetes. You mentioned earlier that
- 13:07Speaker 1: the original Kubernetes ingress API wasn't great.
- 13:11Speaker 2: Yeah, it was. Let's say a bit under specified vague,
- 13:14Speaker 2: which forced vendors like treyfick in Jinks and others to
- 13:18Speaker 2: rely heavily on custom.
- 13:19Speaker 1: Annotations, annotations being those kind of messy tech strings. In
- 13:23Speaker 1: the Yamo.
- 13:23Speaker 2: Exactly, you'd have dozens of vendor specific annotations to configure
- 13:27Speaker 2: basic things like timeouts or retries or sticky sessions. It
- 13:31Speaker 2: wasn't clean, wasn't standardized.
- 13:33Speaker 1: So how did trefik improve on that? They gave up
- 13:35Speaker 1: on Ingress in treyfiic v two.
- 13:36Speaker 2: They shifted strategy. They embraced Kubernetes's custom resource definitions or crds.
- 13:41Speaker 2: They introduced their own resources like ingress, root middleware TLS.
- 13:45Speaker 1: Option, So instead of annotations, you define routing rules using
- 13:48Speaker 1: these custom but still native feeling Kubernetes's objects.
- 13:51Speaker 2: Precisely, it's a much nicer experience. As they say, configuration
- 13:55Speaker 2: becomes structured, version controllable Kubernetes YAML, just like your deployment services.
- 14:01Speaker 2: Any Kubernetes engineer can understand it. It follows familiar patterns,
- 14:05Speaker 2: no more digging through annotation documentation for different vendors.
- 14:08Speaker 1: That sounds like a huge improvement. And you also touched
- 14:10Speaker 1: on TLS simplification getting certificates is often a real pain.
- 14:15Speaker 2: Oh historically it was awful manual requests, validation hoops, remembering
- 14:19Speaker 2: to new high chance of error, high risk.
- 14:23Speaker 1: So how does trifick fix that.
- 14:25Speaker 2: It integrates directly with the ACME protocol, which is the
- 14:28Speaker 2: standard let's encrypt uses for automating certificate issuance for public domains.
- 14:32Speaker 1: Let's encrypt the free certificate authority right.
- 14:35Speaker 2: When in trifick you basically just configure a cert resolver
- 14:38Speaker 2: pointing to let's encrypt. Than when you define an ingress
- 14:42Speaker 2: route for a public host.
- 14:43Speaker 1: Name, trifiic just handles it.
- 14:44Speaker 2: It handles the entire life cycle automatically. It requests the certificate,
- 14:49Speaker 2: handles the domain validation challenge, often using something called the
- 14:52Speaker 2: TLS ALPN zero one challenge. It's quite neat, retrieves the certificate,
- 14:58Speaker 2: installs it, and even handles renew before it expires.
- 15:01Speaker 1: Wow. So the developer just defines the route asks for
- 15:04Speaker 1: TLS and trefick and let's encrypt do the rest.
- 15:08Speaker 2: Pretty much focus on the application logic. The complicated, error
- 15:12Speaker 2: prone task of certificate management just happens.
- 15:15Speaker 1: So wrapping it up, trefix core value seems to be
- 15:18Speaker 1: replacing that old, rigid manual configuration world.
- 15:21Speaker 2: Which just breaks under micro service dynamism.
- 15:24Speaker 1: With the dynamic self configuring system built for that reality.
- 15:28Speaker 1: It's the traffic cop that learns the roads automatically as
- 15:31Speaker 1: they get built or torn down well put.
- 15:33Speaker 2: And there's a final thought, maybe a provocative one, tied
- 15:35Speaker 2: to that certificate automation. We just discussed why traditionally certificate
- 15:39Speaker 2: management was so painful and manual. People did it infrequently,
- 15:42Speaker 2: maybe once a year. This meant certificates were valued for
- 15:45Speaker 2: a long time. If one got compromise somehow, an attacker
- 15:48Speaker 2: had a year long window.
- 15:50Speaker 1: Right. Long lived credentials are risky.
- 15:52Speaker 2: Very yeah. But because Trefix integration with let's encrypt automates
- 15:56Speaker 2: the renewal process, certificates typically only live for ninety days now,
- 16:01Speaker 2: and the renewals automatic, often no human touch needed.
- 16:05Speaker 1: So it drastically shrinks the window of opportunity for an
- 16:08Speaker 1: attacker using a compromise certificate.
- 16:11Speaker 2: Exactly here removes a tedious, error prone operational task and
- 16:15Speaker 2: significantly improves your security posture. By enforcing short certificate lifetimes.
- 16:20Speaker 2: That whole category of operational security risk just kind of
- 16:23Speaker 2: melts away thanks to automation.
- 16:25Speaker 1: That's a really powerful side effect of adopting modern tooling.
- 16:29Speaker 1: A fantastic insight to end on, Thank you for taking
- 16:31Speaker 1: us through this deep dive into trafit.
- 16:33Speaker 2: My pleasure is fascinating technology.
- 16:35Speaker 1: Then thank you our listeners for joining us. We'll catch
- 16:37Speaker 1: you on the next deep dive.