-
-
Notifications
You must be signed in to change notification settings - Fork 314
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
Make Client configurable with Layers #539
Comments
Yeah. Appreciate you writing this down. It seems like a very sensible plan overall. The For clarity; are you thinking of splitting the |
Cool, I started doing TLS part last night. With this change, we can allow When both TLS features are enabled, I'll open a PR later today.
The name is misleading, so it will be renamed. |
Released in 0.56. Added most of the changes from the main body of the PR as the changelog as this one was huge 💯 |
kube::Client
now takesService<http::Request<hyper::Body>>
, so users can create a client with custom Service. However, to make this useful beyond simple testing, we need to provide methods to create parts of the default Service (mainly TLS and auth providers).The goal is to allow full customization at both
connector
andservice
levels:We should also use layers from
tower-http
whenever possible.Overview
TLS
Not having this makes it impossible for custom client to communicate with real clusters.
We currently do the steps described below, and we need to provide a way to create the necessary struct from
kube::Config
(step 1).Native TLS
native_tls::TlsConnector
fromconfig.identity
andconfig.root_cert
(+config.accept_invalid_certs
)hyper_tls::HttpsConnector::from((http, tls))
http
ishyper::client::HttpConnector
andtls
istokio_native_tls::TlsConnector
tokio_native_tls::TlsConnector
is created fromnative_tls::TlsConnector
Rustls
rustls::ClientConfig
fromconfig.identity
andconfig.root_cert
(+config.accept_invalid_certs
)hyper_rustls::HttpsConnector::from((http, config))
http
ishyper::client::HttpConnector
andconfig
isArc<rustls::ClientConfig>
Authorization
Authorization with Basic/Bearer are easy to implement, but refreshable token is pretty complex. We should make that public.
Basic
Users can use
AddAuthorizationLayer::basic(user, pass)
fromtower_http
.Or use
map_request
to addAuthorization
header.Bearer
Users can use
AddAuthorizationLayer::bearer(token)
fromtower_http
.Or use
map_request
to addAuthorization
header.Refreshable (exec and oauth)
kube::service::AuthLayer
should be renamed and made public.This layer refreshes the token when necessary before setting the header.
Cluster URL
It's not difficult to implement, but we should provide a convenient way to set cluster URL because it's almost always necessary.
SetClusterUrlLayer::new(cluster_url)
.SetBaseUrlLayer
. Probably general enough to ask to add totower_http
.Decompression Support
Use
DecompressionLayer
fromtower_http
.Log/Trace
Use
TraceLayer
fromtower_http
.Headers
We should remove
headers
fromConfig
. Users can use a layer to add them.TODO
Config::native_tls_connector
andConfig::rustls_client_config
for users to configure TLS connection when building a custom client (Make Client configurable #540)native-tls
orrustls-tls
whenclient
feature is enabled. Allow one, both or none. When both, the default Service will usenative-tls
because of rustls cannot reach a cluster through ip #153. (Make Client configurable #540)kube-runtime
(Make Client configurable #540)SetBaseUriLayer
(Make Client configurable #540)ConfigExt::auth_layer
to return optional layer that managesAuthorization
header (Make Client configurable #540)AddAuthorization::basic
AddAuthorization::bearer
DecompressionLayer
instead of custom decompression moduleTraceLayer
instead ofLogRequest
headers
fromConfig
kube
totower
's README https://github.com/tower-rs/tower/tree/master/tower#library-support@clux Just summarizing what I have in mind and what needs to be done. Let me know what you think. Hoping to make some time to work on this soon, but if not, I can at least review PRs.
The text was updated successfully, but these errors were encountered: