Skip to content

Commit 26f84c3

Browse files
hyunsunkrishnajs
andauthored
fix: handle IP address change (#116)
Co-authored-by: Krishnamurthy Jambur <[email protected]>
1 parent 61ea12c commit 26f84c3

File tree

2 files changed

+36
-43
lines changed

2 files changed

+36
-43
lines changed

standalone-node/cluster_installers/sen-k3s-installer.sh

100755100644
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@ echo "$(date): Configuring k3s 1/12" | sudo tee /var/log/cluster-init.log | sudo
1313
sudo mkdir -p /etc/rancher/k3s
1414
sudo bash -c 'cat << EOF > /etc/rancher/k3s/config.yaml
1515
write-kubeconfig-mode: "0644"
16-
cluster-init: true
1716
cluster-cidr: "10.42.0.0/16"
1817
cluster-dns: "10.43.0.10"
1918
data-dir : /var/lib/rancher/k3s
2019
disable-kube-proxy: false
21-
etcd-arg:
22-
- --cipher-suites=[TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256,TLS_CHACHA20_POLY1305_SHA256]
23-
etcd-expose-metrics: false
2420
kube-apiserver-arg:
2521
- "feature-gates=PortForwardWebsockets=true"
2622
- "tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
@@ -42,11 +38,11 @@ sudo mkdir -p $K3S_BIN_PATH
4238

4339
# Set up mirrors
4440
sudo bash -c 'cat << EOF > /etc/rancher/k3s/registries.yaml
45-
mirrors:
46-
docker.io:
41+
mirrors:
42+
docker.io:
4743
endpoint: ["https://localhost.internal:9443"]
48-
49-
rs-proxy.rs-proxy.svc.cluster.local:8443:
44+
45+
rs-proxy.rs-proxy.svc.cluster.local:8443:
5046
endpoint: ["https://localhost.internal:9443"]
5147
EOF'
5248

@@ -140,7 +136,7 @@ IP address of the Node:
140136
$IP - Ensure IP address is persistent across the reboot!
141137
See: https://ranchermanager.docs.rancher.com/getting-started
142138
/installation-and-upgrade/installation-requirements#node-ip-
143-
addresses
139+
addresses
144140
145141
To access and view the cluster's pods run:
146142
source /home/<default-user>/.bashrc

standalone-node/provisioning_scripts/k3s-setup-post-reboot.sh

100755100644
Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,54 @@ do
2020
fi
2121
done
2222
if [[ "$host_ip" != "$host_prev_ip" ]]; then
23-
echo "IP changed"
24-
CHANGE_MSG="Warning: The Edge Node IP($host_ip) has changed since k3s install!"
23+
echo "The Edge Node IP($host_ip) has changed since k3s install"
2524
banner="
2625
================================================================================
27-
Edge Microvisor Toolkit - cluster bring up problem
28-
29-
****Looks the IP address of the system chnaged since k3s install*****
30-
3126
OLD k3s cluster IP $host_prev_ip
3227
NEW k3s cluster IP $host_ip
33-
34-
IP address of the Node:
35-
$host_prev_ip - Ensure IP address is persistent across the reboot!
36-
See: https://ranchermanager.docs.rancher.com/getting-started
37-
/installation-and-upgrade/installation-requirements#node-ip-
38-
addresses $CHANGE_MSG
39-
4028
=================================================================================
4129
"
4230
# Print the banner
4331
sleep 10
4432
echo "$banner" | sudo tee /dev/tty0
45-
else
46-
CHANGE_MSG="IP address remained same after reboot."
33+
4734
while [ true ]
4835
do
4936
k3s_status=$(systemctl is-active k3s)
5037
if [[ "$k3s_status" == "active" ]]; then
51-
52-
echo "Waiting for all extensions to complete the deployment..." | sudo tee /dev/tty0
53-
while sudo -E KUBECONFIG=/etc/rancher/k3s/k3s.yaml /usr/bin/k3s kubectl get pods --all-namespaces --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers | grep -q .; do
54-
echo "Some pods are still not ready. Checking again in 5 seconds..." | sudo tee /dev/tty0
55-
sleep 5
56-
done
38+
echo "Reconfiguring cluster..." | sudo tee /dev/tty0
39+
k3s kubectl delete node edgemicrovisortoolkit
40+
sudo systemctl restart k3s
41+
echo "Restarted k3s" | sudo tee /dev/tty0
5742
break
5843
else
59-
echo "Waiting for k3s services to running state,please wait checking again in few seconds" | sudo tee /dev/tty0
60-
sleep 30
44+
echo "K3s service is still not active. Checking in 10 seconds..." | sudo tee /dev/tty0
45+
sleep 10
6146
fi
6247
done
48+
echo $host_ip > $IPCHECK
49+
fi
6350

64-
# Print banner
51+
while [ true ]
52+
do
53+
k3s_status=$(systemctl is-active k3s)
54+
if [[ "$k3s_status" == "active" ]]; then
55+
56+
echo "Waiting for all extensions to complete the deployment..." | sudo tee /dev/tty0
57+
while sudo -E KUBECONFIG=/etc/rancher/k3s/k3s.yaml /usr/bin/k3s kubectl get pods --all-namespaces --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers | grep -q .; do
58+
echo "Some pods are still not ready. Checking again in 5 seconds..." | sudo tee /dev/tty0
59+
sleep 5
60+
done
61+
break
62+
else
63+
echo "Waiting for k3s services to running state,please wait checking again in few seconds" | sudo tee /dev/tty0
64+
sleep 30
65+
fi
66+
done
6567

66-
banner="
68+
# Print banner
69+
70+
banner="
6771
===================================================================
6872
Edge Microvisor Toolkit - cluster bringup complete
6973
Logs located at:
@@ -72,12 +76,6 @@ Logs located at:
7276
For k3s logs run:
7377
sudo journalctl -fu k3s
7478
75-
IP address of the Node:
76-
$IP - Ensure IP address is persistent across the reboot!
77-
See: https://ranchermanager.docs.rancher.com/getting-started
78-
/installation-and-upgrade/installation-requirements#node-ip-
79-
addresses $CHANGE_MSG
80-
8179
To access and view the cluster's pods run:
8280
source /etc/environment
8381
export KUBECONFIG
@@ -87,6 +85,5 @@ KUBECONFIG available at:
8785
/etc/rancher/k3s/k3s.yaml
8886
===================================================================
8987
"
90-
# Print the banner
91-
echo "$banner" | sudo tee /dev/tty0
92-
fi
88+
# Print the banner
89+
echo "$banner" | sudo tee /dev/tty0

0 commit comments

Comments
 (0)