Commit Graph

124 Commits

Author SHA1 Message Date
Antonio Ojea
bc63c412b9 kubelet request certificates if at least one IP exist
A Kubernetes Node requires to have at minimum one IP address
because those are used on the Pods field HostIPs and in some cases,
when pods uses hostNetwork: true, as PodIPs.
Nodes that use IP addresses as Hostname are interpreted as an IP
address, so it is possible that are nodes that don't hane any DNSname.

The feature gate AllowDNSOnlyNodeCSR will allow user to opt-in for
the old behavior.

Change-Id: I094531d87246f1e7a5ef4fe57bd5d9840cb1375d
2024-07-18 09:44:48 +00:00
Wei Zhang
af2b0bdb05 add test 2024-06-06 03:07:40 +00:00
Wei Zhang
1b303fe5da enable kubelet server to dynamically load tls certificate files 2024-06-06 03:07:16 +00:00
HirazawaUi
82e3fa0930 fix fd leaks and failed file removing for main pkg and cmd 2023-05-09 09:24:11 -05:00
Tim Hockin
29c0b73d64 Replace uses of diff.ObjectDiff with cmp.Diff
ObjectDiff is already a shim over cmp.Diff, so no actual output or
behavior changes
2023-04-12 08:46:12 -07:00
Kubernetes Prow Robot
d0584179f4 Merge pull request #114367 from liggitt/kubelet-csr-init
Check for initial kubelet certificates more frequently
2023-01-30 09:07:05 -08:00
Paco Xu
160f015ef4 kubelet: add key encipherment usage only if it is rsa key
remove allowOmittingUsageKeyEncipherment as it is always true

Signed-off-by: Paco Xu <paco.xu@daocloud.io>
2022-12-27 16:04:25 +08:00
Jordan Liggitt
933494ab8d Check for initial kubelet certificates more frequently 2022-12-08 08:57:45 -05:00
Claudiu Belu
6f2eeed2e8 unittests: Fixes unit tests for Windows
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- config options not supported on Windows.
- files not closed, which means that they cannot be removed / renamed.
- paths not properly joined (filepath.Join should be used).
- time.Now() is not as precise on Windows, which means that 2
  consecutive calls may return the same timestamp.
- different error messages on Windows.
- files have \r\n line endings on Windows.
- /tmp directory being used, which might not exist on Windows. Instead,
  the OS-specific Temp directory should be used.
- the default value for Kubelet's EvictionHard field was containing
  OS-specific fields. This is now moved, the field is now set during
  Kubelet's initialization, after the config file is read.
2022-10-25 23:46:56 +03:00
inosato
3b95d3b076 Remove ioutil in kubelet and its tests
Signed-off-by: inosato <si17_21@yahoo.co.jp>
2022-07-30 12:35:26 +09:00
David Ashpole
120da3bb9b fix copylock vet errors in component-base metrics 2022-03-31 15:07:11 +00:00
Davanum Srinivas
9405e9b55e Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-12-09 21:31:26 -05:00
Antonio Ojea
0cd75e8fec run hack/update-netparse-cve.sh 2021-08-20 10:42:09 +02:00
tanjing2020
523b4c0918 Replace 'x.Sub(time.Now())' with 'time.Until(x)' 2021-07-23 10:03:36 +08:00
Davanum Srinivas
75748c185e enable verify-golangci-lint.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-07-14 08:53:33 -04:00
Davanum Srinivas
26cc8e40a8 fix deadcode issues
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-07-14 08:41:21 -04:00
Monis Khan
cd91e59f7c csr: add expirationSeconds field to control cert lifetime
This change updates the CSR API to add a new, optional field called
expirationSeconds.  This field is a request to the signer for the
maximum duration the client wishes the cert to have.  The signer is
free to ignore this request based on its own internal policy.  The
signers built-in to KCM will honor this field if it is not set to a
value greater than --cluster-signing-duration.  The minimum allowed
value for this field is 600 seconds (ten minutes).

This change will help enforce safer durations for certificates in
the Kube ecosystem and will help related projects such as
cert-manager with their migration to the Kube CSR API.

Future enhancements may update the Kubelet to take advantage of this
field when it is configured in a way that can tolerate shorter
certificate lifespans with regular rotation.

