Skip to content

Commit 3982436

Browse files
sidharthsuranak8s-ci-robot
authored andcommitted
Use a better shell command to grab the IP address (#241)
Verified the command on the following distros: ubuntu - trusty,xenial,artful,bionic photon - 2.0,3.0 Resolves #239 Change-Id: I99a915874a894baea067983e62950fc4745073b8
1 parent ad7197a commit 3982436

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/cloud/vsphere/provisioner/common/templates.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ systemctl start docker || true
441441
sysctl net.bridge.bridge-nf-call-iptables=1
442442
443443
` +
444-
"PUBLICIP=`ip route get 8.8.8.8 | awk '{printf \"%s\", $NF; exit}'`" + `
444+
"PUBLICIP=`ip route get 8.8.8.8 | awk '{for(i=1; i<=NF; i++) if($i~/src/) print $(i+1)}'`" + `
445445
446446
cat > /etc/systemd/system/kubelet.service.d/20-cloud.conf << EOF
447447
[Service]
@@ -540,10 +540,10 @@ systemctl enable docker
540540
systemctl start docker
541541
542542
` +
543-
"PRIVATEIP=`ip route get 8.8.8.8 | awk '{printf \"%s\", $NF; exit}'`" + `
543+
"PRIVATEIP=`ip route get 8.8.8.8 | awk '{for(i=1; i<=NF; i++) if($i~/src/) print $(i+1)}'`" + `
544544
echo $PRIVATEIP > /tmp/.ip
545545
` +
546-
"PUBLICIP=`ip route get 8.8.8.8 | awk '{printf \"%s\", $NF; exit}'`" + `
546+
"PUBLICIP=`ip route get 8.8.8.8 | awk '{for(i=1; i<=NF; i++) if($i~/src/) print $(i+1)}'`" + `
547547
548548
cat > /etc/systemd/system/kubelet.service.d/20-cloud.conf << EOF
549549
[Service]

0 commit comments

Comments
 (0)