# Subset Load Balancing
#
# Filters endpoints by metadata labels and applies an inner strategy
# within the matching subset. Useful for canary deployments, GPU-type
# routing, or version-based traffic splitting.
#
# In this example, only endpoints labeled version=canary receive traffic.
# If no endpoints match, the fallback_policy determines behavior:
#   - any_endpoint: use all endpoints regardless of metadata
#   - no_endpoint: return 503
#
# Usage:
#   cargo run -p praxis-proxy -- -c examples/configs/traffic-management/subset-lb.yaml
#   curl http://localhost:8080/

listeners:
  - name: default
    address: "127.0.0.1:8080"
    filter_chains:
      - main

filter_chains:
  - name: main
    filters:
      - filter: router
        routes:
          - path_prefix: "/"
            cluster: backend

      - filter: load_balancer
        clusters:
          - name: backend
            load_balancer_strategy:
              subset:
                selector:
                  version: "canary"
                inner_strategy: round_robin
                fallback_policy: any_endpoint
            endpoints:
              - address: "127.0.0.1:3001"
                metadata:
                  version: "stable"
              - address: "127.0.0.1:3002"
                metadata:
                  version: "canary"
              - address: "127.0.0.1:3003"
                metadata:
                  version: "canary"

insecure_options:
  allow_private_endpoints: true # example proxies to local backends
