Ingress Rule route to multiple backend service ports. #2481
-
Hello, and thank you for accepting my inquiry. General information:kubernetes version: v1.23.3 I have the following service configuration: apiVersion: v1
kind: Service
metadata:
name: myservice
namespace: testing
labels:
app: myservice
spec:
ports:
- name: http-5591
port: 5591
protocol: TCP
targetPort: 5591 ## this is one of the ports the application is running
- name: http-5592
port: 5592
protocol: TCP
targetPort: 5592 ## this is another port the application is running And the respective Ingress config: ApiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myservice
namespace: testing
annotations:
nginx.org/redirect-to-https: "True"
tls:
- hosts:
- myservice.example.com
secretName: wildcard-example-com
rules:
- host: myservice.example.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: myservice
port:
number: 5591
backend:
service:
name: myservice
port:
number: 5592 What I am trying to do is Load Balance the requests to myservice.example.com to the same backend service, but by using multiple ports (5591 and 5592 in this example). paths:
- pathType: Prefix
path: "/" The generated config is: server 10.244.1.2:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.11.10:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.18.28:5592 max_fails=1 fail_timeout=10s max_conns=0; Targeted config (what I am trying to achieve) is: server 10.244.1.2:5591 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.11.10:5591 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.18.28:5591 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.1.3:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.11.13:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.18.38:5592 max_fails=1 fail_timeout=10s max_conns=0;` I have tried several approaches, but I always seem to fall into a duplication of some sort. I also tried with VirtualServer: apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: myservice-vs
namespace: testing
spec:
host: myservice.example.com
tls:
secret: wildcard-example-com
upstreams:
- name: myservice-stream
service: myservice-5591
port: 5591
service: myservice-5592
port: 5592
routes:
- path: /
action:
pass: myservice-stream Again, one of the two services gets ignored: upstream vs_myservice {
zone vs_myservice 256k;
random two least_conn;
server 10.244.1.3:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.11.13:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.18.38:5592 max_fails=1 fail_timeout=10s max_conns=0 Desired Config: upstream vs_myservice {
zone vs_myservice 256k;
random two least_conn;
server 10.244.1.2:5591 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.11.10:5591 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.18.28:5591 max_fails=1 fail_timeout=10s max_conns=0
server 10.244.1.3:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.11.13:5592 max_fails=1 fail_timeout=10s max_conns=0;
server 10.244.18.38:5592 max_fails=1 fail_timeout=10s max_conns=0 Is there any way I can achieve the desired configuration? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
See #2493 |
Beta Was this translation helpful? Give feedback.
See #2493