Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

Commit b7a654d

Browse files
authored
Merge pull request #122 from xwu2git/master
mkvolume to use ip in ssh/scp
2 parents 724a9e4 + 896ded6 commit b7a654d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

deployment/kubernetes/mkvolume.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
DIR=$(dirname $(readlink -f "$0"))
44

55
echo "Making volumes..."
6-
awk -v DIR="$DIR" '
6+
HOSTS=$(kubectl get node -o 'custom-columns=NAME:.status.addresses[?(@.type=="Hostname")].address,IP:.status.addresses[?(@.type=="InternalIP")].address' | awk '!/NAME/{print $1":"$2}')
7+
awk -v DIR="$DIR" -v HOSTS="$HOSTS" '
8+
BEGIN{
9+
split(HOSTS,tmp1," ");
10+
for (i in tmp1) {
11+
split(tmp1[i],tmp2,":");
12+
host2ip[tmp2[1]]=tmp2[2];
13+
}
14+
}
715
/name:/ {
816
gsub("-","/",$2)
917
content="\""DIR"/../../volume/"$2"\""
@@ -12,7 +20,7 @@ awk -v DIR="$DIR" '
1220
path=$2
1321
}
1422
/- ".*"/ {
15-
host=substr($2,2,length($2)-2);
23+
host=host2ip[substr($2,2,length($2)-2)];
1624
paths[host][path]=1;
1725
contents[host][path]=content
1826
}

0 commit comments

Comments
 (0)