-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix multi-node cluster not working after restarting docker #2775
Fix multi-node cluster not working after restarting docker #2775
Conversation
Hi @tnqn. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
sed -i "s#${old_ipv4}#${curr_ipv4}#" /var/lib/kubelet/kubeadm-flags.env || true | ||
if [[ "${old_ipv4}" != "${curr_ipv4}" ]]; then | ||
# kubernetes manifests are only present on control-plane nodes | ||
sed -i "s#${old_ipv4}#${curr_ipv4}#" /etc/kubernetes/manifests/*.yaml || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of sed-ing can we kubeadm init phase control-plane {foo} --config ...
to generate a new manifest for component {foo}
. by running it will try to get the node IP, and hopefully that will be the right one?
then again, sed-ing seems straightforward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could work but it would be a change irrelevant to the PR's purpose as the script has been using sed from the beginning and kubeadm.conf
, kubeadm-flags.env
will still need sed. It may require a few more lines to check if this is control-plane node before invoking kubeadm init phase control-plane
.
Do we want to make the change in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sed means we retain any user changes performed manually out of band except the targeted edit we're making.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for commenting, then I suppose we could keep sed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should however, do some fixes so we replace the actual literals instead of letting the IP address be mis-interpreted as a regex, though that bug is not new to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebased the PR (because it's based on out of date version of entrypoint script) and then fixed this, we regex escape the ip addresses now (I think ...)
/ok-to-test |
1 similar comment
/ok-to-test |
c63323d
to
f0b470b
Compare
Sorry, I am going to finish shipping a release to fix non-systemd hosts after the v0.13 changes before we ship any further potentially problematic changes #2767 |
This is the first thing I'd like to see in v0.15.0, assigning to see this through next. |
In a multi-node cluster with single controlplane node, if the controlplane node's IP changes, kube-controller-manager and kube-scheduler would fail to connect kube-apiserver. This patch fixes it by replacing the server address in kubeconfig files of kube-controller-manager and kube-scheduler with the new IP and re-generate a certificate with the new IP for kube-apiserver. Signed-off-by: Quan Tian <[email protected]>
f0b470b
to
7f76c51
Compare
5a1120b
to
5a58dbf
Compare
/hold |
5a58dbf
to
a563fe4
Compare
dropped the base image bump while we iterate more, @tnqn handing back to you. very excited about this PR :-) |
sed -i "s#${old_ipv4}#${curr_ipv4}#" /var/lib/kubelet/kubeadm-flags.env || true | ||
if [[ "${old_ipv4}" != "${curr_ipv4}" ]]; then | ||
# kubernetes manifests are only present on control-plane nodes | ||
sed_ipv4_command="s#$(regex_escape_ip "${old_ipv4}")#${curr_ipv4}#g" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that when I did the regex fix I also:
- stopped computing this string repeatedly
- changed it to a global replace (!) instead of just replacing the first instance
the existing sed pattern carried forward from the existing script was not good :(
it should be reasonable now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Reminded by it, I also added word boundary to sed pattern to avoid mismatch like
# sed "s/1\.1\.1\.2/1.1.1.3/g" <<< "1.1.1.22"
1.1.1.32
@@ -29,7 +29,12 @@ fi | |||
|
|||
grep_allow_nomatch() { | |||
# grep exits 0 on match, 1 on no match, 2 on error | |||
grep "$@" || [[ $? == 1 ]] | |||
grep "$@"|| [[ $? == 1 ]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is an unintended change and reverted it in 3rd patch, please let me know if this is on purpose
I have tested the change by restarting IPv4, IPv6 and dualstack clusters and they worked as expected after controlplane IP changed. |
/retest
|
1. Check for files and error if replacing in them fails 2. Add word boundary to sed pattern to avoid mismatch 3. Regenerate certificate only once when both IPv4 and IPv6 addresses change Signed-off-by: Quan Tian <[email protected]>
59da8d1
to
316e116
Compare
Tentatively unavailable tomorrow, top of my list to revisit when I am back. Still the first thing I intend to merge in v0.15.0, I think this is about good to go, but I want to double check everything again 😅 Thanks again for working on this 🙏 |
it looks good, pushing images so we can soak all the CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
/hold cancel
thank you!!! 😄
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: BenTheElder, tnqn The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
In a multi-node cluster with single controlplane node, if the
controlplane node's IP changes, kube-controller-manager and
kube-scheduler would fail to connect kube-apiserver.
This patch fixes it by replacing the server address in kubeconfig files
of kube-controller-manager and kube-scheduler with the new IP and
re-generate a certificate with the new IP for kube-apiserver.
Signed-off-by: Quan Tian [email protected]
Fixes #2759