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

kubernetes: sort and uniq TLS secrets #4307

Merged
merged 3 commits into from
Dec 20, 2018
Merged

Conversation

zarqman
Copy link
Contributor

@zarqman zarqman commented Dec 17, 2018

What does this PR do?

This PR sorts and de-dups the set of TLS certs that come from Kubernetes Ingress objects. When not sorted consistently, Traefik believes the config has changed and unnecessarily reloads the server configuration.

Fixes #4187. Note that the issue is simply 2+ Ingress-referenced TLS certs which just happens to be common when using wildcards. Wildcards are not the actual issue.
Fixes #4245.

Motivation

Fixing a bug. 😄

More

  • Added/updated tests

Additional Notes

Background: Kubernetes returns the list of Ingress objects in varied order. Traefik processes the frontends and backends according to named keys (a standard dict/hash), which avoids any ordering issue.

In contrast, Traefik looks up the TLS secrets and simply appends them to an array. Because the Ingresses vary in order, so does the array of TLS secrets. This only applies to TLS certs referenced as part of an Ingress, since it's all local to the Kubernetes provider.

Further, if a given secret is referenced by more than one Ingress (typical when using wildcard or SAN certs), the cert is appended to the TLS array multiple times. This results in unnecessary warnings "Into EntryPoint https, try to add certificate for domains which already have this certificate ...".

This PR sorts and de-dups the TLS certs by the Secret name. To accommodate configurations where Ingresses have different entrypoint lists, it also merges (and sorts) those.

It has been tested on our staging server which has a rather complex set of Ingresses. So far, all unnecessary reloads are gone.

provider/kubernetes/kubernetes.go Outdated Show resolved Hide resolved
provider/kubernetes/kubernetes.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ldez ldez left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

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

LGTM

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.

6 participants