Commit Graph

1062 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
983dd07760 Merge pull request #128031 from HirazawaUi/kep-4656
[Kubeadm] KEP-4656: Add kubelet instance configuration to configure CRI socket for each node
2024-11-06 20:09:37 +00:00
HirazawaUi
d3ea4d3d9a Implement kubeadm reset 2024-11-06 21:43:09 +08:00
Kubernetes Prow Robot
3dcad5f0db Merge pull request #128532 from neolit123/1.32-handle-custom-addreses-comp-readyz
kubeadm: use advertise address for WaitForAllControlPlaneComponents
2024-11-06 08:51:29 +00:00
HirazawaUi
16e767d915 Implement kubeadm init 2024-11-05 20:59:53 +08:00
Lubomir I. Ivanov
0cfcaa82e1 kubeadm: use advertise address for WaitForAllControlPlaneComponents 2024-11-05 09:00:38 +02:00
Kubernetes Prow Robot
6fce566781 Merge pull request #128474 from neolit123/1.32-handle-custom-addreses-comp-readyz
kubeadm: use actual addresses/ports for WaitForAllControlPlaneComponents
2024-11-02 17:19:26 +00:00
Lubomir I. Ivanov
b2741f7b1c kubeadm: use actual addresses/ports for WaitForAllControlPlaneComponents
By default check the KCM and scheduler on 127.0.0.1:<port> as that is the
defaall --bind-address kubeamd uses for these components.

For kube-apiserver take the value from APIEndpoint.AdvertiseAddress which is
dynamically detected from the host. Unless the user has passed explicitly --advertise-address
as an extra arg.

Read the <port> values for all components from the --secure-port flag
value if needed. Otherwise use defaults.

Use /livez for apiserver and scheduler. Add TODO for KCM to
switch to /livez as well.
2024-11-02 18:09:36 +02:00
Lubomir I. Ivanov
fceb39ecd2 kubeadm: ensure proper parsing of SSR username
- Split the code that tries to get node name from SSR into
a new function getNodeNameFromSSR(). Unit test the function.
- Fix error that the "system:nodes:" prefix was not trimmed.
- Fix mislearding errors around FetchInitConfigurationFromCluster.
This function performs multiple actions, and the "get node"
action can also be of type apierrors.NotFound(). This creates
confusion in the returned error in enforceRequirement during
upgrade. Fix this problem.
2024-11-01 11:42:58 +02:00
Lubomir I. Ivanov
07918a59e8 kubeadm: support dryrunning upgrade wihout a real cluster
Make the following changes:
- When dryrunning if the given kubeconfig does not exist
create a DryRun object without a real client. This means only
a fake client will be used for all actions.
- Skip the preflight check if manifests exist during dryrun.
Print "would ..." instead.
- Add new reactors that handle objects during upgrade.
- Add unit tests for new reactors.
- Print message on "upgrade node" that this is not a CP node
if the apiserver manifest is missing.
- Add a new function GetNodeName() that uses 3 different methods
for fetching the node name. Solves a long standing issue where
we only used the cert in kubelet.conf for determining node name.
- Various other minor fixes.
2024-10-31 14:58:47 +02:00
SataQiu
dc48aed791 kubeadm: support joining control plane nodes in dryrun mode without a real initialized control plane 2024-10-28 21:37:58 +08:00
Kubernetes Prow Robot
769695a218 Merge pull request #126776 from neolit123/1.31-improve-dry-run-logic
kubeadm: refactor the dry-run logic
2024-10-14 10:20:21 +01:00
Lubomir I. Ivanov
30f9893374 kubeadm: refactor the dry-run logic
The current dryrun client implemnetation is suboptimal
and sparse. It has the following problems:

- When an object CREATE or UPDATE reaches the default dryrun client
the operation is a NO-OP, which means subsequent GET calls must
fully emulate the object that exists in the store.
- There are multiple implmentations of a DryRunGetter interface
such the one in init_dryrun.go but there are no implementations
for reset, upgrade, join.
- There is a specific DryRunGetter that is backed by a real
client in clientbacked_dryrun.go, but this is used for upgrade
and does not work in conjuction with a fake client.

This commit does the following changes:

- Removes all existing *dryrun*.go implementations.
- Add a new DryRun implementation in dryrun.go that implements
3 clients - fake clientset, real clientset, real dynamic client.
- The DryRun object uses the method chaining pattern.
- Allows the user opt-in into real clients only if needed, by passing
a real kubeconfig. By default only constructs a fake client.
- The default reactor chain for the fake client, always logs the
object action, then for GET or LIST actions attempts to use the
real dynamic client to get the object. If a real object does not
exist it attempts to get the object from the fake object store.
- The user can prepend or append reactors to the chain.
- All known needed reactors for operations during init, join,
reset, upgrade are added as methods of the DryRun struct.
- Adds detailed unit test for the DryRun struct and its methods
including reactors.

