Commit Graph

105 Commits

Author SHA1 Message Date
Tobias Giese
ea46c91868 kubeadm: promote member after the static pod manifest was written
Signed-off-by: Tobias Giese <tobias.giese@mercedes-benz.com>
Co-authored-by: Christian Schlotter <christi.schlotter@gmail.com>
2023-01-16 11:11:58 +01:00
Paco Xu
b3deecfb17 add etcd as learner mode and promote when fg EtcdLearnerMode is enabled
- use etcd backoff to wait; still has many warning messages
Signed-off-by: Paco Xu <paco.xu@daocloud.io>
2022-12-16 21:09:59 +08:00
Paco Xu
241445759e add go:build no windows for some control-plane related UT for kubeadm 2022-09-26 17:17:41 +08:00
Claudiu Belu
d192029e6a unittests: Fixes cmd unit tests for Windows
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- filepath.IsAbs does not consider "/" or "\" as absolute paths, even
  though files can be addressed as such.
- paths not properly joined (filepath.Join should be used).
- files not closed, which means that they cannot be removed / renamed.
- some assertions fail due to slashes / backslashes not matching.
- backslashes need to be escaped in yaml files, or put between ''
instead of "".
2022-08-26 16:03:13 +03:00
Lukasz Szaszkiewicz
81dec8bc6a kubeadm: pass etcd progress notification flag to etcd
The experimental-watch-progress-notify-interval flag specifies an interval
at which etcd sends data to the kube-api server.

It is used by the WatchBookmark feature which is GA since 1.17.
It will be used by a new WatchList feature which is Alpha since 1.25

In addition to that the feature was graduated to GA (non-experiment) in etcd 3.5 without any code changes
2022-07-25 12:28:51 +02:00
Lubomir I. Ivanov
2829fc03e3 kubeadm: use non-serializable startup probe for etcd pods
As per the etcd maintainers' recommendation - startup probes
shouldn't be serialized, while the liveness probes should be.
2022-06-30 20:26:32 +03:00
Lubomir I. Ivanov
29148f61ac kubeadm: add serializable health checks for etcd probes
Use the etcd 3.5.3+ HTTP(s) endpoint "/health?serializable=true",
to allow the kubelet liveness and starup probes in the
kubeadm generated etcd.yaml (static Pod) to track
individual member health instead of tracking the whole
etcd cluster health.
2022-05-16 20:18:35 +03:00
Lubomir I. Ivanov
c9386abd5f kubeadm: add etcd flag for member data consistency
Include the flag "--experimental-initial-corrupt-check"
in etcd static pod manifests to ensure
etcd member data consistency.

The etcd feature is planned for graduation in 3.6,
at which point we should switch to using the flag
without the "experimental" prefix.
2022-03-28 20:47:49 +03:00
ahrtr
972dc46a1f replace deprecated io/ioutil with os and io for cmd 2022-02-01 13:59:41 +08:00
SataQiu
aed6f56257 kubeadm: make the phase prefix and capitalization consistent 2022-01-16 00:01:35 +08:00
XinYang
72fd01095d
re-order imports for kubeadm
Signed-off-by: XinYang <xinydev@gmail.com>
2021-08-17 22:40:46 +08:00
Haleygo
95e000fd65 support kubeadm join dry-run 2021-08-10 23:43:54 +08:00
Ian Gann
c8431f42d9 kubeadm: Reduce the backoff time of AddMember for etcd
This change optimizes the kubeadm/etcd `AddMember` client-side function
by stopping early in the backoff loop when a peer conflict is found
(indicating the member has already been added to the etcd cluster). In
this situation, the function will stop early and relay a call to
`ListMembers` to fetch the current list of members to return. With this
optimization, front-loading a `ListMembers` call is no longer necessary,
as this functionally returns the equivalent response.

This helps reduce the amount of time taken in situational cases where an
initial client request to add a member is accepted by the server, but
fails client-side.

This situation is possible situationally, such as if network latency
causes the request to timeout after it was sent and accepted by the
cluster. In this situation, the following loop would occur and fail with
an `ErrPeerURLExist` response, and would be stuck until the backoff
timeout was met (roughly ~2min30sec currently).

