Skip to content
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 port forwarding in k8s environments #51

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion bin/client_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ fi
ip addr
ip route

# Handle hostnames in K8s pod environments
if [ -n "$KUBERNETES_SERVICE_HOST" ]; then # if this env var exists, it's probably K8s
# In Kubernetes, extract the base pod name before the first dash
HOSTNAME_REAL=$(hostname | cut -d'-' -f1)
else
# In Docker or other environments, use the full hostname
HOSTNAME_REAL=$(hostname)
fi
echo $HOSTNAME_REAL

# Derived settings
K8S_DNS_IP="$(cut -d ' ' -f 1 <<< "$K8S_DNS_IPS")"
GATEWAY_IP="$(dig +short "$GATEWAY_NAME" "@${K8S_DNS_IP}")"
NAT_ENTRY="$(grep "^$(hostname) " /config/nat.conf || true)"
NAT_ENTRY="$(grep "^$HOSTNAME_REAL " /config/nat.conf || true)"
VXLAN_GATEWAY_IP="${VXLAN_IP_NETWORK}.1"

# Make sure there is correct route for gateway
Expand Down