Signed-off-by: Monis Khan <mok@vmware.com>
2021-07-01 23:38:15 -04:00
刁浩 10284789
ce08fd5976 Add test cases to the LoadClientConfig function
Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>
2021-06-02 15:22:00 +00:00
Kubernetes Prow Robot
508a8839ad Merge pull request #98993 from SataQiu/structlog-kubelet-20210211
kubelet: migrate pkg/kubelet/certificate to structured logging
2021-03-04 13:38:48 -08:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
SataQiu
c88ef90b1e migrate to structured logging
Signed-off-by: SataQiu <shidaqiu2018@gmail.com>
2021-02-18 09:40:07 +08:00
SataQiu
6c31162b35 kubelet: improve error message about expired certificates 2021-01-21 23:05:45 +08:00
knight42
808867ba2f test(kubelet): deflake TestRotateShutsDownConnections
Signed-off-by: knight42 <anonymousknight96@gmail.com>
2020-09-18 16:52:58 +08:00
chenjun.cj
db71941775 make Kubelet bootstrap certificate signal aware 2020-07-06 22:30:27 +08:00
Jordan Liggitt
a298c14f18 Switch cert manager to v1 CSR API by default, falling back to v1beta1 2020-06-10 02:30:54 -04:00
Jordan Liggitt
94fd1d76ca Switch issued check to inspect certificate length 2020-05-28 12:20:40 -04:00
Kubernetes Prow Robot
5bace30840 Merge pull request #91148 from liggitt/kubelet-client-metric
Add kubelet_certificate_manager_client_ttl_seconds gauge
2020-05-16 19:00:24 -07:00
Davanum Srinivas
07d88617e5 Run hack/update-vendor.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:33 -04:00
Davanum Srinivas
442a69c3bd switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
Jordan Liggitt
2408d8101f Fix kubelet client certificate gauge 2020-05-15 12:57:34 -04:00
James Munnelly
d5dae04898 certificates: update controllers to understand signerName field
Signed-off-by: James Munnelly <james.munnelly@jetstack.io>
2020-02-27 15:54:31 +00:00
Mike Danese
bfc75d9a5c manual fixes 2020-02-08 12:32:33 -05:00
Mike Danese
2637772298 some manual fixes 2020-02-07 18:17:40 -08:00
Mike Danese
d55d6175f8 refactor 2020-01-29 08:50:45 -08:00
Jiahui Feng
b2bb3dfb59 add logging before kubelet waiting for cert
during bootstrapping.
2020-01-27 10:12:36 -08:00
Samuel Davidson
aba0b31526 Changed Kubelet client and serving cert TTL/Expiry certs to use gaugefunc for calculating time remaining. 2019-12-06 15:52:03 -08:00
Kubernetes Prow Robot
205570eb75 Merge pull request #84614 from rphillips/fixes/add_cert_rotation_failure_metric
kubelet: add certificate rotation error metric
2019-12-03 11:40:57 -08:00
yuxiaobo
81e9f21f83 Correct spelling mistakes
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-11-06 20:25:19 +08:00
Ryan Phillips
8e50c55e6b kubelet: add certificate rotation error metric 2019-11-05 16:51:40 -06:00
Samuel Davidson
3e817d17a5 Updated usage of certificate.Manager to use new rotation metric 2019-11-01 13:32:09 -07:00
Kubernetes Prow Robot
f442b6ef32 Merge pull request #82090 from liggitt/webhook-http2
Use http/1.1 for apiserver->webhook clients
2019-08-30 06:26:54 -07:00
Kubernetes Prow Robot
a9e5c4d6e4 Merge pull request #81968 from mtaufen/node-csr-hash
derive node CSR hashes from public keys
2019-08-29 13:31:41 -07:00
Jordan Liggitt
aef05c8dca Plumb NextProtos to TLS client config, honor http/2 client preference 2019-08-28 16:51:56 -04:00
Han Kang
3a50917795 migrate kubelet's metrics/probes & metrics endpoint to metrics stability framework 2019-08-28 11:16:38 -07:00
Michael Taufen
9dcf4d4ae2 derive node CSR hashes from public keys
These hashes were previously derived from the private key.
This is not a best practice. After this PR they are derived from public
keys.
2019-08-27 09:41:41 -07:00
Tim Allclair
8a495cb5e4 Clean up error messages (ST1005) 2019-08-21 10:40:21 -07:00
Jordan Liggitt
739a75fc32 Interrupt WaitForCertificate if desired kubelet serving cert changes 2019-05-16 15:14:47 -04:00
Clayton Coleman
7f9dfe58f4 Use CodecFactory.WithoutConversion() everywhere
Clarifies that requesting no conversion is part of the codec factory, and
future refactors will make the codec factory less opionated about conversion.
2019-04-03 22:19:13 -04:00
Andrew Lytvynov
18458392ca Extract new keyutil package from client-go/util/cert
This package contains public/private key utilities copied directly from
client-go/util/cert. All imports were updated.

Future PRs will actually refactor the libraries.

Updates #71004
2019-02-19 09:48:59 -08:00
Roy Lenferink
b43c04452f Updated OWNERS files to include link to docs 2019-02-04 22:33:12 +01:00