mirror of
https://github.com/sredevopsorg/deepseek-kubernetes-sandbox.git
synced 2026-11-03 01:13:24 +00:00
feat(gateway-api): expose dsh-gateway externally via Traefik Gateway API (#12)
Add Gateway and HTTPRoute manifests to route external traffic to the dsh-gateway service (dsh-demo:8080). - Gateway dsh-gateway: HTTPS listener with TLS termination against a dsh-demo-tls cert secret. - HTTPRoute dsh-gateway: hostname -> dsh-gateway:8080. - Example TLS secret manifest + README with apply/verify/rollback. Co-authored-by: SREDevOpsAgents <agents@sredevops.org>
This commit is contained in:
committed by
GitHub
parent
0a61e57db4
commit
7d3faf07dd
49
gateway-api/dsh-demo/README.md
Normal file
49
gateway-api/dsh-demo/README.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Gateway API — external access for `dsh-demo/dsh-gateway`
|
||||
|
||||
Exposes the `dsh-gateway` service (`dsh-demo`, port `8080`) outside the cluster
|
||||
using the Kubernetes Gateway API (Traefik Gateway controller).
|
||||
|
||||
## Resources
|
||||
|
||||
| File | Kind | Purpose |
|
||||
|---|---|---|
|
||||
| `gateway.yaml` | `Gateway` | HTTPS listener with TLS termination |
|
||||
| `httproute.yaml` | `HTTPRoute` | Routes the hostname → `dsh-gateway:8080` |
|
||||
| `tls-secret.yaml.example` | `Secret` | Example TLS cert secret (not applied as-is) |
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Hostname** — replace the placeholder in `httproute.yaml` with the real FQDN.
|
||||
2. **TLS secret** — create `dsh-demo-tls` in `dsh-demo` (see `tls-secret.yaml.example`).
|
||||
3. **Ingress and DNS** — configure the upstream ingress and public DNS for the hostname.
|
||||
|
||||
## Apply
|
||||
|
||||
```bash
|
||||
kubectl diff -f gateway-api/dsh-demo/
|
||||
kubectl apply -f gateway-api/dsh-demo/ --dry-run=server
|
||||
kubectl apply -f gateway-api/dsh-demo/
|
||||
```
|
||||
|
||||
> ⚠️ A write-enabled kubeconfig is required to create Gateways and HTTPRoutes.
|
||||
|
||||
## Verify
|
||||
|
||||
```bash
|
||||
kubectl get gateway dsh-gateway -n dsh-demo -o yaml # expect Programmed=True
|
||||
kubectl get httproute -n dsh-demo -o wide # expect Accepted
|
||||
kubectl get endpoints dsh-gateway -n dsh-demo # backend present
|
||||
kubectl -n dsh-demo exec deploy/dsh-gateway -- wget -qO- http://localhost:8080/healthz
|
||||
```
|
||||
|
||||
## Rollback
|
||||
|
||||
```bash
|
||||
kubectl delete -f gateway-api/dsh-demo/
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- No `ReferenceGrant` is required: the Gateway, HTTPRoute, and backend Service are
|
||||
all in `dsh-demo`.
|
||||
- The backend (`dsh-gateway`) serves plain HTTP on 8080 and has a `/healthz` probe.
|
||||
20
gateway-api/dsh-demo/gateway.yaml
Normal file
20
gateway-api/dsh-demo/gateway.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: dsh-gateway
|
||||
namespace: dsh-demo
|
||||
labels:
|
||||
app.kubernetes.io/part-of: dsh-demo
|
||||
spec:
|
||||
gatewayClassName: traefik
|
||||
listeners:
|
||||
- name: https
|
||||
port: 8443
|
||||
protocol: HTTPS
|
||||
tls:
|
||||
mode: Terminate
|
||||
certificateRefs:
|
||||
- name: dsh-demo-tls
|
||||
allowedRoutes:
|
||||
namespaces:
|
||||
from: Same
|
||||
19
gateway-api/dsh-demo/httproute.yaml
Normal file
19
gateway-api/dsh-demo/httproute.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: dsh-gateway
|
||||
namespace: dsh-demo
|
||||
labels:
|
||||
app.kubernetes.io/part-of: dsh-demo
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: dsh-gateway
|
||||
namespace: dsh-demo
|
||||
sectionName: https
|
||||
hostnames:
|
||||
# TODO: replace with the actual public FQDN once provided.
|
||||
- dsh-demo.example.com
|
||||
rules:
|
||||
- backendRefs:
|
||||
- name: dsh-gateway
|
||||
port: 8080
|
||||
17
gateway-api/dsh-demo/tls-secret.yaml.example
Normal file
17
gateway-api/dsh-demo/tls-secret.yaml.example
Normal file
@@ -0,0 +1,17 @@
|
||||
# EXAMPLE ONLY — do not apply as-is.
|
||||
#
|
||||
# Copy to tls-secret.yaml and populate with real base64-encoded PEM material,
|
||||
# then apply. The secret must live in the dsh-demo namespace and be named
|
||||
# "dsh-demo-tls" (referenced by gateway.yaml).
|
||||
#
|
||||
# kubectl -n dsh-demo create secret tls dsh-demo-tls \
|
||||
# --cert=tls.crt --key=tls.key --dry-run=client -o yaml > tls-secret.yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: dsh-demo-tls
|
||||
namespace: dsh-demo
|
||||
type: kubernetes.io/tls
|
||||
data:
|
||||
tls.crt: <base64-encoded-certificate>
|
||||
tls.key: <base64-encoded-private-key>
|
||||
Reference in New Issue
Block a user