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

Allow any kubernetes ingressClass value #3516

Merged
merged 5 commits into from
Jun 22, 2018
Merged

Allow any kubernetes ingressClass value #3516

merged 5 commits into from
Jun 22, 2018

Conversation

rtreffer
Copy link
Contributor

Migrating from one ingress controller to another can require an intentional collision of ingressClass values.

What does this PR do?

The ingressClass in kubernetes can be used to run multiple ingress controllers or to otherwise split the defined ingresses into multiple sets.
The values that Traefik would allow for an ingress class must start with traefik.

This patch removes that limitation as

  1. The name is user defined anyway
  2. It makes migrations from other ingress controllers harder

Motivation

I am trying to move a larger cluster over to traefik and our ingress classes were split into internal and external. Traefik can't handle these names which makes a migration harder than necessary.

More

  • Added/updated tests
  • Added/updated documentation

Additional Notes

The key change is the removal of a few lines in provider/kubernetes/kubernetes.go

@timoreimann
Copy link
Contributor

The prefix restriction was originally introduced along #2222. Back then, we concluded that requiring the prefix would provide some basic means of protection against accidentally hooking up to another Ingress controller (by means of a poor man's "namespacing" or scoping).

@rtreffer and I had a discussion on Slack about the subject preceding this PR. Given the use case he mentioned, I feel that our original assumption about protecting with the help of the prefix does not hold anymore (or never did :-) ). I feel we should drop it in order to facilitate smooth transitions from one controller to another.

@dtomcej / @containous/kubernetes WDYT?

@dtomcej
Copy link
Contributor

dtomcej commented Jun 19, 2018

In 1.7, we introduce dynamic namespacing, and ingress status updates.

Being that we are now modifying the ingress objects, allowing users to set "nginx" as the ingress class could lead to problems, if there are multiple controllers trying to satisfy the ingress...however, the user is ultimately the cause.

I guess the other issue was at the time, we didn't support many of the annotations, and we wanted to ensure that users knew that they would have to modify ingresses that were written for other controllers. Now we support a much larger annotation set, so 🤷‍♂️

I'm willing to allow it to be more flexible, and let users "figure it out"...


It is also possible to set the `ingressClass` option in Træfik to a particular value.
If that's the case and the value contains a `traefik` prefix, then only those Ingress objects matching the same value will be processed.
It is also possible to set the `ingressClass` option in Træfik to a particular value. Træfik will only process matching Ingress objects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a note that having multiple controllers satisfying an ingress can lead to unintended behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a !!! note underneath with a recommendation to prefix ingressClasses.

iAnnotation(annotationKubernetesIngressClass, "custom"),
iRules(
iRule(
iHost("herp"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace the herp/derp with foo/bar or foo/path to match the format of other tests?

backends(
backend("herp/derp",
servers(
server("http://example.com", weight(1)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update this to be an IP/Port combo instead of a URL?
Currently that is only implemented as a URL when its an externalName service IIRC

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall (bar some extra manual testing maybe). Just a minor thing:

@rtreffer could you please also drop the restricting note from the parameter documentation in /docs/configuration/backends/kubernetes.md?

Thanks.

@@ -54,8 +54,6 @@ See also [Kubernetes user guide](/user-guide/kubernetes).
# If the parameter is non-empty, only Ingresses containing an annotation with the same value are processed.
# Otherwise, Ingresses missing the annotation, having an empty value, or the value `traefik` are processed.
#
# Note : `ingressClass` option must begin with the "traefik" prefix.
#
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timoreimann dropped.

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor nit-picks left, but otherwise looks good.

@@ -863,6 +863,10 @@ If the annotation is missing, contains an empty value, or the value `traefik`, t
It is also possible to set the `ingressClass` option in Træfik to a particular value. Træfik will only process matching Ingress objects.
For instance, setting the option to `traefik-internal` causes Træfik to process Ingress objects with the same `kubernetes.io/ingress.class` annotation value, ignoring all other objects (including those with a `traefik` value, empty value, and missing annotation).

!!! note
Letting multiple ingress controllers handle the same ingress objects can lead to uninteded behavior.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: _ uninteded_ -> _ unintended_

@@ -863,6 +863,10 @@ If the annotation is missing, contains an empty value, or the value `traefik`, t
It is also possible to set the `ingressClass` option in Træfik to a particular value. Træfik will only process matching Ingress objects.
For instance, setting the option to `traefik-internal` causes Træfik to process Ingress objects with the same `kubernetes.io/ingress.class` annotation value, ignoring all other objects (including those with a `traefik` value, empty value, and missing annotation).

!!! note
Letting multiple ingress controllers handle the same ingress objects can lead to uninteded behavior.
It is recommended to prefix all ingressClass values with traefik to avoid unintended collisions with other ingress implementations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you backtick traefik so that it renders as traefik?

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with the addressing of my comments; will @dtomcej cover his.

Copy link
Contributor

@m3co-code m3co-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the contribution! :-)

@mmatur mmatur added this to the 1.7 milestone Jun 22, 2018
Copy link
Contributor

@dtomcej dtomcej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants