Commit Graph

38 Commits

Author SHA1 Message Date
SataQiu
69e50cabd2 kubeadm: fix a bug where the uploaded kubelet configuration in kube-system/kubelet-config ConfigMap does not respect user patch 2023-02-07 18:24:31 +08:00
Lubomir I. Ivanov
81b3540206 kubeadm: ensure kubelet patch results are in YAML
Once we patch a kubelet configuration file, the patched output
is in JSON. Make sure it's converted back to YAML, given
the kubelet config in the cluster and on disk is always in YAML.

Add unit test for the new function applyKubeletConfigPatches()
2022-06-15 13:38:04 +03:00
Paco Xu
31922c7794 kubeadm: use staticpod known tags for upgrade/init phases 2022-06-09 14:21:48 +08:00
Kubernetes Prow Robot
cd4b8ed070
Merge pull request #110405 from neolit123/1.25-kubelet-config-patches
kubeadm: add support for patching a "kubeletconfiguration" target
2022-06-07 07:05:07 -07:00
Lubomir I. Ivanov
85fb6b01f8 kubeadm: apply patches to the kubelet config before writing it to disk
In phases/kubelet/WriteConfigToDisk() create a patch
manager for the root patches directory and apply
the user patches with a target "kubeletconfiguration".
2022-06-06 20:37:26 +03:00
Lubomir I. Ivanov
665f66d2bc kubeadm: pass io.Writer and "patches dir" to WriteConfigToDisk()
With phases/kubelet/WriteConfigToDisk() about to support patches
it is required that the function accepts an io.Writer
where the PatchManager can output to and also a patch directory.

Modify all call sites of the function WriteConfigToDisk()
to properly prepare an pass an io.Writer and patches dir to it.
This results in command phases for init/join/upgrade to pass
the root io.Writer (usually stdout) and the patchesDir populated
either via the config file or --patches flag.
2022-06-06 20:37:26 +03:00
Lubomir I. Ivanov
9f6df1d489 kubeadm: graduate the UnversionedKubeletConfig FG to GA
- lock the FG to true by default
- cleanup wrappers and logic related to versioned vs unversioned
naming of API objects (CMs and RBAC)
- update unit tests
2022-06-01 17:17:07 +03:00
ahrtr
972dc46a1f replace deprecated io/ioutil with os and io for cmd 2022-02-01 13:59:41 +08:00
Kubernetes Prow Robot
35f9bcabf1
Merge pull request #105992 from hwdef/fix-kubeadm-2419
kubeadm: add mutation for Linux paths in KubeletConfiguration on Windows
2021-11-11 19:48:29 -08:00
hwdef
b985e094b0 kubeadm: fix absolute paths do not work properly in config files in windows 2021-11-12 10:42:46 +08:00
Lubomir I. Ivanov
68118d7319 kubeadm: remove unused / legacy function DownloadConfig
The function has been marked as deprecated for a long time
and has been unused in the code base.

Remove it.
2021-11-08 17:31:29 +02:00
Lubomir I. Ivanov
a6587f4ffb kubeadm: add the UnversionedKubeletConfigMap feature gate
Add the UnversionedKubeletConfigMap feature gate that can
be used to control legacy vs new behavior for naming the
default configmap used to store the KubeletConfiguration.

Update related unit tests.
2021-11-08 17:31:29 +02:00
XinYang
72fd01095d
re-order imports for kubeadm
Signed-off-by: XinYang <xinydev@gmail.com>
2021-08-17 22:40:46 +08:00
XinYang
c2a8cd359f
re-order the imports in kubeadm
Signed-off-by: XinYang <xinydev@gmail.com>

Update cmd/kubeadm/app/cmd/join.go

Co-authored-by: Lubomir I. Ivanov <neolit123@gmail.com>
2021-07-04 16:41:27 +08:00
Rostislav M. Georgiev
5d6cf8ecd4 kubeadm: Distinguish between user supplied and generated component configs
Until now, users were always asked to manually convert a component config to a
version supported by kubeadm, if kubeadm is not supporting its version.
This is true even for configs generated with older kubeadm versions, hence
getting users to make manual conversions on kubeadm generated configs.
This is not appropriate and user friendly, although, it tends to be the most
common case. Hence, we sign kubeadm generated component configs stored in
config maps with a SHA256 checksum. If a configs is loaded by kubeadm from a
config map and has a valid signature it's considered "kubeadm generated" and if
a version migration is required, this config is automatically discarded and a
new one is generated.
If there is no checksum or the checksum is not matching, the config is
considered as "user supplied" and, if a version migration is required, kubeadm
will bail out with an error, requiring manual config migration (as it's today).
The behavior when supplying component configs on the kubeadm command line
does not change. Kubeadm would still bail out with an error requiring migration
if it can recognize their groups but not versions.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2020-06-01 17:57:53 +03:00
Rostislav M. Georgiev
543f29be4e kubeadm: Reduce kubelet.DownloadConfig usage
kubelet.DownloadConfig is an old utility function which takes a client set and
a kubelet version, uses them to fetch the kubelet component config from a
config map, and places it in a local file. This function is simple to use, but
it is dangerous and unnecessary. Practically, in all cases the kubelet
configuration is present locally and does not need to be fetched from a config
map on the cluster (it just needs to be stored in a file).
Furthermore, kubelet.DownloadConfig does not use the kubeadm component configs
module in any way. Hence, a kubelet configuration fetched using it may not be
patched, validated, or otherwise, processed in any way by kubeadm other than
piping it to a file.

This patch replaces all but a single kubelet.DownloadConfig invocation with
equivalents that get the local copy of the kubelet component config and just
store it in a file. The sole remaining invocation covers the
`kubeadm upgrade node --kubelet-version` case.

In addition to that, a possible panic is fixed in kubelet.DownloadConfig and
it now takes the kubelet version parameter as string.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2020-05-19 13:30:45 +03:00
Rostislav M. Georgiev
b881f19c8b kubeadm: Group centric component configs
kubeadm's current implementation of component config support is "kind" centric.
This has its downsides. Namely:
- Kind names and numbers can change between config versions.
  Newer kinds can be ignored. Therefore, detection of a version change is
  considerably harder.
- A component config can have only one kind that is managed by kubeadm.
Thus a more appropriate way to identify component configs is required.

Probably the best solution identified so far is a config group.
A group name is unlikely to change between versions, while the kind names and
structure can.
Tracking component configs by group name allows us to:
- Spot more easily config version changes and manage alternate versions.
- Support more than one kind in a config group/version.
- Abstract component configs by hiding their exact structure.

Hence, this change rips off the old kind based support for component configs
and replaces it with a group name based one. This also has the following
extra benefits:
- More tests were added.
- kubeadm now errors out if an unsupported version of a known component group
  is used.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-11-26 13:55:28 +02:00
Rostislav M. Georgiev
994df0d631 kubeadm: use versioned component configs
This change removes dependencies on the internal types of the kubelet and
kube-proxy component configs. Along with that defaulting and validation is
removed as well. kubeadm will display a warning, that it did not verify the
component config upon load.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-11-06 14:15:57 +02:00
Rostislav M. Georgiev
c394d0fd80 kubeadm: Don't use RBAC helpers
RBAC construction helpers are part of the Kubernetes internal APIs. As such,
we cannot use them once we move to staging.
Hence, replace their use with manual RBAC rule construction.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-06-14 14:08:31 +03:00
Rafael Fernández López
26c9965a97
kubeadm: Add ability to retry ConfigMap get if certain errors happen
During the control plane joins, sometimes the control plane returns an
expected error when trying to download the `kubeadm-config` ConfigMap.
This is a workaround for this issue until the root cause is completely
identified and fixed.

Ideally, this commit should be reverted in the near future.
2019-06-12 17:49:27 +02:00
Lubomir I. Ivanov
6f6b364b9c kubeadm: update output of init, join reset commands
- move most unrelated to phases output to klog.V(1)
- rename some prefixes for consistency - e.g.
[kubelet] -> [kubelet-start]
- control-plane-prepare: print details for each generated CP
component manifest.
- uppercase the info text for all "[reset].." lines
- modify the text for one line in reset
2019-03-06 03:17:35 +02:00
Rostislav M. Georgiev
80e2a3cf07 kubeadm: reduce the usage of InitConfiguration
For historical reasons InitConfiguration is used almost everywhere in kubeadm
as a carrier of various configuration components such as ClusterConfiguration,
local API server endpoint, node registration settings, etc.

Since v1alpha2, InitConfiguration is meant to be used solely as a way to supply
the kubeadm init configuration from a config file. Its usage outside of this
context is caused by technical dept, it's clunky and requires hacks to fetch a
working InitConfiguration from the cluster (as it's not stored in the config
map in its entirety).

This change is a small step towards removing all unnecessary usages of
InitConfiguration. It reduces its usage by replacing it in some places with
some of the following:

- ClusterConfiguration only.
- APIEndpoint (as local API server endpoint).
- NodeRegistrationOptions only.
- Some combinations of the above types, or if single fields from them are used,
  only those field.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-01-28 12:21:01 +02:00
fabriziopandini
c9302caf6c error-imports-cleanups 2019-01-03 13:25:18 +01:00
Lubomir I. Ivanov
9a37f2d878
kubeadm: set pod-infra-container-image for the kubelet
The kubelet allows you to set `--pod-infra-container-image`
(also called `PodSandboxImage` in the kubelet config),
which can be a custom location to the "pause" image in the case
of Docker. Other CRIs are not supported.

Set the CLI flag for the Docker case in flags.go using
WriteKubeletDynamicEnvFile().
2018-11-13 13:10:22 -05:00
yuexiao-wang
cc303c8774 [kubeadm/app/]switch to github.com/pkg/errors
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2018-10-30 16:23:24 +08:00
fabriziopandini
a3d90cc824 kubeadm graduate kubelet-start phase 2018-10-24 12:57:31 +02:00
Benjamin Elder
8b56eb8588 hack/update-gofmt.sh 2018-09-24 12:21:29 -07:00
Benjamin Elder
088cf3c37b find & replace version import 2018-09-24 12:03:24 -07:00
fabriziopandini
3f70af3685 upload and fetch of kubeam config v1alpha3 from cluster 2018-09-04 09:09:55 +02:00
Lucas Käldström
7a840cb4c8
automated: Rename all package references 2018-08-29 19:07:52 +03:00
Lucas Käldström
52f0591ad9
Automated rename from MasterConfiguration to InitConfiguration 2018-07-09 04:55:02 +03:00
Lucas Käldström
495ac9883d
Make kubeadm support {un,}marshalling ComponentConfig structs as different YAML documents 2018-07-08 21:32:28 +03:00
Lucas Käldström
35673da7c5
Start using the new path in the internal config for the ComponentConfig structs 2018-07-08 09:49:34 +03:00
Lucas Käldström
5d96a719fb
kubeadm: Fix a couple of small-ish bugs for v1.11 2018-06-12 18:59:34 +03:00
Davanum Srinivas
2072dc3ce8
Ensure directory is created for kubelet configuration 2018-06-07 15:39:40 -04:00
Lucas Käldström
1a0de9442e
Add a 'kubeadm upgrade node config' command and finish up the kubelet integration work 2018-06-06 23:17:04 +03:00
Lucas Käldström
b48f23b786
kubeadm: Move .NodeName and .CRISocket to a common sub-struct 2018-05-29 17:51:39 +03:00
Lucas Käldström
0aa0f3208a
kubeadm: Write kubelet config file to disk and persist in-cluster. Also write runtime environment file and fixup the kubelet phases command 2018-05-22 09:12:25 +03:00