|
| 1 | +# TCP Ingress Setup for Pyrom |
| 2 | + |
| 3 | +## Problem |
| 4 | + |
| 5 | +Pyrom uses **telnet (TCP protocol)**, not HTTP. The standard HTTP Ingress won't work for telnet connections. We need to configure ingress-nginx to route TCP traffic. |
| 6 | + |
| 7 | +## Solution |
| 8 | + |
| 9 | +### 1. Apply the TCP Services ConfigMap |
| 10 | + |
| 11 | +The ConfigMap tells ingress-nginx which TCP ports to route to which services: |
| 12 | + |
| 13 | +```bash |
| 14 | +# Apply via ArgoCD (recommended) |
| 15 | +kubectl apply -f argocd/ingress-nginx-tcp-config.yaml |
| 16 | + |
| 17 | +# Or apply directly |
| 18 | +kubectl apply -f k8s/ingress-nginx/tcp-services-configmap.yaml |
| 19 | +``` |
| 20 | + |
| 21 | +Verify it's applied: |
| 22 | + |
| 23 | +```bash |
| 24 | +kubectl get configmap tcp-services -n ingress-nginx -o yaml |
| 25 | +``` |
| 26 | + |
| 27 | +You should see: |
| 28 | + |
| 29 | +```yaml |
| 30 | +data: |
| 31 | + "1337": "pyrom-prod/pyrom-service:1337" |
| 32 | + "1338": "pyrom-staging/pyrom-service:1337" |
| 33 | + "1339": "pyrom-dev/pyrom-service:1337" |
| 34 | +``` |
| 35 | +
|
| 36 | +### 2. Configure ingress-nginx Controller to Expose TCP Ports |
| 37 | +
|
| 38 | +The ingress-nginx controller Service needs to expose these TCP ports. You have two options: |
| 39 | +
|
| 40 | +#### Option A: Patch the existing ingress-nginx controller Service |
| 41 | +
|
| 42 | +```bash |
| 43 | +kubectl patch service ingress-nginx-controller -n ingress-nginx --type='json' -p='[ |
| 44 | + {"op": "add", "path": "/spec/ports/-", "value": {"name": "pyrom-prod", "port": 1337, "protocol": "TCP", "targetPort": 1337}}, |
| 45 | + {"op": "add", "path": "/spec/ports/-", "value": {"name": "pyrom-staging", "port": 1338, "protocol": "TCP", "targetPort": 1338}}, |
| 46 | + {"op": "add", "path": "/spec/ports/-", "value": {"name": "pyrom-dev", "port": 1339, "protocol": "TCP", "targetPort": 1339}} |
| 47 | +]' |
| 48 | +``` |
| 49 | + |
| 50 | +#### Option B: Edit the ingress-nginx Helm values (if using Helm) |
| 51 | + |
| 52 | +If you installed ingress-nginx via Helm, update the values: |
| 53 | + |
| 54 | +```yaml |
| 55 | +tcp: |
| 56 | + 1337: "pyrom-prod/pyrom-service:1337" |
| 57 | + 1338: "pyrom-staging/pyrom-service:1337" |
| 58 | + 1339: "pyrom-dev/pyrom-service:1337" |
| 59 | +``` |
| 60 | +
|
| 61 | +Then upgrade: |
| 62 | +
|
| 63 | +```bash |
| 64 | +helm upgrade ingress-nginx ingress-nginx/ingress-nginx \ |
| 65 | + -n ingress-nginx \ |
| 66 | + -f ingress-nginx-values.yaml |
| 67 | +``` |
| 68 | + |
| 69 | +### 3. Verify the Setup |
| 70 | + |
| 71 | +Check that the ingress-nginx controller Service has the TCP ports: |
| 72 | + |
| 73 | +```bash |
| 74 | +kubectl get svc ingress-nginx-controller -n ingress-nginx -o yaml | grep -A 5 "1337\|1338\|1339" |
| 75 | +``` |
| 76 | + |
| 77 | +You should see ports 1337, 1338, and 1339 listed. |
| 78 | + |
| 79 | +### 4. Test the Connection |
| 80 | + |
| 81 | +```bash |
| 82 | +# Production |
| 83 | +telnet pyrom.bubtaylor.com 1337 |
| 84 | + |
| 85 | +# Staging |
| 86 | +telnet pyrom-staging.bubtaylor.com 1338 |
| 87 | + |
| 88 | +# Dev |
| 89 | +telnet pyrom-dev.bubtaylor.com 1339 |
| 90 | +``` |
| 91 | + |
| 92 | +## Important Notes |
| 93 | + |
| 94 | +1. **The HTTP Ingress resource** (`pyrom-ingress.yaml`) is **NOT used for telnet connections**. It's only there if you want to serve HTTP content on port 80. |
| 95 | + |
| 96 | +2. **TCP routing is configured via**: |
| 97 | + - ConfigMap: `tcp-services` in `ingress-nginx` namespace |
| 98 | + - Service: `ingress-nginx-controller` must expose the TCP ports |
| 99 | + |
| 100 | +3. **DNS must point to the ingress-nginx controller's external IP** for the hostnames to work. |
| 101 | + |
| 102 | +## Troubleshooting |
| 103 | + |
| 104 | +### Check if ConfigMap is applied |
| 105 | + |
| 106 | +```bash |
| 107 | +kubectl describe configmap tcp-services -n ingress-nginx |
| 108 | +``` |
| 109 | + |
| 110 | +### Check if ingress-nginx controller is using the ConfigMap |
| 111 | + |
| 112 | +```bash |
| 113 | +kubectl get deployment ingress-nginx-controller -n ingress-nginx -o yaml | grep tcp-services |
| 114 | +``` |
| 115 | + |
| 116 | +You should see a reference to the `tcp-services` ConfigMap. |
| 117 | + |
| 118 | +### Check ingress-nginx controller logs |
| 119 | + |
| 120 | +```bash |
| 121 | +kubectl logs -n ingress-nginx deployment/ingress-nginx-controller | grep -i tcp |
| 122 | +``` |
| 123 | + |
| 124 | +### Check if ports are exposed on the Service |
| 125 | + |
| 126 | +```bash |
| 127 | +kubectl get svc ingress-nginx-controller -n ingress-nginx |
| 128 | +``` |
| 129 | + |
| 130 | +Look for ports 1337, 1338, 1339 in the PORT(S) column. |
| 131 | + |
0 commit comments