Commit Graph

118 Commits

Author SHA1 Message Date
Paco Xu
cca7a205ad remove kubeadm v1beta2 support 2023-01-05 21:30:26 +08:00
Dave Chen
e8e804deaa kubeadm: certs renew doesn't support positional args
Signed-off-by: Dave Chen <dave.chen@arm.com>
2022-06-23 19:52:22 +08:00
ahrtr
972dc46a1f replace deprecated io/ioutil with os and io for cmd 2022-02-01 13:59:41 +08:00
calvin
d591b62b4a remove the kubeadm feature gate. 2021-11-29 18:11:02 +08:00
Paco Xu
a0cc3f1c9a cleanup: DualStack GA for kubeadm 2021-09-04 22:38:14 +08:00
XinYang
72fd01095d
re-order imports for kubeadm
Signed-off-by: XinYang <xinydev@gmail.com>
2021-08-17 22:40:46 +08:00
Lubomir I. Ivanov
e3538edc22 kubeadm: update unit tests to support dynamic version updates
Tests under /app and /test would fail if the current/minimum k8s version
is dynamically populated from the version in the kubeadm binary.
Adapt the tests to support that.
2021-08-09 19:42:08 +03: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
Kubernetes Prow Robot
7f47a3aabb
Merge pull request #102108 from neolit123/1.22-kubeadm-remove-csr-flags
kubeadm: remove deprecated "--csr*" flags in "init phase certs"
2021-05-18 23:33:12 -07:00
Lubomir I. Ivanov
92a57fc573 kubeadm: remove deprecated --csr* flags in "init phase certs"
- Remove the deprecated --csr* flags "init phase certs"
- Deprecate the same flags for "certs renew".

For both cases users should be using "certs generate-csr".
2021-05-18 22:35:06 +03:00
Lubomir I. Ivanov
8b9d0dceb1 kubeadm: remove the ClusterStatus object from v1beta3
- Remove the object form v1beta3 and internal type
- Deprecate a couple of phases that were specifically designed / named to
modify the ClusterStatus object
- Adapt logic around annotation vs ClusterStatus retrieval
- Update unit tests
- Run generators
2021-05-17 19:27:36 +03:00
Lubomir I. Ivanov
c2bddf3998 kubeadm: fix unit tests for v1beta1 removal 2021-04-20 03:47:27 +03:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
pacoxu
829b0cde81 kubeadm: promote DualStack feature gate to Beta 2021-02-22 16:03:49 +08:00
Lubomir I. Ivanov
6578e0f6c5 kubeadm: introduce static defaults for unit tests
Add DefaultedStaticInitConfiguration() which can be
used instead of DefaultedInitConfiguration() during unit tests.

