Skip to content

Commit ebab869

Browse files
charles francis larrieu casiascharles francis larrieu casias
authored andcommitted
simplify and put focus on LoadBalancer instead of Ingress
1 parent a30d8db commit ebab869

File tree

4 files changed

+22
-88
lines changed

4 files changed

+22
-88
lines changed

kubernetes/ingress.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

readme.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This is especially problematic when using a managed Kafka service where the numb
3131
One way to solve this is with host-based routing, also known as Server Name Indication (SNI) routing.
3232
SNI routing allows Gateway expose a single port and route requests to individual brokers based on hostname rather than port ([see SNI routing guide in the docs](https://docs.conduktor.io/gateway/how-to/sni-routing/) for more information).
3333

34-
This tutorial sets up SNI routing specifically for a Kubernetes cluster that exposes Gateway to clients externally via an Ingress.
34+
This tutorial sets up SNI routing specifically for a Kubernetes cluster that exposes Gateway to clients externally via external `LoadBalancer` service.
3535
Kubernetes has its own networking concepts, so it is helpful to see an example for how SNI routing works for Conduktor Gateway deployed on Kubernetes specifically.
3636

3737
Here is an overview of what we will deploy:
@@ -44,7 +44,7 @@ Here is an overview of what we will deploy:
4444
## Setup
4545

4646
To run this all locally, I will use [OrbStack](https://orbstack.dev/), a container and VM management tool for Mac only (sorry!).
47-
I chose OrbStack specifically because this tutorial aims to show how external clients will connect via an Ingress Controller, which can otherwise be difficult to do without either running up a cloud bill or sacrificing authenticity compared to a real-world deployment.
47+
I chose OrbStack specifically because this tutorial aims to show how external clients will connect via an external `LoadBalancer` service, which can otherwise be difficult to do without either running up a cloud bill or sacrificing authenticity compared to a real-world deployment.
4848
OrbStack has some networking magic that makes the entire tutorial run locally without sacrificing authenticity.
4949

5050
1. Install homebrew at [https://brew.sh/](https://brew.sh/).
@@ -108,7 +108,7 @@ This example will use TLS (formerly known as SSL) to encrypt data in transit bet
108108
```
109109
> **IMPORTANT:** Notice the **Subject Alternate Names** (SAN) that allow Gateway to present various hostnames to the client. This is crucial for hostname-based routing, also known as Server Name Indication (SNI) routing. Kafka clients need to know which particular broker or brokers they need to send requests to.
110110
111-
OrbStack handles DNS resolution automatically for us in this example, but in general, DNS must resolve all of these names to the Ingress load balancer IP address. In this case, you would need a DNS record for `gateway.conduktor.k8s.orb.local` and CNAME aliases for each SAN all pointing to the load balancer IP.
111+
OrbStack handles DNS resolution automatically for us in this example, but in general, DNS must resolve all of these names to the external IP address of the `LoadBalancer` service. In this case, you would need a DNS record for `gateway.conduktor.k8s.orb.local` and CNAME aliases for each SAN all pointing to the load balancer IP.
112112
113113
Gateway impersonates brokers by presenting various hostnames to the client -- for example, `brokermain0-gateway.conduktor.k8s.orb.local` to present to the client as the broker with id `0`. The client first needs to trust that the certificate presented by Gateway includes that hostname as a SAN, otherwise TLS handshake will fail. The client then makes its request to `brokermain0-gateway.conduktor.k8s.orb.local`. Gateway receives this request and uses the SNI headers to understand that it needs to forward the request to the Kafka broker with id `0`.
114114
@@ -133,16 +133,14 @@ This example will use TLS (formerly known as SSL) to encrypt data in transit bet
133133
./scripts/start.sh
134134
```
135135

136-
A lot happens here:
136+
Here is what happens:
137137
- Create shared namespace `conduktor`
138138
- Create kubernetes secrets for Kafka
139139
- Create kubernetes secrets for Gateway
140140
- Install Kafka via Bitnami's Kafka helm chart
141141
- Install Gateway via Conduktor's helm chart
142-
- Install `ingress-nginx` Ingress Controller
143-
- Create Ingress for Gateway
144142

145-
Inspect the start script, helm values, and ingress definition.
143+
Inspect the start script and helm values.
146144

147145
### Deploy Console (Optional).
148146

@@ -192,7 +190,7 @@ kafka-broker-api-versions \
192190
--command-config client.properties | grep 9092
193191
```
194192

195-
**NOTE**: The above uses a bit of OrbStack magic to reach an internal service from your laptop.
193+
**NOTE**: The above uses a bit of OrbStack networking magic to reach an internal service from your laptop.
196194
Usually you would only be able to reach an internal service from a pod within the kubernetes cluster.
197195

198196
Look at the hostnames in the metadata returned by Gateway, accessed externally.
@@ -203,7 +201,7 @@ kafka-broker-api-versions \
203201
--command-config client.properties | grep 9092
204202
```
205203

206-
> **NOTE**: OrbStack allows you to reach external services using the `*.k8s.orb.local` domain via Ingress Controller.
204+
> **NOTE**: OrbStack does some magic networking here to allow you to reach external `LoadBalancer` services using the `*.k8s.orb.local` domain.
207205
208206
Create a topic (going through Gateway).
209207

@@ -253,23 +251,24 @@ Clean up kubernetes resources.
253251
kubectl delete namespace conduktor
254252
```
255253

256-
If you also want to delete the Ingress controller,
254+
Or for convenience:
257255

258256
```bash
259257
./scripts/stop.sh
260258
```
261259

262260
## Takeaways
263261

264-
- Your Ingress Controller must support **layer 4 routing** (TCP, not HTTP) with **TLS-passthrough**.
265-
- For AWS EKS this would mean using the Load Balancer Controller with Network Load Balancer (NLB).
262+
- It is highly recommended to configure Conduktor Gateway with an external service of type `LoadBalancer`
263+
- For exmaple, AWS EKS uses the Load Balancer Controller with Network Load Balancer (NLB) to expose `LoadBalancer` services.
264+
- If you have no choice but to use an Ingress Controller, it must support **layer 4 routing** (TCP, not HTTP) with **TLS-passthrough**.
266265
- TLS passthrough is required so that Gateway can use the SNI headers in the TLS handshake to route requests to specific brokers.
267-
- Your client must be able to resolve all hosts advertised by Gateway to the external load balancer. In this example, OrbStack magically points all `*.k8s.orb.local` to the ingress-nginx Ingress Controller, and the Ingress we defined points these hosts to the `gateway-external` service:
266+
- Your client must be able to resolve all hosts advertised by Gateway to the external IP address. In this example, OrbStack magically routes all `*.k8s.orb.local` into the Kubernetes cluster so you don't have to update DNS anywhere, but if you had to, you would need to make sure all of these hostnames map to the external IP of the `LoadBalancer` service:
268267
- `gateway.conduktor.k8s.orb.local`
269268
- `brokermain0-gateway.conduktor.k8s.orb.local`
270269
- `brokermain1-gateway.conduktor.k8s.orb.local`
271270
- `brokermain2-gateway.conduktor.k8s.orb.local`
272-
- As brokers are added, any `brokermain<broker id>-gateway.conduktor.k8s.orb.local` will be routed automatically without requiring changes elsewhere in the infrastructure.
271+
- If you use a wildcard DNS, e.g. `*.conduktor.k8s.orb.local`, then as brokers are added, any `brokermain<broker id>-gateway.conduktor.k8s.orb.local` will be routed automatically without requiring changes elsewhere in the infrastructure.
273272
- Gateway's TLS certificate must include SANs so that it can be trusted by the client when it presents itself as different brokers.
274273
- Alternatively, you could use a certificate with a wildcard CN, which in this case would be `CN=*.conduktor.k8s.orb.local`
275274
- Since we are using an external load balancer, we do not need to use Gateway's internal load balancing mechanism. The external load balancer will distribute load.
@@ -291,6 +290,14 @@ conduktor apply -f resources/producer-safeguard.yml
291290

292291
Try to produce records and then consume `_conduktor_gateway_auditlogs` topic to see policy violation information.
293292

293+
### Consume and produce scripts
294+
295+
Try out the produce / consume scripts. For example:
296+
297+
```
298+
./scripts/consume.sh
299+
```
300+
294301
### kcat commands
295302

296303
The interaction between kcat and OrbStack's ingress controller is a bit buggy. Connections often drop.

scripts/start.sh

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,3 @@ helm upgrade --install \
6767
-f $PWD/helm/gateway-values.yml \
6868
-n conduktor \
6969
gateway conduktor/conduktor-gateway
70-
71-
# Install Ingress Controller
72-
helm upgrade \
73-
--install ingress-nginx ingress-nginx/ingress-nginx \
74-
--set controller.extraArgs.enable-ssl-passthrough="true"
75-
76-
echo "Waiting for the ingress-nginx LoadBalancer IP to be available..."
77-
78-
# Wait for the admission webhook service to have endpoints
79-
while true; do
80-
ENDPOINTS=$(kubectl get endpoints --namespace default ingress-nginx-controller-admission -o jsonpath='{.subsets[0].addresses}')
81-
if [[ -n "$ENDPOINTS" ]]; then
82-
echo "Admission webhook service is ready!"
83-
break
84-
fi
85-
echo "Waiting for admission webhook service to be ready..."
86-
sleep 1
87-
done
88-
89-
# Create Ingress for Gateway
90-
kubectl apply -f $PWD/kubernetes/ingress.yml

scripts/stop.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/bin/bash
22

3-
kubectl delete namespace conduktor
4-
helm uninstall ingress-nginx
3+
kubectl delete namespace conduktor

0 commit comments

Comments
 (0)