Additional changes:
- Use the new DryRun implementation in all command workflows -
init, join, reset, upgrade.
- Ensure that --dry-run works even if there is no active cluster
by returning faked objects. For join, a faked cluster-info
with a fake bootstrap token and CA are used.
2024-10-11 00:15:59 +03:00
SataQiu
2dc0d2962a kubeadm: fix a bug where the RemoveMember function did not return the correct member list when the member to be removed did not exist 2024-09-26 14:29:30 +08:00
Kubernetes Prow Robot
4c4edfede5 Merge pull request #127398 from my-git9/patch-23
kubeadm: update comment for ArgumentsFromCommand function in app/util/arguments
2024-09-25 11:40:00 +01:00
xin.li
706e939382 kubeadm: update comment for ArgumentsFromCommand function in app/util/arguments
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-09-25 16:19:28 +08:00
SataQiu
9af1b25bec kubeadm: check the member list status before adding or removing an etcd member 2024-09-24 22:53:42 +08:00
SataQiu
18318a32ce kubeadm: check whether the peer URL for the added etcd member already exists when the MemberAddAsLearner/MemberAdd fails 2024-09-20 11:52:47 +08:00
Lubomir I. Ivanov
b497d28d43 kubeadm: better error handling for unknown phases and commands
If an unknown command or a phase is called consistently
return the same error.

If a command that has subcommands is called
return an error.

To achieve the above add a new util function
RequireSubcommand() that sets NoArgs and RunE for
regular commands or a "phase" command.

Remove MacroCommandLongDescription and just return an
error that a subcommand is required from the phase runner.

Fix minor comments capitalization.

Perform other minor fixes in util/error.go.
2024-09-05 19:41:43 +03:00
Nathan Baulch
ad7cb45bb2 Fix kubeadm typos 2024-09-03 13:07:55 +10:00
Kubernetes Prow Robot
de6db3ffb0 Merge pull request #126758 from my-git9/dryrun-ut
kubeadm: increase ut coverage for util/dryrun
2024-08-30 06:33:30 +01:00
xin.li
6f7f49c3df kubeadm: increase ut coverage for util/dryrun
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-08-30 10:53:04 +08:00
carlory
84f6301204 kubeadm: removed the deprecated flag '--experimental-output', please use the flag '--output' instead that serves the same purpose. Affected commands are - "kubeadm config images list", "kubeadm token list", "kubeadm upgade plan", "kubeadm certs check-expiration". 2024-08-26 16:48:30 +08:00
Kubernetes Prow Robot
385fd21d92 Merge pull request #126743 from neolit123/1.32-add-get-proxy-env-vars-test
kubeadm: sort the merged env vars and improve related tests
2024-08-26 05:40:50 +01:00
Lubomir I. Ivanov
a9f681d40a kubeadm: sort the results of MergeKubeadmEnvVars
MergeKubeadmEnvVars use a map which results in non
deterministic output in the end slice EnvVar objects.
Before returning the slice, sort it by the Name field.

Update the unit test to capture the sorting aspect.
2024-08-20 09:11:53 +03:00
Lubomir I. Ivanov
ffbc494a4a kubeadm: add unit test for GetProxyEnvVars 2024-08-20 09:11:53 +03:00
xin.li
6b9e106c2f kubeadm: remove unused function in util/pkiutil
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-08-17 22:57:33 +08:00
xin.li
42e8446d7e kubeadm: increase ut coverage for util/version
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-08-09 09:23:10 +08:00
Kubernetes Prow Robot
815efa2baa Merge pull request #126250 from my-git9/pkiutil-consot
kubeadm: remove unused constants in util/pkiutil
2024-07-21 03:02:57 -07:00
Lubomir I. Ivanov
b90b280c5a kubeadm: fix join bug where kubeletconfig was not patched in memory
During kubeadm join in 1.30 kubeadm started respecting
the kubeletconfiguration healthz address/port. Previously
it hardcoded the health check to localhost:defaultport.

A corner case was not handled where the user applies --patches
on join to modify the local kubeletconfiguration. This results
in kubeletconfiguration patch target patches not being applied to
the KubeletConfiguration in memory and the health check
running on the address:port which are present in the kubelet-config
configmap.

Fix that by explicitly calling a new function to patch the
KubeletConfiguration in memory. This is scoped to only handle
the healthz checks *after* the kubelet config.yaml was already
patched and written to disk.
2024-07-20 19:31:19 +03:00
xin.li
c1dca0ad7c kubeadm: remove unused constants in util/pkiutil
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-07-20 23:30:25 +08:00
xin.li
fbf8cf41a7 kubeadm: remove unused function in util/staticpod
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-07-14 16:57:25 +08:00
SataQiu
69a2bebc70 kubeadm: fix a bug that ImageExists check returns true when the image isn't in the local storage 2024-07-11 22:42:40 +08:00
Alex Stundzia
58ff17bbfa When using external CA, look for common trust anchor within CA bundle. 2024-06-28 18:04:31 -05:00
Kubernetes Prow Robot
e832b70230 Merge pull request #125545 from claudiubelu/unittests-12
unittests: Fixes unit tests for Windows (part 12)
2024-06-28 03:57:56 -07:00
Claudiu Belu
b5e3b81de6 unittests: Fixes unit tests for Windows (part 12)
Currently, there are some unit tests that are failing on Windows due
to various reasons:

