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

Support cluster-external Kubernetes client. #1159

Merged
merged 2 commits into from
Mar 7, 2017

Conversation

timoreimann
Copy link
Contributor

Detect whether in-cluster or cluster-external Kubernetes client should be used based on the KUBERNETES_SERVICE_{HOST,PORT} environment variables.

My main motivation for this PR was to enable connecting to a Kubernetes cluster via kubectl proxy, which technically is not an in-cluster usage.
Given a bearer token and CA cert files, it's also possible to connect without a proxy while running outside of a cluster.

I will add some more tests once we agree on the general direction of this PR.

/cc @emilevauge @errm @dtomcej

@timoreimann timoreimann changed the title Support cluster-external client. Support cluster-external Kubernetes client. Feb 14, 2017
# Traefik will use env variable KUBERNETES_SERVICE_HOST
# and KUBERNETES_SERVICE_PORT_HTTPS as endpoint
# When deployed as a replication controller in Kubernetes, Traefik will use
# the environment variables KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I changed KUBERNETES_SERVICE_PORT_HTTPS to KUBERNETES_SERVICE_PORT because that's what client-go uses for its check.

@timoreimann timoreimann force-pushed the external-k8s-client branch 3 times, most recently from d44bd8c to e626bc3 Compare February 21, 2017 23:18
@timoreimann
Copy link
Contributor Author

@emile @SantoDE @errm @russ @dtomcej @vdemeester did you have a chance to take a look? Thanks!

@timoreimann timoreimann force-pushed the external-k8s-client branch 2 times, most recently from 4033c03 to 9b64552 Compare February 22, 2017 21:49
@emilevauge emilevauge added this to the 1.3 milestone Feb 23, 2017
@Russell-IO
Copy link
Contributor

I feel like this should be a new backend ? i.e. we should have kubernetes-proxy as well as kubernetes-ingress

@timoreimann
Copy link
Contributor Author

@Russell-IO not sure I understand. You mean backends as in where Traefik sends payload traffic to?

This PR is about how Traefik should connect to the Kubernetes API server.

Maybe I'm missing something.

@dtomcej
Copy link
Contributor

dtomcej commented Feb 23, 2017

I don't think it requires a new backend. Instead of expecting traefik to run IN kubernetes to access the API server, this will allow traefik to run OUTSIDE of kubernetes, and still access the api server. There are some scenarios where this will completely break, such as the API server returning pod network IPs, which may not be accessible from outside the cluster.

Despite that, I think that since it uses the same client, just different config, there should be no need for a different backend or tests, since they should be identical.

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.

My only concern is that this PR expects the endpoint to require TLS-Auth, without any config for non-auth'ed API servers. That being said, people who run k8s clusters without auth should be pummelled.

LGTM :shipit:

@timoreimann
Copy link
Contributor Author

@errm did you have a chance to look at this PR yet? Thanks!

@timoreimann timoreimann force-pushed the external-k8s-client branch 4 times, most recently from 0ff31e6 to f674849 Compare March 3, 2017 20:17
Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

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

Thanks @ttr :)
Could you also complete docs/toml.md?
Other than that, LGTM!

@ttr
Copy link

ttr commented Mar 6, 2017

@emilevauge thanks for checking if I'm alive but I was not near this PR :D

@timoreimann
Copy link
Contributor Author

For a moment, I thought someone had hijacked my Github account. Then I realized the Slack / Github username mismatch. :-)

@ttr I guess that means I have to do the documentation update myself then. ;-)

@ttr
Copy link

ttr commented Mar 6, 2017 via email

@timoreimann
Copy link
Contributor Author

@emilevauge I updated toml.md. WDYT?

Detect whether in-cluster or cluster-external Kubernetes client should
be used based on the KUBERNETES_SERVICE_{HOST,PORT} environment
variables.

Adds bearer token and CA certificate file path parameters.
@timoreimann timoreimann merged commit 920b5bb into traefik:master Mar 7, 2017
@timoreimann timoreimann deleted the external-k8s-client branch March 7, 2017 12:09
emilevauge pushed a commit that referenced this pull request Apr 4, 2017
Detect whether in-cluster or cluster-external Kubernetes client should
be used based on the KUBERNETES_SERVICE_{HOST,PORT} environment
variables.

Adds bearer token and CA certificate file path parameters.
@ldez ldez added kind/enhancement a new or improved feature. area/provider/k8s/ingress labels Apr 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants