Commit Graph

52 Commits

Author SHA1 Message Date
Lubomir I. Ivanov
38dc9a8fb0 client-go: use klog.V(3) for the cert-rotation controller start/stop
Introduce a verbosity level for the start and stop notifications,
so that regular calls to commands such as:
  "kubectl auth ..."
would only contain the "yes" / "no" output.

Kubernetes-commit: b2677b1e572ae1cd8b823683e88005b7857d8938
2020-03-04 01:35:17 +02:00
Jack Kleeman
a493c8da9a Add ReloadCertFromDisk flag to rest.Config and to kubeconfig which allows the provided client certificate files to be reloaded from disk (currently on every use)
Close outbound connections when using a cert callback and certificates rotate. This means that we won't get into a situation where we have open TLS connections using expires certs, which would get unauthorized errors at the apiserver

Attempt to retrieve a new certificate if open connections near expiry, to prevent the case where the cert expires but we haven't yet opened a new TLS connection and so GetClientCertificate hasn't been called.

Move certificate rotation logic to a separate function

Rely on generic transport approach to handle closing TLS client connections in exec plugin; no need to use a custom dialer as this is now the default behaviour of the transport when faced with a cert callback. As a result of handling this case, it is now safe to apply the transport approach even in cases where there is a custom Dialer (this will not affect kubelet connrotation behaviour, because that uses a custom transport, not just a dialer).

Check expiry of the full TLS certificate chain that will be presented, not only the leaf. Only do this check when the certificate actually rotates. Start the certificate as a zero value, not nil, so that we don't see a rotation when there is in fact no client certificate

Drain the timer when we first initialize it, to prevent immediate rotation. Additionally, calling Stop() on the timer isn't necessary.

Don't close connections on the first 'rotation'

Remove RotateCertFromDisk and RotateClientCertFromDisk flags.

Instead simply default to rotating certificates from disk whenever files are exclusively provided.

Add integration test for client certificate rotation

Simplify logic; rotate every 5 mins

Instead of trying to be clever and checking for rotation just before an
expiry, let's match the logic of the new apiserver cert rotation logic
as much as possible. We write a controller that checks for rotation
every 5 mins. We also check on every new connection.

Respond to review

Fix kubelet certificate rotation logic

The kubelet rotation logic seems to be broken because it expects its
cert files to end up as cert data whereas in fact they end up as a
callback. We should just call the tlsConfig GetCertificate callback
as this obtains a current cert even in cases where a static cert is
provided, and check that for validity.

Later on we can refactor all of the kubelet logic so that all it does is
write files to disk, and the cert rotation work does the rest.

Only read certificates once a second at most

Respond to review

1) Don't blat the cert file names
2) Make it more obvious where we have a neverstop
3) Naming
4) Verbosity

Avoid cache busting

Use filenames as cache keys when rotation is enabled, and add the
rotation later in the creation of the transport.

Caller should start the rotating dialer

Add continuous request rotation test

Rebase: use context in List/Watch

Swap goroutine around

Retry GETs on net.IsProbableEOF

Refactor certRotatingDialer

For simplicity, don't affect cert callbacks

To reduce change surface, lets not try to handle the case of a changing
GetCert callback in this PR. Reverting this commit should be sufficient
to handle that case in a later PR.

This PR will focus only on rotating certificate and key files.
Therefore, we don't need to modify the exec auth plugin.

Fix copyright year

