Commit Graph

75 Commits (0a68740d08ce096a39884de95e270d9920705255)

Author SHA1 Message Date
Roy Lenferink b43c04452f Updated OWNERS files to include link to docs 2019-02-04 22:33:12 +01:00
Clayton Coleman fde87329cb
bootstrap: Use kubeconfig contents as seed for cert dir if necessary
kubeadm uses certificate rotation to replace the initial high-power
cert provided in --kubeconfig with a less powerful certificate on
the masters. This requires that we pass the contents of the client
config certData and keyData down into the cert store to populate
the initial client.

Add better comments to describe why the flow is required. Add a test
that verifies initial cert contents are written to disk. Change
the cert manager to not use MustRegister for prometheus so that
it can be tested.
2018-11-17 19:52:12 -05:00
Clayton Coleman 486577df17 Restore "Make bootstrap client cert loading part of rotation""
This reverts the revert of commit 3464222267.
2018-11-17 13:44:58 -05:00
Clayton Coleman 3464222267
Revert "Make bootstrap client cert loading part of rotation"
This reverts commit 0af19875ad.

Revert "Ensure the bootstrap rotation code is tested by forcing rotation"

This reverts commit de293b2d7d.
2018-11-17 10:24:39 -05:00
Clayton Coleman de293b2d7d
Ensure the bootstrap rotation code is tested by forcing rotation
Expose both a Stop() method (for cleanup) and a method to force
cert rotation, but only expose Stop() on the interface.

Verify that we choose the correct client.
2018-11-16 21:50:52 -05:00
Clayton Coleman 0af19875ad
Make bootstrap client cert loading part of rotation
Ensure that bootstrap+clientcert-rotation in the Kubelet can:

1. happen in the background so that static pods aren't blocked by bootstrap
2. collapse down to a single call path for requesting a CSR
3. reorganize the code to allow future flexibility in retrieving bootstrap creds

Fetching the first certificate and later certificates when the kubelet
is using client rotation and bootstrapping should share the same code
path. We also want to start the Kubelet static pod loop before
bootstrapping completes. Finally, we want to take an incremental step
towards improving how the bootstrap credentials are loaded from disk
(potentially allowing for a CLI call to get credentials, or a remote
plugin that better integrates with cloud providers or KSMs).

Reorganize how the kubelet client config is determined. If rotation is
off, simplify the code path. If rotation is on, load the config
from disk, and then pass that into the cert manager. The cert manager
creates a client each time it tries to request a new cert.

Preserve existing behavior where:

1. bootstrap kubeconfig is used if the current kubeconfig is invalid/expired
2. we create the kubeconfig file based on the bootstrap kubeconfig, pointing to
   the location that new client certs will be placed
3. the newest client cert is used once it has been loaded
2018-11-16 21:50:26 -05:00
Andrew Lytvynov 5c073abfe1 Move csr.RequestNodeCertificate into kubelet bootstrap package
This func is only used by the kubelet and there's no need to pollute
client-go API with it.
2018-11-13 10:27:51 -08:00
Davanum Srinivas 954996e231
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
2018-11-10 07:50:31 -05:00
Jordan Liggitt 4ebe084376 certificates subproject approvers/reviewers 2018-11-06 00:57:38 -05:00
Kubernetes Submit Queue c1e37a5f16
Merge pull request #66056 from mikedanese/fixhang
Automatic merge from submit-queue (batch tested with PRs 67349, 66056). If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md.

wait until apiserver connection before starting kubelet tls bootstrap

I wonder if this helps with sometimes slow network programming

cc @mwielgus @awly
2018-08-30 20:16:32 -07:00
Mike Danese 2cf1c75e07 wait until apiserver connection before starting kubelet tls bootstrap 2018-08-30 11:37:05 -07:00
Lucas Käldström 844487aea4
autogenerated 2018-08-29 20:21:17 +03:00
Lucas Käldström 7a840cb4c8
automated: Rename all package references 2018-08-29 19:07:52 +03:00
Andrew Lytvynov 3357b5ecf4 Set connrotation dialer via restclient.Config.Dialer
Instead of Transport. This fixes ExecPlugin, which fails if
restclient.Config.Transport is set.
2018-07-25 16:23:57 -07:00
Jordan Liggitt db9d3c2d10
Derive kubelet serving certificate CSR template from node status addresses 2018-07-10 14:33:48 -04:00
Jeff Grafton 23ceebac22 Run hack/update-bazel.sh 2018-06-22 16:22:57 -07:00
Andrew Lytvynov 2c0f043957 Re-use private key after failed CSR
If we create a new key on each CSR, if CSR fails the next attempt will
create a new one instead of reusing previous CSR.