- IPVS proxy mode is not supported on Windows.
- pkg/kubelet/cri/remote was moved to cri-client.
2024-06-28 08:05:38 +00:00
SataQiu
7120b3902c kubeadm: improve the error/warning messages of 'validateSupportedVersion' to include the checked resource kind 2024-06-27 18:47:09 +08:00
Lubomir I. Ivanov
09078d4810 kubeadM: allow conversion of TimeoutForControlPlane
v1beta3.ClusterConfiguration.APIServer.TimeoutForControlPlane
must be migrated to {Init|Join}Configuration.Timeouts.
.ControlPlaneComponentHealthCheck.

To achieve this sort of cross-Kind migration do the following:
- Use a temporary, thread-safe variable in timeoututils.go
- Make the order of GVKs in documentMapToInitConfiguration
deterministic.
2024-06-17 10:07:33 +03:00
Lubomir I. Ivanov
4af99cd676 kubeadm: deprecate v1beta3
Mark v1beta3 as deprecated by showing a warning when used
and write a note about it in the doc.go file.
2024-06-17 10:07:33 +03:00
Lubomir I. Ivanov
8a5f849c66 kubeadm: keep v1beta3 only in required code paths
Use v1beta4 everywhere and only use v1beta3
in a few required locations:
- kubeadm-config map handling
- unit and integration tests
2024-06-17 10:07:32 +03:00
Lubomir I. Ivanov
66c7fc5ab4 kubeadm: update migration logic from v1beta3 to 4
Treat v1beta4 as non experimental API when migrating.
Update unit tests.
2024-06-17 10:07:32 +03:00
Lubomir I. Ivanov
52302e4ad5 kubeadm: use the actual configured kubelet healthz address:port
When doing a kubelet health check on init/join, do not
hardcode the "localhost" address. Instead, use the
KubeletConfiguration HealthzBindAddress and HealthzPort
fields.
2024-06-01 10:10:31 +03:00
Sascha Grunert
51a36294a3 kubeadm: check only for RuntimeReady condition
We only check for the `RuntimeReady` condition instead of anything else
like the `NetworkReady` to allow kubeadm to provision the cluster.

Refers to https://github.com/kubernetes/kubernetes/pull/124685#issuecomment-2138655482
Follow-up on: https://github.com/kubernetes/kubernetes/pull/124685

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-05-30 08:33:22 +02:00
Kubernetes Prow Robot
da02fdb2ae Merge pull request #123339 from skitt/canonical-json-patch
Update kustomize, use canonical json-patch v4 import
2024-05-29 08:02:24 -07:00
Sascha Grunert
7d1bfd9872 Make kubeadm independent from crictl
With the new `cri-client` staging repository it's finally possible to
decouple `kubeadm` from `crictl`.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-05-29 08:58:01 +02:00
Stephen Kitt
5300466a5c Use canonical json-patch v4 import
The canonical import for json-patch v4 is
gopkg.in/evanphx/json-patch.v4 (see
https://github.com/evanphx/json-patch/blob/master/README.md#get-it for
reference).

Using the v4-specific path should also reduce the risk of unwanted v5
upgrade attempts, because they won't be offered as automated upgrades
by dependency upgrade management tools, and they won't happen through
indirect dependencies (see
https://github.com/kubernetes/kubernetes/pull/120327 for context).

Signed-off-by: Stephen Kitt <skitt@redhat.com>
2024-05-28 10:48:22 +02:00
Lubomir I. Ivanov
5e290ebc90 switch k/k to pause version 3.10 2024-05-24 10:02:51 +03:00
Kubernetes Prow Robot
67012614c3 Merge pull request #124442 from neolit123/1.31-add-image-pull-policy-to-upgrade-config
kubeadm: support image pull mode and policy in UpgradeConfiguration
2024-05-16 20:12:52 -07:00
Lubomir I. Ivanov
0faa2bfbc1 kubeadm: support image pull mode and policy in UpgradeConfiguration
Add Upgrade{Apply|Node}Configuration.{ImagePullPolicy|ImagePullSerial}.
The same feature already exists in NodeRegistrationOptions for
{Init|Join}Configuration.
2024-05-16 11:34:39 +03:00
SataQiu
1329935739 kubeadm: add support for patching a corednsdeployment target 2024-05-11 18:21:20 +08:00
Lubomir I. Ivanov
74e1438d86 kubeadm: add support for custom cert validity period in v1beta4
Allow the user to pass custom cert validity period with
ClusterConfiguration.CertificateValidityPeriod and
CACertificateValidityPeriod.

The defaults remain 1 year for regular cert and 10 years for CA.
Show warnings if the provided values are more than the defaults.

Additional changes:
- In "certs show-expiration" use HumanDuration() to print
more detailed durations instead of ShortHumanDuration().
- Add a new kubeadm util GetStartTime() which can be used
to consistently get a UTC time for tasks like writing certs
and unit tests.
- Update unit tests to validate the new customizable NotAfter.
2024-05-01 19:01:49 +03:00