Kubernetes-commit: 929b1559a0b855d996257ab3ad5364605edc253d
2019-06-14 22:08:58 +01:00
Jordan Liggitt
696c159e45 Plumb NextProtos to TLS client config, honor http/2 client preference
Kubernetes-commit: aef05c8dca2c1a9967ebd9a2f67a0bf7fb16f079
2019-08-28 09:55:37 -04:00
Mike Danese
cdbf1c4b62 implement request cancellation in token transport
Kubernetes-commit: a42e029e6905bee5b9d5489610c4fbe5988eeac6
2018-12-05 12:36:48 -08:00
Ted Yu
689d090711 Hide bearer token in logs
Kubernetes-commit: 010d8382642119c73cb2405286b347c08d704287
2019-08-13 09:36:13 -07:00
Clayton Coleman
40d852a94d Allow gzip compression to be disabled from rest.Config
Golang automatically enables transport level gzip, but local network
clients may wish to disable it for better CPU usage and lower latency
(scheduler, controller-manager). Allow DisableCompression on rest.Config
to modify the underlying transport. This impacts the transport cache,
but it is expected that most clients connecting to the same servers
within a process will have the same compression config.

Kubernetes-commit: dee6de70d0e4ad381bd5de01b6d1fbd4fde004bc
2019-08-02 14:23:33 -04:00
WanLinghao
0dbf86afcf Migrate the controller to use TokenRequest and rotate token periodically
Kubernetes-commit: 244b244f9d84c56ad3a5af255b70c793f6bfd39c
2019-02-19 11:42:05 +08:00
Justin SB
931e6a04ad Remove executable file permission from OWNERS files
Kubernetes-commit: dd19b923b7c26420af39fcf4eedfa213b236c8d3
2019-01-03 12:18:20 -05:00
Roy Lenferink
94093d2527 Updated OWNERS files to include link to docs
Kubernetes-commit: b43c04452f3b563473b5c2a765d4ac18cc0ff58f
2019-01-30 20:05:00 +01:00
Clayton Coleman
77dfa9569a Add transport wrapper that blocks api calls after context close
The ContextCanceller transport wrapper blocks all API requests
after the provided context is closed. Used with the leader election
step down, a controller can ensure that new requests are not made
after the client has stepped down.

Kubernetes-commit: fe74efb1f90826b1903d2908ff9e528329bebea0
2018-12-27 12:29:34 -05:00
Clayton Coleman
615e8e2492 Make wrapping a client transport more pleasant
Properly wrapping a transport can be tricky. Make the normal case
(adding a non-nil transport wrapper to a config) easier with a helper.
Also enforce a rough ordering, which in the future we can use to
simplify the WrapTransport mechanism down into an array of functions
we execute in order and avoid wrapping altogether.

Kubernetes-commit: 1f590e697ef64812620c787720b4b5942027e4a1
2018-12-27 11:47:50 -05:00
Jordan Liggitt
f46a378f78 Shorten re-read period for token files to work with ProjectedTokenVolumeSource
Kubernetes-commit: a432a7cf683e4ea304ae8e39e191a438e37a813e
2018-12-29 22:18:28 -05:00
Jordan Liggitt
66e83da33c Plumb token and token file through rest.Config
Kubernetes-commit: dba85e58debadfcb66aff2b68ba8bcc2eafeac2d
2018-12-04 11:24:29 -05:00
Davanum Srinivas
74cd8bbeee Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
Jordan Liggitt
63eb0a3a1f Add system root unit test
Kubernetes-commit: fbd5597e9914fc24ece3b21e6015748ed865de7b
2018-10-23 13:48:05 -04:00
Christoph Blecker
7f1c01699a Update gofmt for go1.11
Kubernetes-commit: 97b2992dc191a357e2167eff5035ce26237a4799
2018-10-05 12:59:38 -07:00
Tim Allclair
a6d1c60475 Only allow apiserver to follow redriects to the same host
Kubernetes-commit: 4ee9f007cbc88cca5fa3e8576ff951a52a248e3c
2018-07-23 13:16:25 -07:00
David Eads
5f3a23fd53 add logging to find offending transports
Kubernetes-commit: 8b61c5a08846221503ad039a53e3f38328c9c127
2018-08-02 15:14:27 -04:00
Jake Sanders
cce189a67e Escape illegal characters in remote extra keys
Signed-off-by: Jake Sanders <jsand@google.com>