If approver/signer don't handle CSRs as quickly as new nodes come up,
they can pile up and approver would keep handling old abandoned CSRs and
Nodes would keep timing out on startup.
2018-06-13 13:12:43 -07:00
Andrew Lytvynov 85a61ff3aa Extract connection rotating dialer into a package
This will be re-used for exec auth plugin to rotate connections on
credential change.
2018-05-16 10:30:53 -07:00
Kubernetes Submit Queue 8220171d8a
Merge pull request #63492 from liggitt/node-heartbeat-close-connections
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

track/close kubelet->API connections on heartbeat failure

xref #48638
xref https://github.com/kubernetes-incubator/kube-aws/issues/598

we're already typically tracking kubelet -> API connections and have the ability to force close them as part of client cert rotation. if we do that tracking unconditionally, we gain the ability to also force close connections on heartbeat failure as well. it's a big hammer (means reestablishing pod watches, etc), but so is having all your pods evicted because you didn't heartbeat.

this intentionally does minimal refactoring/extraction of the cert connection tracking transport in case we want to backport this

* first commit unconditionally sets up the connection-tracking dialer, and moves all the cert management logic inside an if-block that gets skipped if no certificate manager is provided (view with whitespace ignored to see what actually changed)
* second commit plumbs the connection-closing function to the heartbeat loop and calls it on repeated failures

follow-ups:
* consider backporting this to 1.10, 1.9, 1.8
* refactor the connection managing dialer to not be so tightly bound to the client certificate management

/sig node
/sig api-machinery

```release-note
kubelet: fix hangs in updating Node status after network interruptions/changes between the kubelet and API server
```
2018-05-14 16:56:35 -07:00
Jordan Liggitt 52876f77e9
Always track kubelet -> API connections 2018-05-07 15:06:30 -04:00
Mayank Gaikwad e03a41ddf8 fixed golint error on redundant if 2018-05-04 11:58:30 +05:30
Kubernetes Submit Queue 9e52d14eb9
Merge pull request #62805 from awly/take-reviews
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add awly as reviewer in several subtrees

```release-note
NONE
```
2018-04-25 21:24:31 -07:00
Clayton Coleman 368959346a
When bootstrapping a client cert, store it with other client certs
The kubelet uses two different locations to store certificates on
initial bootstrap and then on subsequent rotation:

* bootstrap: certDir/kubelet-client.(crt|key)
* rotation:  certDir/kubelet-client-(DATE|current).pem

Bootstrap also creates an initial node.kubeconfig that points to the
certs. Unfortunately, with short rotation the node.kubeconfig then
becomes out of date because it points to the initial cert/key, not the
rotated cert key.

Alter the bootstrap code to store client certs exactly as if they would
be rotated (using the same cert Store code), and reference the PEM file
containing cert/key from node.kubeconfig, which is supported by kubectl
and other Go tooling. This ensures that the node.kubeconfig continues to
be valid past the first expiration.
2018-04-23 10:23:01 -04:00
Andrew Lytvynov ff85d34d4e Add awly as reviewer in several subtrees 2018-04-18 12:22:04 -07:00
Kubernetes Submit Queue 2bbaf430d8
Merge pull request #59316 from smarterclayton/terminate_early
Automatic merge from submit-queue (batch tested with PRs 58716, 59977, 59316, 59884, 60117). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Cap how long the kubelet waits when it has no client cert

If we go a certain amount of time without being able to create a client
cert and we have no current client cert from the store, exit. This
prevents a corrupted local copy of the cert from leaving the Kubelet in a
zombie state forever. Exiting allows a config loop outside the Kubelet
to clean up the file or the bootstrap client cert to get another client
cert.

Five minutes is a totally arbitary timeout, judged to give enough time for really slow static pods to boot.

@mikedanese

```release-note
Set an upper bound (5 minutes) on how long the Kubelet will wait before exiting when the client cert from disk is missing or invalid. This prevents the Kubelet from waiting forever without attempting to bootstrap a new client credentials.
```
2018-02-21 15:40:41 -08:00
Jeff Grafton ef56a8d6bb Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
Clayton Coleman 0346145615
Cap how long the kubelet waits when it has no client cert
If we go a certain amount of time without being able to create a client
cert and we have no current client cert from the store, exit. This
prevents a corrupted local copy of the cert from leaving the Kubelet in a
zombie state forever. Exiting allows a config loop outside the Kubelet
to clean up the file or the bootstrap client cert to get another client
cert.
2018-02-03 23:18:53 -05:00
Jeff Grafton efee0704c6 Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
supereagle b694d51842 use versiond group clients from client-go 2017-11-07 14:47:22 +08:00
Clayton Coleman 5649f9a578 Move pkg/kubelet/util/csr into client-go
Everything else it depends on was already there, and now we have a
somewhat consistent code chain.
2017-10-16 16:05:48 +02:00
Clayton Coleman b3a11aa635
Have the certificate manager decide if the server is healthy
Prevent a Kubelet from shutting down when the server isn't responding to
us but we cannot get a new certificate. This allows a cluster to coast
if the master is unresponsive or a node is partitioned and their client
cert expires.
2017-10-16 14:27:03 +02:00
Clayton Coleman 7555dec82e
Kubelet should exit if the current client cert has expired
The client cert manager uses the most recent cert to request new
certificates. If that certificate is expired, it will be unable to
complete new CSR requests. This commit alters the manager to force
process exit if no further client cert rotation is possible, which
is expected to trigger a restart of the kubelet and either a
re-bootstrap from the bootstrap kubeconfig or a re-read of the
current disk state (assuming that some other agent is managing the
bootstrap configuration).

