Apache APISIX on Kubernetes with Redis
Apache APISIX is a high-performance, cloud-native API gateway built on Nginx + LuaJIT. Unlike plain Nginx, APISIX has a live Admin API — you add routes, plugins, and upstreams at runtime with no reloads and no restarts.Architecture
| Component | Role | NodePort |
|---|---|---|
| APISIX Gateway | Proxies all traffic, runs plugins | 30080 |
| APISIX Admin API | Configure routes/upstreams at runtime | 30180 |
| APISIX Dashboard | Web UI — manage everything visually | 30900 |
| Prometheus Metrics | Per-route metrics scraped by Prometheus | 30091 |
| Redis | Cache + rate-limit counter store | cluster-internal |
| etcd | APISIX config store (watched live) | cluster-internal |
Access Points
| What | URL |
|---|---|
| Gateway | http://109.199.120.120:30080 |
| Admin API | http://109.199.120.120:30180 |
| Dashboard UI | http://109.199.120.120:30900 |
| Metrics | http://109.199.120.120:30091/apisix/prometheus/metrics |
admin / coderz123
File Structure
All manifests live in/opt/coderz/k8s/apisix/:
Deploy
- Apply all manifests in order
- Wait for every pod to be ready
- Run
configure-routes.pyto register upstreams and routes via the Admin API - Print all access URLs
Routes Configured
configure-routes.py registers these routes automatically:
| Route | Upstream | Cache |
|---|---|---|
GET /dotnet/* | .NET API :5050 | Redis (1 hour TTL) |
GET /webapi/* | Web API :8888 | Redis (1 hour TTL) |
GET /web/* | coderz-web k3s service | Redis (1 hour TTL) |
GET /cache/keys | — | Lists all Redis cache keys |
Global Plugins (on every route)
| Plugin | What it does |
|---|---|
loki-logger | Sends structured JSON access logs to Loki |
prometheus | Per-route metrics exposed on :30091 |
request-id | Injects X-Request-Id on every request and response |
Per-Route Plugins
| Plugin | What it does |
|---|---|
serverless-pre-function | Checks Redis before proxying — returns cached response on HIT |
serverless-post-function | Stores upstream 200 responses in Redis (TTL 1 hour) |
response-rewrite | Adds X-Gateway: APISIX and X-Cache-Backend: Redis headers |
cors | Opens CORS for all origins |
Redis Cache Behavior
cache:<METHOD>:<URI>
Inspect live cache:
Dashboard UI
Openhttp://109.199.120.120:30900 and log in with admin / coderz123.
From the Dashboard you can:
| Section | What you can do |
|---|---|
| Route | Create/edit routes, attach plugins, set URI patterns |
| Upstream | Add backend services, configure load balancing |
| Service | Reusable upstream + plugin bundles |
| Consumer | Create API key or JWT users with per-user rate limits |
| Plugin | Enable/disable plugins globally or per-route |
| SSL | Upload TLS certificates |
Smoke Tests
Run the test job
What it tests
| Test | Checks |
|---|---|
| Admin API reachable | GET /apisix/admin/routes returns 200 |
| Route registration | PUT /routes/999 returns 200 or 201 |
| Proxy request | Request through gateway returns 200 |
| Custom headers | X-Gateway: APISIX header present |
| Rate limiting | 429 fires after 5 requests in 60s window |
| Cache inspector | GET /cache/keys returns 200 |
| Prometheus metrics | Metrics endpoint returns 200 |