argoproj / argo-rollouts

Progressive Delivery for Kubernetes
https://argo-rollouts.readthedocs.io/
Apache License 2.0
2.73k stars 851 forks source link

Allow ALB traffic management with more than one routing condition #2998

Open mvgmb opened 1 year ago

mvgmb commented 1 year ago

Summary

AWS ALB provides a method for specifying routing conditions by adding a condition annotation: alb.ingress.kubernetes.io/conditions.${conditions-name}.

Some scenarios require more than one condition to route traffic. The conditions-name in the annotation can be a either real serviceName or an annotation-based action name, i.e., the service does not need to exist. If it does not exist, you must specify an action annotation to be able to route its traffic: alb.ingress.kubernetes.io/actions.${action-name}.

Currently, argo-rollouts' traffic management only manages the action related to the rollout service, which uses the root/stable service name as the action name: alb.ingress.kubernetes.io/actions.<SERVICE-NAME>. This means I can't use the more than one condition per service since it needs to be named after the root/stable service.

Use Cases

Given I want to route requests based on their header value from the /path1 and requests based on their method to the /path2, the setup would look like this:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo
  annotations:
    alb.ingress.kubernetes.io/conditions.http-header: '[{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "HeaderName", "values":["HeaderValue1"]}}]'
    alb.ingress.kubernetes.io/conditions.http-request-method: '[{"field":"http-request-method","httpRequestMethodConfig":{"Values":["POST"]}}]'
spec:
  rules:
    - host: www.example.com
      http:
        paths:
          - backend:
              serviceName: http-header # does not match the service name, requires actions annotation
              servicePort: use-annotation
            path: /path1
          - backend:
              serviceName: http-request-method # does not match the service name, requires actions annotation
              servicePort: use-annotation
            path: /path2
          - backend:
              serviceName: example
              servicePort: 80
            path: /*

If the Rollout knew which actions to take into account, it could take care of each condition's actions annotation weight management, e.g.:

apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: demo
spec:
  strategy:
    canary:
      pingPong:
        pingService: demo-ping
        pongService: demo-pong
      trafficRouting:
        alb:
          ingress: demo
          servicePort: 80
          actionNames: # this field specifies a list of action names argo-rollouts should manage
            - http-header
            - http-request-method

By doing this, argo-rollouts would add an actions annotation for each condition:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo
  annotations:
    alb.ingress.kubernetes.io/actions.http-header: '{"Type":"forward","ForwardConfig":{"TargetGroups":[{"ServiceName":"demo-pong","ServicePort":"80","Weight":80},{"ServiceName":"demo-ping","ServicePort":"80","Weight":20}]}}'
    alb.ingress.kubernetes.io/actions.http-request-method: '{"Type":"forward","ForwardConfig":{"TargetGroups":[{"ServiceName":"demo-pong","ServicePort":"80","Weight":80},{"ServiceName":"demo-ping","ServicePort":"80","Weight":20}]}}'
    alb.ingress.kubernetes.io/conditions.http-header: '[{"field":"http-header","httpHeaderConfig":{"httpHeaderName": "HeaderName", "values":["HeaderValue1"]}}]'
    alb.ingress.kubernetes.io/conditions.http-request-method: '[{"field":"http-request-method","httpRequestMethodConfig":{"Values":["POST"]}}]'
github-actions[bot] commented 11 months ago

This issue is stale because it has been open 60 days with no activity.