We have multiple namespaces running in a single cluster and have 2 issues:
-
Re-use of IP addresses
** Azure seems to re-allocate IP addresses
** the targets table in the kong database has IP addresses
** if the IP is reused (eg after scale down, upgrade, scale up) these can point to other namespaces
** when this happens the routing fails horribly (requests routed to the wrong service) -
Other namespaces having ingress in each cluster - this seems to be the same as:
Deploy Multiple Kong Instances on different namespaces in a k8s cluster
Is there any advice on the first one ?
Ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ams-web # Looks like this has to match the service
namespace: my-namespace
annotations:
...
konghq.com/protocols: http # Upstream protocol
spec:
ingressClassName: kong
rules:
- http:
paths:
- path: /ams-web/
pathType: Prefix
backend:
service:
name: ams-web
port:
number: 8080
- path: /ams-web
pathType: Exact
backend:
service:
name: ams-web
port:
number: 8080
---
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: ams-web-kong-ingress
namespace: my-namespace
upstream:
algorithm: consistent-hashing
hash_on: cookie
hash_on_cookie: X-AMS-KONG-COOKIE
hash_on_cookie_path: /
...
route:
methods:
- POST
- PUT
- GET
- DELETE
regex_priority: 0
strip_path: false
preserve_host: true
protocols:
- http
- https
Deployment
kind: Deployment
apiVersion: apps/v1
metadata:
name: ams-web
namespace: my-namespace
labels:
api_version: v2
app: ams-web
annotations:
spec:
replicas: 1
selector:
matchLabels:
app: ams-web
template:
metadata:
labels:
app: ams-web
version: v1
spec:
volumes:
...
containers:
- name: ams-web-blue
image: kamelosoacr.azurecr.io/ams-web:7.7.6.15-SNAPSHOT
ports:
- containerPort: 8080
protocol: TCP
env:
...
resources:
...