Kubernetes-commit: f35e3d07c9898f8ec156209a868fa4451eb9afe2
2018-07-03 21:19:15 -07:00
Andrew Lytvynov
c669580288 Add TLS support to exec authenticator plugin
https://github.com/kubernetes/community/blob/master/contributors/design-proposals/auth/kubectl-exec-plugins.md#tls-client-certificate-support

Allows exec plugin to return raw TLS key/cert data. This data populates
transport.Config.TLS fields.
transport.Config.TLS propagates custom credentials using
tls.Config.GetClientCertificate callback.
On key/cert rotation, all connections using old credentials are
closed

Kubernetes-commit: cd89f9473faa60c15b8e9d223e5c4f9dab53627a
2018-05-30 14:03:32 -07:00
Mikhail Mazurskiy
4a75b93cb4 Use Dial with context
Kubernetes-commit: 5e8e570dbda6ed89af9bc2e0a05e3d94bfdfcb61
2018-05-19 08:14:37 +10:00
Cao Shufeng
f71f3da0d1 fix curl header
Kubernetes-commit: 084eb9b42906736002c285ac88c0dfcfbfb87a63
2018-04-27 15:56:03 +08:00
Jordan Liggitt
d23614d7ea ensure tls server name is used in transport
Kubernetes-commit: 6f657424743e93d064f8975a930941ba73f53110
2018-04-17 00:59:27 -04:00
Jordan Liggitt
015563ab58 distinguish custom dialers in transport cache
Kubernetes-commit: d45fbce37985b72ec454a8dbe73d92bf07f8726f
2018-04-17 00:58:56 -04:00
Aleksandra Malinowska
c1e13e8dbf Improve debug curl command
Kubernetes-commit: 42f756aeb01a6ce90ff56a0b07cb4bb5ab2c602b
2018-03-07 13:33:14 +01:00
Kubernetes Publisher
fff8c3d73e sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel 2018-03-15 09:19:38 +00:00
Jeff Grafton
fca8bb2928 Autogenerated: hack/update-bazel.sh
Kubernetes-commit: ef56a8d6bb3800ab7803713eafc4191e8202ad6e
2018-02-16 13:43:01 -08:00
Eric Chiang
77f9dfa073 client-go: remove import of github.com/gregjones/httpcache
Kubernetes-commit: ea085e0a32a6b723e5c565e60d8941b5a760bb68
2017-12-15 15:02:31 -08:00
Jeff Grafton
fe985a55a2 Autogenerate BUILD files
Kubernetes-commit: efee0704c60a2ee3049268a41535aaee7f661f6c
2017-12-23 13:06:26 -08:00
Jordan Liggitt
60b0546760 Use struct key for TLS cache
Kubernetes-commit: 5c8fe23722db05dda25a54d4275737af329227eb
2017-12-04 13:51:29 -06:00
Jordan Liggitt
fdf7e51f22 Include ServerName in tls transport cache key
Kubernetes-commit: 195a4d6f6da77ec39c5f80f3906406583c143996
2017-11-27 10:05:26 -05:00
Jeff Grafton
c92755ea3b update BUILD files
Kubernetes-commit: aee5f457dbfd70c2d15c33e392dce6a3ca710116
2017-10-12 13:52:10 -07:00
Kubernetes Publisher
baf97d23c3 plumb the proxyTransport to the webhook admission plugin;
set the ServerName in the config for webhook admission plugin.

Kubernetes-commit: 186a0684d582272aa2fbfec390aea5fbb88a8bc6
2017-09-22 11:22:07 +00:00
Antoine Pelisse
2ed3ee4524 client-go cache: Make caching layer Unwrappable
Kubernetes-commit: a804d440c3dfab8820c7f2d231dcaecb201be7b5
2017-09-01 16:19:00 +00:00
Antoine Pelisse
0b7513368a c-go cache: Use diskv TempDir to get atomic write
Kubernetes-commit: e58da7bb7c1800ffd4f24cf77c2e3f3cdfcdf906
2017-09-01 16:19:00 +00:00
Antoine Pelisse
928f5804e3 Revert "Revert "Merge pull request #47353 from apelisse/http-cache""
This reverts commit 4ee72eb300423772020dd1cf208159058ba7dab5.

