Skip to content

Conversation

@devin-ai-integration
Copy link

feat: add IP-based canary traffic routing support IFRFE-0

Summary

This PR implements IP-based canary traffic routing for Flagger's Istio integration, extending the existing webhook mechanism to support consistent hashing of client IPs for gradual canary traffic routing.

Key changes:

  • Added IPRangeRouting configuration to CanarySpec with support for consistent hashing strategies
  • Created IPRangeCalculator utility package for IP range calculation and hash generation
  • Extended confirm-traffic-increase webhook to include IP range metadata in payload
  • Modified IstioRouter to generate IP-based HTTPMatchRequest rules using X-Client-IP-Hash header
  • Added comprehensive test coverage and example configuration

Architecture: Uses header-based approach where gateway/ingress injects X-Client-IP-Hash header with hashed client IP, then Flagger matches against calculated hash ranges for routing decisions.

Review & Testing Checklist for Human

🟡 Medium Risk - 4 items to verify:

  • Header injection dependency: Verify your gateway/ingress can inject the X-Client-IP-Hash header. The implementation assumes this header exists but doesn't automatically configure it - this is a critical integration requirement.

  • Backward compatibility: Test that existing canary deployments without IP routing continue to work normally. Run a standard weighted canary rollout to ensure no regressions.

  • Webhook payload compatibility: Verify that external webhook consumers can handle the new IP range metadata fields in webhook payloads without breaking existing integrations.

  • Routing rule priority: Test scenarios where IP routing, A/B testing, and session affinity overlap to ensure routing precedence is correct and predictable.

End-to-End Test Plan

  1. Deploy the example config (artifacts/examples/istio-ip-routing.yaml)
  2. Configure gateway to inject X-Client-IP-Hash: slot-X header based on client IP hash
  3. Start canary deployment and verify traffic gradually shifts based on IP ranges
  4. Monitor webhook calls receive IP range metadata
  5. Test that same IP consistently routes to same destination

Notes

- Add IPRangeRouting configuration to CanarySpec with consistent hashing support
- Implement IPRangeCalculator utility for IP range calculation and hash generation
- Extend confirm-traffic-increase webhook with IP range metadata
- Add IP range matching in IstioRouter using X-Client-IP-Hash header
- Support configurable hash functions (fnv, md5, sha256) and slot counts
- Add comprehensive test coverage for IP routing utilities
- Include example configuration for IP-based canary routing
- Maintain backward compatibility with existing webhook and routing functionality

Co-Authored-By: Yunpeng Han <[email protected]>
@devin-ai-integration
Copy link
Author

Original prompt from Yunpeng
1. 使用flagger的istio-canary分支
2. 检查项目代码目前flagger支持的动态流量规则是随机流量的百分比
3. 如果需要支持在Canary过程根据客户端Ip进行Canary流量的扩展,应该如何设计和实现?
4. 比如 按照ip把10%范围的ip给路由到Canary实例,后续再把10%范围的ip给路由到Canary实例
5. 后续能否扩展为参数,指定请求头和值范围,根据一致性hash或者slot方式,依次扩大条件


You only need to look in the following repo: MoeGolibrary/flagger

@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Implement attribute range routing for Istio and Kubernetes
- Add new configuration options to Canary CRD
- Create HeaderRangeCalculator for routing decisions- Update IstioRouter to handle attribute range routing
- Add tests for new routing functionality
- Add IPRangeRouting and AttributeRangeRouting configurations to Canary CRD
- Implement IP and attribute-based routing logic in Istio router
- Update deployment controller to handle new routing configurations
- Add tests for new routing features
- Add IPRangeRouting and AttributeRangeRouting configurations to Canary CRD
- Implement IP and attribute-based routing logic in Istio router
- Update deployment controller to handle new routing configurations
- Add tests for new routing features
@yunpeng-moego yunpeng-moego force-pushed the istio-canary branch 2 times, most recently from d68f2f0 to a579fc3 Compare September 21, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants