Skip to content

Commit

Permalink
ensure kubelet --node-ip is set correctly when joining a cluster (#3216)
Browse files Browse the repository at this point in the history
  • Loading branch information
neoaggelos authored Jun 14, 2022
1 parent 25d81c9 commit 4711817
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/cluster/join.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,17 @@ def store_base_kubelet_args(args_string):
try_set_file_permissions(args_file)


def update_kubelet_node_ip(args_string, hostname_override):
"""
Update the kubelet --node-ip argument if it was set on the node that we join.
:param args_string: the kubelet arguments
:param hostname_override: the source IP address used by the node when joining
"""
if "--node-ip" in args_string:
set_arg("--node-ip", hostname_override, "kubelet")


def replace_admin_token(token):
"""
Replaces the admin token in the known tokens
Expand Down Expand Up @@ -822,7 +833,7 @@ def join_dqlite_worker_node(info, master_ip, master_port, token):
store_cert("serviceaccount.key", info["service_account_key"])

store_base_kubelet_args(info["kubelet_args"])

update_kubelet_node_ip(info["kubelet_args"], hostname_override)
update_cert_auth_kubeproxy(token, info["ca"], master_ip, master_port, hostname_override)
update_cert_auth_kubelet(token, info["ca"], master_ip, master_port)

Expand Down Expand Up @@ -868,6 +879,7 @@ def join_dqlite_master_node(info, master_ip, token):

create_admin_kubeconfig(info["ca"], info["admin_token"])
store_base_kubelet_args(info["kubelet_args"])
update_kubelet_node_ip(info["kubelet_args"], hostname_override)
store_callback_token(info["callback_token"])
update_dqlite(info["cluster_cert"], info["cluster_key"], info["voters"], hostname_override)
# We want to update the local CNI yaml but we do not want to apply it.
Expand All @@ -892,6 +904,8 @@ def join_etcd(connection_parts, verify=True):
hostname_override = None
if "hostname_override" in info:
hostname_override = info["hostname_override"]
update_kubelet_node_ip(info["kubelet_args"], hostname_override)

store_remote_ca(info["ca"])
update_flannel(info["etcd"], master_ip, master_port, token)
update_kubeproxy(info["kubeproxy"], info["ca"], master_ip, info["apiport"], hostname_override)
Expand Down

0 comments on commit 4711817

Please sign in to comment.