The later can be slow since it performs dynamic defaulting.
2021-02-01 19:43:57 +02:00
KeZhang
0abed09a6a remove unused funcs for kubeadm tests 2020-12-22 19:37:30 +08:00
Jordan Liggitt
7e01e38334 Avoid mutating global variables in kubeadm certs phases 2020-09-04 13:36:10 -04:00
Prabhu Jayakumar
bdd0ccaddb
Allow to configure clustername in creation of kubeconfig using kubeadm command
Signed-off-by: Prabhu Jayakumar <j.prabhu91@gmail.com>
2020-08-20 22:59:23 +05:30
Monis Khan
fc4f91f10b cmd/*: fail on unrecognized flags/arguments for component CLI
In case a malformed flag is passed to k8s components
such as "–foo", where "–" is not an ASCII dash character,
the components currently silently ignore the flag
and treat it as a positional argument.

Make k8s components/commands exit with an error if a positional argument
that is not empty is found. Include a custom error message for all
components except kubeadm, as cobra.NoArgs is used in a lot of
places already (can be fixed in a followup).

The kubelet already handles this properly - e.g.:
'unknown command: "–foo"'

This change affects:
- cloud-controller-manager
- kube-apiserver
- kube-controller-manager
- kube-proxy
- kubeadm {alpha|config|token|version}
- kubemark

Signed-off-by: Monis Khan <mok@vmware.com>
Signed-off-by: Lubomir I. Ivanov <lubomirivanov@vmware.com>
2020-05-28 22:06:01 +03:00
Lubomir I. Ivanov
a18502615e kubeadm-init: allow overriding the dry-run temp directory
Allow overriding the dry-run temporary directory with
an env. variable (KUBEADM_INIT_DRYRUN_DIR).

Use the same variable in test/cmd/init_test.go.
This allows running integration tests as non-root.
2020-04-09 01:20:24 +03:00
Lubomir I. Ivanov
04933f3a94 cmd/kubeadm/test/cmd: refactor _test.go files
Make getKubeadmPath() fetch the KUBEADM_PATH env. variable.
Panic if it's missing. Don't handle the "--kubeadm-path"
flag. Remove the same flag from the BUILD bazel test rule.

Don't handle "--kubeadm-cmd-skip" usage of this flag is missing
from the code base.

Remove usage of "kubeadmCmdSkip" as the flag "--kubeadm-cmd-skip"
is never passed.
2020-04-09 00:47:16 +03:00
Dmitry Rozhkov
109f5db5a3 kubeadm: allow creating a cluster with ECDSA keys
The selected key type is defined by kubeadm's --feature-gates option:
if it contains PublicKeysECDSA=true then ECDSA keys will be generated
and used.

By default RSA keys are used still.

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
2020-02-24 11:20:07 +02:00
Rafael Fernández López
b140c5d64b
kubeadm: remove ClusterStatus dependency
While `ClusterStatus` will be maintained and uploaded, it won't be
used by the internal `kubeadm` logic in order to determine the etcd
endpoints anymore.

The only exception is during the first upgrade cycle (`kubeadm upgrade
apply`, `kubeadm upgrade node`), in which we will fallback to the
ClusterStatus to let the upgrade path add the required annotations to
the newly created static pods.
2020-02-20 12:18:56 +01:00
Lubomir I. Ivanov
261f26075c kubeadm: remove the deprecated GA CoreDNS feature-gate
The CoreDNS GA feature-gate in kubeadm was deprecated since 1.13.
The k8s policy is to remove the gate 2 releases after it transitions
to GA:
https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecation

We kept it around for longer to prevent existing setups from breaking
as it caused minimal maintenance overhead.
2020-01-21 04:54:47 +02: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
Rafael Fernández López
cd1ad5646e
kubeadm: add test to detect panics when given certain feature gates
This integration test allows us to detect if a given feature gate will
panic kubeadm. This builds on the assumption that a golang panic makes
the process exit with the code 2.

These tests are not trying to check if the init process succeeds or
not, their only purpose is to ensure that the exit code of the
`kubeadm init` invocation is not 2, thus, reflecting a golang panic.

Some refactors had to be made to the test code, so we return the exit
code along with stdout and stderr.
2019-10-01 20:37:37 +02:00
alan
cd2ecefb80 kubeadm: fix name of CA spell error 2019-08-06 12:01:28 +08:00
Rostislav M. Georgiev
5671ea9cf1 kubeadm: Remove ClusterConfiguration from InitConfiguration in v1beta2
Ever since v1alpha3, InitConfiguration is containing ClusterConfiguration
embedded in it. This was done to mimic the internal InitConfiguration, which in
turn is used throughout the kubeadm code base as if it is the old
MasterConfiguration of v1alpha2.

This, however, is confusing to users who vendor in kubeadm as the embedded
ClusterConfiguration inside InitConfiguration is not marshalled to YAML.
For this to happen, special care must be taken for the ClusterConfiguration
field to marshalled separately.

Thus, to make things smooth for users and to reduce third party exposure to
technical debt, this change removes ClusterConfiguration embedding from
InitConfiguration.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-05-29 12:13:37 +03:00
Rostislav M. Georgiev
9e1ac76c1a kubeadm: Introduce v1beta2 config
Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-04-25 17:10:04 +03:00
aaa
81c30cbeb0 kubeadm cleanup: master -> control-plane
update pul request
2019-04-20 06:15:19 -04:00
Rostislav M. Georgiev
36783eb88b kubeadm: remove v1alpha3
Remove deprecated old v1alpha3 kubeadm config.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-03-08 14:54:51 +02:00
Rostislav M. Georgiev
f64baf755e kubeadm: Don't load deprecated configs
Currently kubeadm supports a couple of configuration versions - v1alpha3 and
v1beta1. The former is deprecated, but still supported.

To discourage users from using it and to speedup conversion to newer versions,
we disable the loading of deprecated configurations by all kubeadm
sub-commands, but "kubeadm config migrate".

v1alpha3 is still present and supported at source level, but cannot be used
directly with kubeadm and some of its internal APIs.

The added benefit to this is, that users won't need to lookup for an old
kubeadm binary after upgrade, just because they were stuck with a deprecated
config version for too long.

To achieve this, the following was done:

- ValidateSupportedVersion now has an allowDeprecated boolean parameter, that
  controls if the function should return an error upon detecting deprecated
  config version. Currently the only deprecated version is v1alpha3.

- ValidateSupportedVersion is made package private, because it's not used
  outside of the package anyway.

- BytesToInitConfiguration and LoadJoinConfigurationFromFile are modified to
  disallow loading of deprecated kubeadm config versions. An error message,
  that points users to kubeadm config migrate is returned.

- MigrateOldConfig is still allowed to load deprecated kubeadm config versions.

- A bunch of tests were fixed to not expect success if v1alpha3 config is
  supplied.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-02-19 12:27:39 +02:00
Rostislav M. Georgiev
51197e4393 kubeadm: Refactor InitConfiguration init APIs
Currently ConfigFileAndDefaultsToInternalConfig and
FetchConfigFromFileOrCluster are used to default and load InitConfiguration
from file or cluster. These two APIs do a couple of completely separate things
depending on how they were invoked. In the case of

ConfigFileAndDefaultsToInternalConfig, an InitConfiguration could be either
defaulted with external override parameters, or loaded from file.
With FetchConfigFromFileOrCluster an InitConfiguration is either loaded from
file or from the config map in the cluster.

The two share both some functionality, but not enough code. They are also quite
difficult to use and sometimes even error prone.

To solve the issues, the following steps were taken:

- Introduce DefaultedInitConfiguration which returns defaulted version agnostic
  InitConfiguration. The function takes InitConfiguration for overriding the
  defaults.

- Introduce LoadInitConfigurationFromFile, which loads, converts, validates and
  defaults an InitConfiguration from file.

- Introduce FetchInitConfigurationFromCluster that fetches InitConfiguration
  from the config map.

- Reduce, when possible, the usage of ConfigFileAndDefaultsToInternalConfig by
  replacing it with DefaultedInitConfiguration or LoadInitConfigurationFromFile
  invocations.

- Replace all usages of FetchConfigFromFileOrCluster with calls to
  LoadInitConfigurationFromFile or FetchInitConfigurationFromCluster.

- Delete FetchConfigFromFileOrCluster as it's no longer used.

- Rename ConfigFileAndDefaultsToInternalConfig to
  LoadOrDefaultInitConfiguration in order to better describe what the function
  is actually doing.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2019-02-11 14:45:34 +02:00
Sascha Grunert
ba7aaa911d
Update dedent to latest release
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-01-17 08:30:07 +01:00
Kubernetes Prow Robot
b89ab2c0c3
Merge pull request #72299 from bart0sh/PR0046-kubeadm-add-CurrentKubernetesVersion
kubeadm: add CurrentKubernetesVersion
2018-12-28 12:03:05 -08:00
Ed Bartosh
639101289c kubeadm: use T.Run API in test/cmd
Used T.Run API for kubeadm tests in cmd/kubeadm/test/cmd/

This should improve testing output and make it more visible
which test is doing what.
2018-12-27 15:22:32 +02:00
Ed Bartosh
e6937ec27f kubeadm: add CurrentKubernetesVersion
Replaced hardcoded "v0.13.0" strings with CurrentKubernetesVersion variable.

This should help with a regular release version bumps.
2018-12-27 11:29:59 +02:00
Ed Bartosh
b40018da7b kubeadm: simplify minimum Kubernetes version bumps
Replaced hardcoded "v0.12.0" strings with MinimumControlPlaneVersion and
MinimumKubeletVersion global variables.

This should help with a regular release version bumps.
2018-12-19 20:41:25 +02:00
yuexiao-wang
0dc0659e07 move test utilites out of /test
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2018-12-04 19:27:17 +08:00
Rostislav M. Georgiev
aa414e139e kubeadm: Bump minimum Kubernetes version to v1.12
Bump MinimumControlPlaneVersion and MinimumKubeletVersion to v1.12 and update
any related tests.

Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
2018-11-20 16:21:49 +02:00
liz
9e8228f14a
Move some test functions into test utils 2018-11-19 14:38:10 -05:00
liz
440a5ad7cb
Don't allow --csr-only for CA certs or all 2018-11-16 15:22:37 -08:00
liz
5fc1a9a87c
Option to generate CSRs instead of issued certificates 2018-11-15 10:47:54 -08:00
Lucas Käldström
731bcdc864
kubeadm: InitConfiguration.APIEndpoint -> LocalAPIEndpoint 2018-11-09 14:47:21 +02:00
Davanum Srinivas
43f523d405
Switch to sigs.k8s.io/yaml from ghodss/yaml
Change-Id: Ic72b5131bf441d159012d67a6a3d87088d0e6d31
2018-11-07 13:17:32 -05:00
yuexiao-wang
4f0c2ecf09 move certs/pkiutil to generic kubeadm utils
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2018-11-01 15:05:19 +08:00
fabriziopandini
3cadb3ca1d kubeadm graduate kubeconfig phase 2018-10-30 16:35:29 +01:00
yuexiao-wang
c0a9b4d04d add BUILD
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
2018-10-30 16:23:52 +08: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