Skip to content

Instantly share code, notes, and snippets.

@moonape1226
Last active March 14, 2022 10:46
Show Gist options
  • Save moonape1226/7b4e8abe58c275fc345c6b7f7db5f47e to your computer and use it in GitHub Desktop.
Save moonape1226/7b4e8abe58c275fc345c6b7f7db5f47e to your computer and use it in GitHub Desktop.
a k8s ingress manifest to achieve query-based routing with ALB ingress controller
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/actions.rule-path-1: >
{"type": "forward", "forwardConfig": {"targetGroups": [{"serviceName": "nginx-path1", "servicePort": 80, "weight": 100}]}}
alb.ingress.kubernetes.io/conditions.rule-path-1: >
[{"Field":"query-string","QueryStringConfig":{"Values":[{"Key":"path","Value":"nginx1"}]}}]
alb.ingress.kubernetes.io/actions.rule-path-2: >
{"type": "forward", "forwardConfig": {"targetGroups": [{"serviceName": "nginx-path2", "servicePort": 80, "weight": 100}]}}
alb.ingress.kubernetes.io/conditions.rule-path-2: >
[{"Field":"query-string","QueryStringConfig":{"Values":[{"Key":"path","Value":"nginx2"}]}}]
name: query-path-test-path
namespace: test
spec:
rules:
- host: query-routing.exmaple.com
http:
paths:
- path: /
backend:
service:
name: rule-path-1
port:
name: use-annotation
pathType: ImplementationSpecific
- path: /
backend:
service:
name: rule-path-2
port:
name: use-annotation
pathType: ImplementationSpecific
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment