Support canary routing based on multiple upstream according to weight and total weight
lianglli opened this issue · 1 comments
lianglli commented
Support canary routing based on multiple upstream according to weight and total weight
lianglli commented
Main ingress with nginx.ingress.kubernetes.io/canary-weight-total: "1000"
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/canary-weight-total: "1000"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
creationTimestamp: "2023-10-30T09:33:15Z"
generation: 1
name: tengine-ingress-echo-ing
namespace: default
resourceVersion: "28591137"
uid: 34ff03fa-0e52-4ff4-b992-3b3625664cba
spec:
ingressClassName: opensource-ingress
rules:
- host: echo.w1.com
http:
paths:
- backend:
service:
name: tengine-ingress-echo-service
port:
number: 80
path: /
pathType: Prefix
tls:
- hosts:
- echo.w1.com
secretName: https-server-1
status:
loadBalancer:
ingress:
- {}
Canary ingress with nginx.ingress.kubernetes.io/canary-weight: "20"
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "20"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
creationTimestamp: "2023-11-01T11:46:03Z"
generation: 2
name: tengine-ingress-hello-weight-ing
namespace: default
resourceVersion: "28589548"
uid: ea56cd6a-7d65-48fd-affd-f102199c12ff
spec:
ingressClassName: opensource-ingress
rules:
- host: echo.w1.com
http:
paths:
- backend:
service:
name: tengine-ingress-hello5-service
port:
number: 80
path: /
pathType: Prefix
tls:
- hosts:
- echo.w1.com
secretName: https-server-1
status:
loadBalancer:
ingress:
- {}
Expect results:
20 / 1000 ---> upstream tengine-ingress-hello5-service
980 /1000 ---> upstream tengine-ingress-echo-service
for i in {1..1000}; do curl -i -k https://echo.w1.com ; done > weight.txt
984 times: ups-target-key: default-tengine-ingress-echo-service-80
16 times: ups-target-key: default-tengine-ingress-hello5-service-80