Kubernetes-commit: 332b681bd1d961e2cee16bca10784088a8d308f1
2017-09-01 16:19:00 +00:00
Jeff Grafton
5da217e5c4 Use buildozer to delete licenses() rules except under third_party/
Kubernetes-commit: a7f49c906df816123e7d4ccbd4cebab411519465
2017-08-29 12:51:55 +00:00
Jeff Grafton
fa2ceb7462 Use buildozer to remove deprecated automanaged tags
Kubernetes-commit: 33276f06be5e872bf53ca62a095fcf0a6b6c11a8
2017-08-29 12:51:55 +00:00
Jordan Liggitt
53ab900949 Revert "Merge pull request #47353 from apelisse/http-cache"
This reverts commit fc89743dca6b563063b74728c3b28100cf674d9d, reversing
changes made to 29ab38e898988c36e2de34f77fa33be556eb21bd.

Kubernetes-commit: 4ee72eb300423772020dd1cf208159058ba7dab5
2017-08-29 12:51:24 +00:00
Antoine Pelisse
9f99bf70e2 c-go/transport: Add test for CacheRoundTripper
Kubernetes-commit: d6348cc1ff72be719e0830da2c64ef1689499956
2017-08-29 12:50:18 +00:00
Antoine Pelisse
d7f469601f c-go: Use http Etag cache
Add a new command-line cachedir flag to specify where to store the http
cache responses. This cache will only be used for OpenAPI Swagger spec
for now (as this is the only end-point that returns an ETag).

Kubernetes-commit: d7bba25d4a42f346f1963c86fc0dab43aa4f242e
2017-08-29 12:50:18 +00:00
Jeff Grafton
f921a73942 Run hack/update-bazel.sh to generate BUILD files
Kubernetes-commit: 3579017b865ddbc5449d6bba87346f086e4b93ff
2017-08-29 12:50:17 +00:00
Clayton Coleman
3bb413eede Move SPDY specific code into its own package
Kubernetes-commit: cf026a3314fd3513a2c4239c6f4edbbbbcb96a77
2017-07-16 03:58:42 +00:00
Andy Goldstein
6bc1999690 Add redirect support to SpdyRoundTripper
Add support for following redirects to the SpdyRoundTripper. This is
necessary for clients using it directly (e.g. the apiserver talking
directly to the kubelet) because the CRI streaming server issues a
redirect for streaming requests.

Also extract common logic for following redirects.

Kubernetes-commit: 715d5d9c91c669cf33c0bf9a9c9d352c6c4228a6
2017-04-27 20:28:33 +00:00
Mike Danese
9a45999fa0 autogenerated
Kubernetes-commit: a05c3c0efdc5822049e34b1a5a1ee259c5fb1906
2017-04-15 20:28:18 +00:00
Chao Xu
6c315a68f3 manully sync up to 1634d8f9f72a626b16c55573d78e8da2d75e6356
(merging https://github.com/kubernetes/kubernetes/pull/42084). For the new publish
script to work, client-go has to be synced up to when k8s.io/kubernetes doesn't
include _vendor
2017-03-08 11:31:44 -08:00
Kubernetes Publisher
204f12b1f3 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 616038db1b0d1e852b4a3d10c8c512a052f91fba
2017-01-14 15:19:47 +00:00
Kubernetes Publisher
5fe6fc56cb published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 5b2823adb9a8777f7819884fa79a6e1daa26b9c2
2016-12-17 15:19:41 +00:00
Kubernetes Publisher
243d8a9cb6 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is d8c925319a23f6bbf865baa53ae23f48f60dd73b
2016-12-11 15:19:40 +00:00
Kubernetes Publisher
41a99d711a published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 238ffdd0d6d79d610cea2ebe3a03868a197283c8
2016-12-03 08:16:09 +00:00