Skip to content

Commit cb18c82

Browse files
RKE2 cluster banner update if ip changes (#21)
1 parent f2939ae commit cb18c82

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

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

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,42 @@ else
116116
fi
117117

118118
# Start RKE2
119+
# Check RKE2 start first time or after reboot
120+
IPCHECK="/var/lib/rancher/ip.log"
121+
if [ -f "$IPCHECK" ]; then
122+
# Check if the IP address changes, if changes print the banner
123+
host_prev_ip=$(cat "$IPCHECK")
124+
125+
# Get the system ip
126+
pub_inerface_name=$(route | grep '^default' | grep -o '[^ ]*$')
127+
host_ip=$(ifconfig "${pub_inerface_name}" | grep 'inet ' | awk '{print $2}')
128+
129+
if [[ "$host_ip" != "$host_prev_ip" ]]; then
130+
echo "IP changed"
131+
CHANGE_MSG="Warning: The Edge Node IP("$host_ip") has changed since RKE2 install!"
132+
banner="
133+
================================================================================
134+
Edge Microvisor Toolkit - cluster bring up problem
135+
136+
****Looks the IP address of the system chnaged since RKE2 install*****
137+
138+
OLD RKE2 cluster IP "$host_prev_ip"
139+
NEW RKE2 cluster IP "$host_ip"
140+
141+
IP address of the Node:
142+
"$host_prev_ip" - Ensure IP address is persistent across the reboot!
143+
See: https://ranchermanager.docs.rancher.com/getting-started
144+
/installation-and-upgrade/installation-requirements#node-ip-
145+
addresses $CHANGE_MSG
146+
147+
=================================================================================
148+
"
149+
# Print the banner
150+
echo "$banner" | sudo tee /dev/tty0
151+
else
152+
CHANGE_MSG="IP address remained same after reboot."
153+
fi
154+
fi
119155
echo "$(date): Starting RKE2 4/13" | sudo tee -a /var/log/cluster-init.log | sudo tee /dev/tty0
120156
sudo systemctl enable --now rke2-server.service
121157

@@ -201,23 +237,13 @@ export KUBECONFIG
201237
echo "$(date): The cluster installation is complete 13/13" | sudo tee -a /var/log/cluster-init.log | sudo tee /dev/tty0
202238
echo "$(date): The cluster installation is complete!"
203239

204-
# Print banner
205240
IP=$(sudo -E KUBECONFIG=/etc/rancher/rke2/rke2.yaml /var/lib/rancher/rke2/bin/kubectl get nodes -o jsonpath='{range .items[*]}{.status.addresses[?(@.type=="InternalIP")].address}{"\n"}{end}')
206241
IPCHECK="/var/lib/rancher/ip.log"
207-
CHANGE_MSG=""
208242

209243
if [ ! -f "$IPCHECK" ]; then
210244
echo "$IP" | sudo tee "$IPCHECK"
211-
else
212-
CLUSTER_IP=$(cat "$IPCHECK")
213-
if ip addr | grep -qw "$CLUSTER_IP"; then
214-
echo "IP address $CLUSTER_IP is present."
215-
CHANGE_MSG="IP address remained same after reboot."
216-
else
217-
echo "IP changed"
218-
CHANGE_MSG="Warning: The Edge Node IP has changed since RKE2 install!"
219-
fi
220245
fi
246+
# Print banner
221247

222248
banner="
223249
===================================================================

0 commit comments

Comments
 (0)