I have a deployment that can have X replica (autoscaling). The pods are called e.g. "dp-1", "dp-2" etc.
Each of these pods has (logically) the same configuration and tasks, but it is important to be able to access the WebUI of the individual pod.
This pod has two important ports, each of which fulfils a different task: 8080 WebUI and 5550 SOMA.
Since there may be more replicas than planned at any time, I would like to define a FQDN to be able to address the corresponding service/port and the respective pod using the context root.
I have already written a deployment that can dynamically create an ingress and service for this pod based on the number of pods (and can also remove it again if there are fewer again).
However, I still have problems with the reverse proxy. When I call my backend on port 8080 normally, I get the contextroot "/login.html". This is also hardwired, I can't adjust anything there. This means that when I call up "https://dp.pod.com", for example, the browser displays "https://dp.pod.com/login.htlm".
However, I would now like to be able to call up the corresponding pod "dp-2" using the context root "/2/webgui" and thus receive "https://dp.pod.com/2/webgui/login.html" in the browser (and all possible other links also land behind it).
I have already tried the wildest annotations, location snippets, etc. However, I never get the desired result.
Currently, my Ingress template looks like this:
apiVersion: v1
kind: ConfigMap
metadata:
name: dp-custom-ingress-manager-templates
namespace: utils
data:
ingress-template.yaml: |
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dp-admin-{{pod_number}}
namespace: dp
annotations:
nginx.ingress.kubernetes.io/backend-protocol: HTTPS
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
ingressClassName: nginx
tls:
- hosts:
- dp.pod.com
secretName: dp-endpoint
rules:
- host: dp.pod.com
http:
paths:
- path: /({{pod_number}}/webui/.*)
pathType: Prefix
backend:
service:
name: dp-custom-{{pod_number}}
port:
number: 9090
- path: /({{pod_number}}/soma/.*)
pathType: Prefix
backend:
service:
name: dp-custom-{{pod_number}}
port:
number: 5550
I think I want to set up a simple reverse proxy here.... but somehow I just can't manage it :-(