This prevents the Kubelet from wedging in a state where it cannot make
API calls.
2017-10-16 14:27:03 +02:00
Clayton Coleman 710dfb3427
Delete the private key for the bootstrap client cert on failure
Ensures that in a crash loop state we can make forward progress by
generating a new key and hence new CSR. If we do not delete the key, an
expired CSR may block startup.

Also more aggressively delete a bad cert path
2017-10-16 14:27:02 +02:00
Clayton Coleman ae6ee96b36
Verify the bootstrap client cert before using it
Before the bootstrap client is used, check a number of conditions that
ensure it can be safely loaded by the server. If any of those conditions
are invalid, re-bootstrap the node. This is primarily to force
bootstrapping without human intervention when a certificate is expired,
but also handles partial file corruption.
2017-10-16 14:26:56 +02:00
Jeff Grafton aee5f457db update BUILD files 2017-10-15 18:18:13 -07:00
Jacob Simpson 415c4d2c3a Move certificate manager to client. 2017-10-05 12:54:38 -07:00
hzxuzhonghu 00d703d4dc remove unused code 2017-09-26 16:39:21 +08:00
Jacob Simpson f1fef11b37 Add a kubelet metric to track certificate expiration. 2017-08-30 09:55:40 -07:00
Kubernetes Submit Queue 2c6cb24e8a Merge pull request #50303 from zouyee/newb
Automatic merge from submit-queue

delete ineffectual assginment

**What this PR does / why we need it**:
delete ineffectual assignment
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:
2017-08-18 02:46:09 -07:00
Michael Taufen 24bab4c20f move KubeletConfiguration out of componentconfig API group 2017-08-15 08:12:42 -07:00
Jeff Grafton a7f49c906d Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
Jeff Grafton 33276f06be Use buildozer to remove deprecated automanaged tags 2017-08-11 09:31:50 -07:00
zouyee 847aa640b4 fix dump 2017-08-09 09:10:19 +08:00
Michael Taufen 443d58e40a Dynamic Kubelet Configuration
Alpha implementation of the Dynamic Kubelet Configuration feature.
See the proposal doc in #29459.
2017-08-08 12:21:37 -07:00
Malepati Bala Siva Sai Akhil f90a825308 Fix typo in certificate 2017-08-05 20:50:56 +05:30
xiangpengzhao f003ee9b29 Update OWNERS to correct members' handles. 2017-08-04 15:00:15 +08:00
Kubernetes Submit Queue 07ddb3941f Merge pull request #49899 from ericchiang/kubelet-close-conns-on-rotate
Automatic merge from submit-queue (batch tested with PRs 49237, 49656, 49980, 49841, 49899)

certificate manager: close existing client conns once cert rotates

After the kubelet rotates its client cert, it will keep connections to the API server open indefinitely, causing it to use its old credentials instead of the new certs. Because the API server authenticates client certs at the time of the request, and not the handshake, this could cause the kubelet to start hitting auth failures even if it rotated its certificate to a new, valid one.
    
When the kubelet rotates its cert, close down existing connections to force a new TLS handshake.

Ref https://github.com/kubernetes/features/issues/266
Updates https://github.com/kubernetes-incubator/bootkube/pull/663

```release-note
After a kubelet rotates its client cert, it now closes its connections to the API server to force a handshake using the new cert. Previously, the kubelet could keep its existing connection open, even if the cert used for that connection was expired and rejected by the API server.
```

/cc @kubernetes/sig-auth-bugs 
/assign @jcbsmpsn @mikedanese
2017-08-02 19:11:18 -07:00
Kubernetes Submit Queue 2495cc602f Merge pull request #49512 from bowei/cert-rotation-logging
Automatic merge from submit-queue (batch tested with PRs 49989, 49806, 49649, 49412, 49512)

Add some logs to certificate rotation

```release-note
NONE
```
2017-08-02 17:06:04 -07:00
Mike Danese 780e0eae3f rename OWNER to OWNERS 2017-08-01 17:44:10 -07:00
Eric Chiang 98795b32de generated:
Commands run:

	./hack/update-bazel.sh
2017-08-01 16:33:52 -07:00