Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataclients/kubernetes: append predicates to routes of Ingress/RouteGroup having specific annotation #3328

Merged

Conversation

MustafaSaber
Copy link
Member

@MustafaSaber MustafaSaber commented Dec 4, 2024

The main purpose of this change is to allow skipper operators to dynamically add predicates to routes based on annotations key-value pairs in Kubernetes resources (metadata.annotation). This provides more flexibility in routing configuration without modifying the core Ingress or RouteGroup definitions.

Key changes:

  • Added KubernetesAnnotationPredicates option & -kubernetes-annotation-predicates flag for public hostnames, which can be specified multiple times.
  • Added KubernetesEastWestRangeAnnotationPredicates option & -kubernetes-east-west-range-annotation-predicates flag for internal hostnames (hostnames defined by -kubernetes-east-west-range-domains), which can be specified multiple times.
  • Modified Ingress and RouteGroup clients to apply annotation predicates depending on the host
  • Added test cases for new functionality

Run & test with

➜ ./bin/skipper -kubernetes -kubernetes-annotation-predicates="zalando.org/traffic-disabled=true=False()" -kubernetes-east-west-range-annotation-predicates="zalando.org/traffic-disabled=true=False()"#or
➜ ./bin/routesrv -kubernetes -kubernetes-annotation-predicates="zalando.org/traffic-disabled=true=False()" -kubernetes-east-west-range-annotation-predicates="zalando.org/traffic-disabled=true=False()"

Having both flags with same value will append configured predicates to all routes of Ingress/RouteGroup resources annotated with zalando.org/traffic-disabled: true, routes defined in:

  • The spec.rules section of Ingress resources.
  • Routes specified using the zalando.org/skipper-routes annotation of Ingress resources.
  • The spec.routes section of RouteGroup resources.

@MustafaSaber MustafaSaber added the major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs label Dec 4, 2024
@MustafaSaber MustafaSaber self-assigned this Dec 4, 2024
skipper.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
@MustafaSaber MustafaSaber force-pushed the apply-predicates-on-a-set-of-ingresses-with-annotation branch from c71990f to 5839d17 Compare December 4, 2024 16:48
…roup having specific annotation

The main purpose of this change is to allow skipper operators to dynamically add predicates to routes based on annotations key-value pairs in Kubernetes resources (metadata.annotation). This provides more flexibility in routing configuration without modifying the core Ingress or RouteGroup definitions.

Key changes:
- Added KubernetesAnnotationPredicates option & `-kubernetes-annotation-predicates` flag for public hostnames, which can be specified multiple times.
- Added KubernetesEastWestRangeAnnotationPredicates option & `-kubernetes-east-west-range-annotation-predicates` flag for internal hostnames, which can be specified multiple times.
- Modified Ingress and RouteGroup clients to apply annotation predicates depending on the host
- Added test cases for new functionality

Run & test with

```sh

➜ ./bin/skipper -kubernetes -kubernetes-annotation-predicates="zalando.org/traffic-disabled=true=False()" -kubernetes-east-west-range-annotation-predicates="zalando.org/traffic-disabled=true=False()"
➜ #or
➜ ./bin/routesrv -kubernetes -kubernetes-annotation-predicates="zalando.org/traffic-disabled=true=False()" -kubernetes-east-west-range-annotation-predicates="zalando.org/traffic-disabled=true=False()"
```

Having both flags with same value will append configured predicates to all routes of Ingress/RouteGroup resources annotated with `zalando.org/traffic-disabled: true`, routes defined in:

* The `spec.rules` section of Ingress resources.
* Routes specified using the `zalando.org/skipper-routes` annotation of Ingress resources.
* The `spec.routes` section of RouteGroup resources.

Signed-off-by: Mustafa Abdelrahman <mustafa.abdelrahman@zalando.de>
@MustafaSaber MustafaSaber force-pushed the apply-predicates-on-a-set-of-ingresses-with-annotation branch from 5839d17 to 948c27f Compare December 5, 2024 08:22
@AlexanderYastrebov
Copy link
Member

👍

1 similar comment
@MustafaSaber
Copy link
Member Author

👍

@MustafaSaber MustafaSaber merged commit 8c6bc0a into master Dec 5, 2024
11 of 13 checks passed
@MustafaSaber MustafaSaber deleted the apply-predicates-on-a-set-of-ingresses-with-annotation branch December 5, 2024 08:48
@szuecs
Copy link
Member

szuecs commented Dec 9, 2024

Can you please also write in the description what "internal" hostname means?
There is a flag that defines the east-west domain and that's what we use (I didn't review the code but everything else would be a bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major moderate risk, for example new API, small filter changes that have no risk like refactoring or logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants