Commit Graph

1545 Commits

Author SHA1 Message Date
Brad Davidson
6c7be18621 Fix startuphooks race condition panic
Ensure startup hooks WaitGroup is initialized before starting goroutine that will wait on it

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-15 17:46:07 -07:00
Brad Davidson
64981bc458 Fix secretsencryption request handler panic
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-15 17:46:07 -07:00
Brad Davidson
398eef4220 Fix authorization-config/authentication-config handling
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-15 15:39:35 -07:00
Brad Davidson
8053523ea1 Sync datastore config defaults with kine CLI
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 10e3d40bf3)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Richard Hansen
d4bb1cbbda flannel: Use custom type for network mode (IPv4, IPv6, dual-stack)
Move the `ipv4` and `ipv6` constants to their own constant
declaration.  This ensures that the `iota` expression for the `ipv4`
constant evaluates to 0, not some arbitrary value.  (`iota` evaluates
to N for the Nth constant in the constant declaration; see
<https://go.dev/ref/spec#Iota>.)  This is also more idiomatic, which
improves readability.

Also switch from incremental integers to bit flags, and use bitwise
operators for checking.  This is more idiomatic (the integer is
treated like a set of booleans), it avoids some code duplication, and
it is necessary to avoid ambiguity.  Consider the following:

    const (
    	ipv4 = iota
    	ipv6
    )

In the above, `ipv4` would have the value 0 and `ipv6` would have the
value 1.  This would make it impossible to distinguish an IPv6-only
stack from a dual-stack configuration because `ipv6` would equal
`ipv4 + ipv6`.  With bit flags this problem doesn't exist.

And put the integer holding the bit flags in a custom type with
convenience methods to improve readability.

Signed-off-by: Richard Hansen <rhansen@rhansen.org>
(cherry picked from commit 925726c84d)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
bo.jiang
a890866a83 Optimize certificate status check
Signed-off-by: bo.jiang <bo.jiang@daocloud.io>
(cherry picked from commit 4c1f014d27)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Brad Davidson
36ef04e9c9 Add support for conditional image tarball imports
Normally K3s will import all tarballs in the image dir on startup, and
re-import any tarballs that change while it is running.

This change allows users to opt into only importing tarballs that have
changed since they were last imported, even across restarts.

This behavior is opted into by touching a `.cache.json` file in the
images dir. This file is used to track the size and mtime of the image
files when they are imported.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 67291090ca)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Brad Davidson
bc309b8c15 Add CLI flag and config file for s3 bucket lookup type
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit a8f0acbe52)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Brad Davidson
29b29b8e15 Add anonymous-auth to flags gated on empty authorization-config value
Also warn if default flags are not set due to user provided config

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 921e502918)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Brad Davidson
ca634926b8 Bump containerd/cri-dockerd/spegel/runc
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit b15af84e4a)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Vitor Savian
8efef65aaf Fix prints that broke unit tests
Signed-off-by: Vitor Savian <vitor.savian@suse.com>
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Brad Davidson
a4f870e60b Bump spegel to v0.1.1
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 396f1366cc)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Robert Rose
c037d66355 Remove resources created by addon before deleting addon (#11975)
Remove the AddOn last, after any resources it created in the cluster
have been deleted and the AddOn file is removed.

Signed-off-by: Robert Rose <robert.rose@mailbox.org>
(cherry picked from commit 5e1845b7c1)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-05-13 14:45:27 -07:00
Vitor Savian
b39fd93002 Update certification renew alert to 120 days
Signed-off-by: Vitor Savian <vitor.savian@suse.com>
2025-05-13 17:46:08 -03:00
Vitor Savian
a2634b8904 Add generation for kube-scheduler and kube-controller-manager certs (#12285)
* Add generation for kube-scheduler and kube-controller-manager certs

Signed-off-by: Vitor Savian <vitor.savian@suse.com>

* Add new certs to the tests

Signed-off-by: Vitor Savian <vitor.savian@suse.com>

* Change cert-dir to tls-cert-file and tls-private-key-file

Signed-off-by: Vitor Savian <vitor.savian@suse.com>

* Address altName structure

Co-authored-by: Brad Davidson <brad@oatmail.org>
Signed-off-by: Vitor Savian <vitor.savian@suse.com>

---------

Signed-off-by: Vitor Savian <vitor.savian@suse.com>
Co-authored-by: Brad Davidson <brad@oatmail.org>
2025-05-13 17:46:08 -03:00
Brad Davidson
7975e4bfef Bump traefik to v2.11.24
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-21 16:12:35 -07:00
Brad Davidson
7225aa3d63 Fix handler panic when bootstrapper returned empty peer list
Panic gets rescued by the http server, and was only visible when running in debug mode, but should be handled properly.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-18 10:33:32 -07:00
Brad Davidson
bb3b1330de Add cache to spegel p2p peerinfo handler
libp2p may make a large number of bootstrap calls during startup; serve nodes from cache to avoid excessive CPU usage.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-17 21:30:52 -07:00
Brad Davidson
11042804f3 Move delegating auth middleware into common package and add MaxInFlight
Adds maximum in-flight request limits to agent join and p2p peer info
request request handlers.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-17 21:30:52 -07:00
Brad Davidson
5a1859d405 Fix chainingBootstrapper to return the first successful address list
Avoids infinite recursion when the chain includes an agentBootstrapper with a server address that points back at this node (via join address loop or external LB)

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-17 21:30:52 -07:00
Brad Davidson
ece7520bcc Fix etcd socket option config
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-11 14:28:22 -07:00
Aaron Dewes
e5a21f7a3e fix: Use proper key when signing kubelet certificate
I assume this was a mistake when copying and the kubelet key should have been used here.

This bug was introduced in #11471.

Signed-off-by: Aaron Dewes <aaron@nirvati.org>
(cherry picked from commit 147a3c0daf)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-11 14:28:22 -07:00
github-actions[bot]
196df2249c Bump Klipper Helm and Helm Controller version (#12026)
* chore: Bump Klipper Helm and Helm Controller version

Made with ❤️️ by updatecli

* chore: Bump Klipper Helm and Helm Controller version

Made with ❤️️ by updatecli

* Fix build

Signed-off-by: Derek Nola <derek.nola@suse.com>

---------

Signed-off-by: Derek Nola <derek.nola@suse.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Derek Nola <derek.nola@suse.com>
(cherry picked from commit 2fdc6fab07)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-11 14:28:22 -07:00
Brad Davidson
650e431b1c Fix windows socket prefix
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit f5b0d7884f)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-11 14:28:22 -07:00
Brad Davidson
895bf636d7 Add ReusePort/ReuseAddr flags to etcd config
Addresses flakes in etcd CI due to the port still being in TIME_WAIT after the server is shut down between tests

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 9deef77eef)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-11 14:28:22 -07:00
Brad Davidson
f497eb0522 Bump to traefik/v2.11.22, coredns/v1.12.1
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 7cdf0fa688)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-11 14:28:22 -07:00
manuelbuil
93bd4bb2a1 Add error in certificate check
Signed-off-by: manuelbuil <mbuil@suse.com>
2025-04-11 13:37:37 -07:00
Derek Nola
9e5267e384 Remove double error check
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-04-09 01:01:06 -04:00
Derek Nola
37ceaca12a Align Value CLI
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-04-09 01:01:06 -04:00
Derek Nola
af9c58ec75 Mark rotate-keys as GA
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-04-09 01:01:06 -04:00
Derek Nola
e66881bd97 Implement secrets-encryption secretbox provider
- Add testlet for new provider switch
- Handle migration between providers
- Add exception for criticalcontrolargs
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-04-09 01:01:06 -04:00
Brad Davidson
0dd43a9ba9 Fix flakey etcd startup tests
Increase etcd shutdown delay to avoid "bind: address already in use" errors seen in CI. Also uses test TmpDir to ensure dir is cleaned up between tests.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-02 11:38:51 -07:00
Brad Davidson
c42cc2d43c Add tests for control-plane component arg generation
Use mocked executor to ensure the correct args are being passed to components

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 1ba19856de)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-02 11:38:51 -07:00
Brad Davidson
028bbc7745 Fix issue caused by default authorization-mode apiserver arg
Move arg-parsing helper functions into util, and use them to see if the user has set an authorization-config flag - and do not set authorization-mode if so.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit ee036f7bc9)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-02 11:38:51 -07:00
Brad Davidson
d8221573e3 Rework mock executor using gomock for call validation
Generate the mock executor with mockgen and convert existing uses of the mock executor to set it up properly.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 0eeac6a622)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-04-02 11:38:51 -07:00
Brad Davidson
e8079602af Move etcd ready channel into executor
This eliminates the final channel that was being passed around in an internal struct. The ETCD management code passes in a func that can be polled until etcd is ready; the executor is responsible for polling this after etcd is started and closing the etcd ready channel at the correct time.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit d45006be66)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-31 17:22:44 -07:00
Brad Davidson
6f0212ab9a Fix etcd tests to use mock executor
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 72bbd676f1)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-31 17:22:44 -07:00
Brad Davidson
ceaa23e65e Move container runtime ready channel into executor
Move the container runtime ready channel into the executor interface, instead of passing it awkwardly between server and agent config structs

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit a8bc412422)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-31 17:22:44 -07:00
Brad Davidson
f3f7899521 Move apiserver ready wait into common channel
Splits server startup into prepare/start phases. Server's agent is now
started after server is prepared, but before it is started. This allows
us to properly bootstrap the executor before starting server components,
and use the executor to provide a shared channel to wait on apiserver
readiness.

This allows us to replace four separate callers of WaitForAPIServerReady
with reads from a common ready channel.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 529e748ac7)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-31 17:22:44 -07:00
Brad Davidson
9989f5e69a Increase log output while waiting for apiserver ready
Increases log verbosity but decreases polling frequency to avoid
spamming the console. It usually takes a couple seconds for the
apiserver to come up anyway.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 2c133692b2)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-31 17:22:44 -07:00
Brad Davidson
f13bf11348 Add context to agent token validation error
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit c11c06cad4)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-31 17:22:44 -07:00
Derek Nola
51fb5b7843 Migrate to UrfaveCLI v2 (#11831) (#12030)
* Bump rootlesskit tov 1.1.1, last of the v1 line
* Migrate to urfavecli v2
* Disable StringSlice seperattion

Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-03-31 13:39:46 -07:00
Brad Davidson
e566886305 Fix syncing empty list of apiserver addresses during initial startup
Also add more debug logging to the sync process.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 781640ecea)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-11 20:28:51 -07:00
Derek Nola
310ce7a63f Bump klipper-lb image (#11898)
Signed-off-by: Derek Nola <derek.nola@suse.com>
2025-03-10 11:32:37 -07:00
Brad Davidson
6adca198c7 Add periodic background snapshot reconcile
Interval is configurable with new etcd-snapshot-reconcile-interval flag

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit d694dd1db9)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00
Brad Davidson
3cb6c2dc92 Avoid use of github.com/pkg/errors functions that capture stack
We are not making use of the stack traces that these functions capture, so we should avoid using them as unnecessary overhead.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit bed1f66880)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00
Brad Davidson
79a15a3258 Fix panic when secret-encrypt status is checked before runtime core is ready
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit e7b52cd63d)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00
Brad Davidson
936e9a0f2e Use etcd proxy to bootstrap control-plane-only nodes, if possible
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit f940368747)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00
Brad Davidson
62fbed7ed5 Use existing server-CA and hash if available
Also wraps errors along the cluster prepare path to improve tracability.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 244bfd0c35)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00
Brad Davidson
58168ac103 Serve HTTP bootstrap data from datastore before disk
Fixes issue where CA rotation would fail on servers with join URL set due to using old data from disk on other server

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 53fcadc028)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
2025-03-07 14:46:16 -08:00