Draft: Extending the canary deployment functionality for cookie-based routing
New annotations canary-by-cookie-pattern and canary-by-cookie-value have been added in analogy with similar annotations canary-by-header-pattern and canary-by-header-value
What this PR does / why we need it:
This PR extends the canary deployment functionality for cookie-based routing by adding support for custom values and regex patterns, similar to the existing header-based canary annotations.
Currently, canary-by-cookie only supports the hardcoded values always and never.
This enhancement allows users to define custom cookie values and patterns for more flexible canary routing scenarios.
New Annotations:
-
nginx.ingress.kubernetes.io/canary-by-cookie-value: For exact cookie value matching -
nginx.ingress.kubernetes.io/canary-by-cookie-pattern: For regex pattern matching
Usage Examples:
# Exact value matching
nginx.ingress.kubernetes.io/canary-by-cookie: "stand"
nginx.ingress.kubernetes.io/canary-by-cookie-value: "staging"
# Regex pattern matching
nginx.ingress.kubernetes.io/canary-by-cookie: "user-group"
nginx.ingress.kubernetes.io/canary-by-cookie-pattern: "^(beta|test).*$"
# Backward compatibility (still works)
nginx.ingress.kubernetes.io/canary-by-cookie: "test"
# "always" routes to canary, "never" routes to primary
This implementation maintains full backward compatibility while providing the same flexible routing capabilities for cookies that were already available for headers.
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
CVE Report (Scanner found CVE and adding report) -
Breaking change (fix or feature that would cause existing functionality to change) -
Documentation only
How Has This Been Tested?
-
Added comprehensive unit tests in canary/canary_test.go covering: - Custom cookie value matching
- Regex pattern matching
- Backward compatibility with existing "always"/"never" behavior
- Priority handling (value > pattern > default)
-
Tested in development environment with various cookie value scenarios -
Verified consistency with existing canary-by-header functionality
Checklist:
-
My change requires a change to the documentation. -
I have updated the documentation accordingly. -
I've read the CONTRIBUTION guide -
I have added unit and/or e2e tests to cover my changes. -
All new and existing tests passed.