Testing Done:

* Manual testing with an etcd cluster. Initial "AddMember` call was
  successful, and the etcd manifest file was identical to prior version
  of these files. Subsequent calls to add the same member succeeded
  immediately (retaining idempotency), and the resulting manifest file
  remains identical to previous version as well. The difference, this
  time, is the call finished ~2min25sec faster in an identical test in
  the environment tested with.
2021-08-05 13:11:42 -07: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
Vinayak Goyal
5a0756c5f4 Update etcd in kubeadm to run as non-root. 2021-06-16 17:30:46 -07:00
Vinayak Goyal
e6bf19bcf6 Update CreateInitStaticPodManifestFiles, CreateStaticPodFiles and CreateLocalEtcdStaticPodManifestFile to take into account if the command was run as dry-run. 2021-06-09 15:01:42 -07:00
Jack Francis
ff164f9013 feat: remove ephemeral-storage etcd requirement 2021-06-07 16:03:10 -07:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
Ian Gann
dc70c79a00 Fix bug in Member Exists Join for Kubeadm etcd join
In kubeadm etcd join there is a a bug that exists where,
if a peer already exists in etcd, it attempts to mitigate
by continuing and generating the etcd manifest file. However,
this existing "member name" may actually be unset, causing
subsequent etcd consistency checks to fail.

This change checks if the member name is empty - if it is,
it sets the member name to the node name, and resumes.
2020-12-17 11:54:02 -08:00
Lubomir I. Ivanov
8ece27bf4b kubeadm: remove the --experimental-kustomize feature
The feature was replaced by --experimental-patches and deprecated in
1.19.
2020-09-18 03:49:53 +03:00
knight42
2ebd293780
feat(kubeadm): specify resource requests in etcd pod spec
Signed-off-by: knight42 <anonymousknight96@gmail.com>
2020-09-04 11:54:21 +08:00
Kubernetes Prow Robot
d71a09271c
Merge pull request #92017 from neolit123/1.19-patches
kubeadm: introduce --experimental-patches and deprecate --experimental-kustomize
2020-07-02 04:17:01 -07:00
Lubomir I. Ivanov
ceb768ccbd kubeadm: apply patches to static Pods
Add PatchStaticPod() in staticpod/utils.go

Apply patches to static Pods in:
- phases/controlplane/CreateStaticPodFiles()
- phases/etcd/CreateLocalEtcdStaticPodManifestFile() and
CreateStackedEtcdStaticPodManifestFile()

Add unit tests and update Bazel.
2020-06-26 02:14:47 +03:00
Lubomir I. Ivanov
144778db83 kubeadm: plumb the patches option trough init/join/upgrade
This changes adds the "patches" option in all places where
the "kustomize" option is already present.
2020-06-26 02:14:47 +03:00
Lubomir I. Ivanov
94af045324 kubeadm: don't re-add an etcd member if it already exists for "join"
If an etcd member with the same address already exists, don't re-add it.
Instead, use the existing member list for creating the "initial cluster"
that is written for this etcd server instance static Pod.
2020-06-15 20:22:13 +03:00
Kubernetes Prow Robot
40076c856e
Merge pull request #91179 from SataQiu/startup-probe-20200517
kubeadm: add startup probes for static Pods to protect slow starting containers
2020-06-02 18:10:31 -07:00
Kubernetes Prow Robot
02637bb250
Merge pull request #91145 from tnqn/kubeadm-reset-error
kubeadm: skip removing last etcd member in reset phase
2020-05-27 15:04:01 -07:00
SataQiu
e04a2b3b26 kubeadm: add startup probes for static Pods to protect slow starting containers
Signed-off-by: SataQiu <1527062125@qq.com>
2020-05-21 11:12:36 +08:00
Quan Tian
9cc416e7df kubeadm: do not remove the only remaining etcd member during reset
If this is the only remaining stacked etcd member in the cluster,
calling RemoveMember() is not needed.
2020-05-21 02:12:36 +08: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
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
Antonio Ojea
335a3e9efb kubeadm: use correct IP family for etcd localhost
kubeadm always use the IPv4 localhost address by defaultA for etcd

