fix: auto-detect kube-vip interface and tighten SSH fallback
Some checks failed
Terraform Plan / Terraform Plan (push) Has been cancelled
Some checks failed
Terraform Plan / Terraform Plan (push) Has been cancelled
This commit is contained in:
@@ -101,6 +101,15 @@ in
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
iface="${config.terrahome.kubeadm.controlPlaneInterface}"
|
iface="${config.terrahome.kubeadm.controlPlaneInterface}"
|
||||||
|
if ! ip link show "$iface" >/dev/null 2>&1; then
|
||||||
|
iface="$(ip -o -4 route show to default | awk 'NR==1 {print $5}')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "''${iface:-}" ]; then
|
||||||
|
echo "Could not determine network interface for kube-vip"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
suffix="${toString config.terrahome.kubeadm.controlPlaneVipSuffix}"
|
suffix="${toString config.terrahome.kubeadm.controlPlaneVipSuffix}"
|
||||||
pod_subnet="${config.terrahome.kubeadm.podSubnet}"
|
pod_subnet="${config.terrahome.kubeadm.podSubnet}"
|
||||||
service_subnet="${config.terrahome.kubeadm.serviceSubnet}"
|
service_subnet="${config.terrahome.kubeadm.serviceSubnet}"
|
||||||
@@ -155,6 +164,15 @@ in
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
iface="${config.terrahome.kubeadm.controlPlaneInterface}"
|
iface="${config.terrahome.kubeadm.controlPlaneInterface}"
|
||||||
|
if ! ip link show "$iface" >/dev/null 2>&1; then
|
||||||
|
iface="$(ip -o -4 route show to default | awk 'NR==1 {print $5}')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "''${iface:-}" ]; then
|
||||||
|
echo "Could not determine network interface for kube-vip"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
suffix="${toString config.terrahome.kubeadm.controlPlaneVipSuffix}"
|
suffix="${toString config.terrahome.kubeadm.controlPlaneVipSuffix}"
|
||||||
local_ip_cidr=$(ip -4 -o addr show dev "$iface" | awk 'NR==1 {print $4}')
|
local_ip_cidr=$(ip -4 -o addr show dev "$iface" | awk 'NR==1 {print $4}')
|
||||||
if [ -z "''${local_ip_cidr:-}" ]; then
|
if [ -z "''${local_ip_cidr:-}" ]; then
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ remote() {
|
|||||||
local quoted_cmd
|
local quoted_cmd
|
||||||
local candidate
|
local candidate
|
||||||
local candidates=()
|
local candidates=()
|
||||||
|
local rc=0
|
||||||
|
|
||||||
candidates+=("$ACTIVE_SSH_USER")
|
candidates+=("$ACTIVE_SSH_USER")
|
||||||
for candidate in $SSH_USER_CANDIDATES; do
|
for candidate in $SSH_USER_CANDIDATES; do
|
||||||
@@ -100,6 +101,11 @@ remote() {
|
|||||||
ACTIVE_SSH_USER="$candidate"
|
ACTIVE_SSH_USER="$candidate"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rc=$?
|
||||||
|
if [ "$rc" -ne 255 ]; then
|
||||||
|
return "$rc"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Remote command failed for all SSH users on $host_ip"
|
echo "Remote command failed for all SSH users on $host_ip"
|
||||||
|
|||||||
Reference in New Issue
Block a user