Skip to content

Commit

Permalink
Add traefik details and yaml files
Browse files Browse the repository at this point in the history
  • Loading branch information
CJLove committed Mar 3, 2024
1 parent 303ec4a commit 88c3aae
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# ingress-playground

TCP and UDP services for deployment in Kubernetes to explore ingress
TCP and UDP services for deployment in Kubernetes to explore ingress

## Deployment
```bash
kubectl apply -f tcp-server-ss.yaml
kubectl apply -f udp-server-ss.yaml
```

## Minikube nginx ingress controller

Create ingress-nginx-controller-patch.yaml
```yaml
spec:
template:
spec:
containers:
- name: controller
ports:
- containerPort: 5000
hostPort: 5000
protocol: UDP
- containerPort: 5001
hostPort: 5001

```

Configure ingress
```bash
kubectl patch configmap udp-services -n ingress-nginx --patch '{"data":{"5000":"default/udp-server-0-service:5000"}}'
kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"5001":"default/tcp-server-0-service:5001"}}'
kubectl patch deployment ingress-nginx-controller -n ingress-nginx --patch "$(cat ingress-nginx-controller-patch.yaml)" -n ingress-nginx
```

Reach services on minikube ip (e.g. 192.168.49.2)

## K3S With Traefic

- On K3S master, create file `/var/lib/rancher/k3s/server/manifests/traefik-config.yaml` with additional ports to expose. See example in traefik directory

- Create instances of IngressRouteTCP or IngressRouteUDP as needed
```bash
kubectl apply -f ingressRouteTcp.yaml
kubectl apply -f ingressRouteUdp.yaml
```

- Services should be available; check details from the `traefik` service in the `kube-system` namespace, as they may be on a load balancer IP if something like `metallb` is in use.

14 changes: 14 additions & 0 deletions traefik/ingressRouteTcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
name: tcp-server
namespace: default
spec:
entryPoints:
- tcp-server
routes:
- match: HostSNI(`*`)
services:
- name: tcp-server-0-service
port: 5001
13 changes: 13 additions & 0 deletions traefik/ingressRouteUdp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteUDP
metadata:
name: udp-server
namespace: default
spec:
entryPoints:
- udp-server
routes:
- services:
- name: udp-server-0-service
port: 5000
19 changes: 19 additions & 0 deletions traefik/traefik-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: helm.cattle.io/v1
kind: HelmChartConfig
metadata:
name: traefik
namespace: kube-system
spec:
valuesContent: |-
ports:
udp-server:
port: 5000
expose: true
exposedPort: 5000
protocol: UDP
tcp-server:
port: 5001
expose: true
exposedPort: 5001
protocol: TCP

0 comments on commit 88c3aae

Please sign in to comment.