The probe hostname is obtained before the generation of the etcd
parameters, so it can't detect the right IP familiy for the
host of the probe.
This causes that with IPv6 clusters doesn't work because the probe
uses the IPv4 localhost address.

This patchs configures the right localhost address based on the used
AdvertiseAddress IP family.
2019-11-30 17:25:30 +01:00
Ted Yu
2167321adb Remove Client#ClusterAvailable from interface 2019-08-29 07:40:34 -07:00
Kubernetes Prow Robot
d54c5163e0
Merge pull request #81458 from fabriziopandini/kubeadm-kustomize-ux
kubeadm: kustomize-ux
2019-08-22 05:46:32 -07:00
Lubomir I. Ivanov
99b64f1e8e kubeadm: use etcd's /health endpoint for it's liveness probe
Etcd v3.3.0 added the --listen-metrics-urls flag which allows specifying
addition URLs to the already present /health and /metrics endpoints.

While /health and /metrics are enabled for URLS defined with
--listen-client-urls (v3+ ?) they do require HTTPS.

Replace the present etcdctl based liveness probe with a standard HTTP
GET v1.Probe that connects to http://127.0.0.1:2381/health.

These endpoints are not reachable from the outside and only available
for localhost connections.
2019-08-16 01:06:49 +03:00
fabriziopandini
a92e7975d2 kubeadm-kustomize-ux 2019-08-15 09:14:31 +02:00
fabriziopandini
97181595f0 kubeadm-kustomize-core 2019-08-12 14:16:51 +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
pytimer
83f5296a14 kubeadm: Remove etcd member from the etcd cluster when reset the control plane node 2019-02-22 09:13:01 +08:00
SataQiu
7edea2b77f kubeadm cleanup: master -> control-plane 2019-02-13 23:13:31 +08:00
Rafael Fernández López
981bf1930c
kubeadm: do not create etcd datastore if we are in dryrun mode
This allows for kubeadm tests to pass when run with an unprivileged
user.
2019-02-06 22:59:19 +01: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
Rafael Fernández López
6dc6ce78d9
kubeadm: adapt timeout for new etcd member to join 2019-01-20 12:39:53 +01:00
Rafael Fernández López
b4cb3fd37c
kubeadm: wait for the etcd cluster to be available when growing it
When the etcd cluster grows we need to explicitly wait for it to be
available. This ensures that we are not implicitly doing this in
following steps when they try to access the apiserver.
2019-01-18 12:04:39 +01:00
Davanum Srinivas
836f413cf1
Create /var/lib/etcd with 0700
If we let the hostpath with DirectoryOrCreate to create this directory
it defaults to 0755. A default install should use 0700 for better
security especially if the directory is not present.

Change-Id: Idc0266685895767b0d1c5710c8a4fb704805652f
2018-12-08 19:42:58 -05:00
Dane LeBlanc
99887716c5 Fix kubeadm etcd manifests to use brackets around IPv6 addrs
When 'kubeadm init ...' is used with an IPv6 kubeadm configuration,
kubeadm currently generates an etcd.yaml manifest that uses IP:port
combinatins where the IP is an IPv6 address, but it is not enclosed
in square brackets, e.g.:
    - --advertise-client-urls=https://fd00:20::2:2379
For IPv6 advertise addresses, this should be of the form:
    - --advertise-client-urls=https://[fd00:20::2]:2379

The lack of brackets around IPv6 addresses in cases like this is
causing failures to bring up IPv6-only clusters with Kubeadm as
described in kubernetes/kubeadm Issues #1212.

This format error is fixed by using net.JoinHostPort() to generate
URLs as shown above.

Fixes kubernetes/kubeadm Issue #1212
2018-11-16 15:12:29 -05:00
fabriziopandini
6759334f6e add DNS struct to kubeadm config 2018-11-10 17:27:39 +01:00
Davanum Srinivas
954996e231
Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
2018-11-10 07:50:31 -05:00
Lucas Käldström
5656338b6e
Update unit tests after the rename 2018-11-09 14:47:45 +02:00