Code Review
/
iec.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Use Hostname instead of IP to install k8s"
[iec.git]
/
src
/
foundation
/
scripts
/
k8s_master.sh
diff --git
a/src/foundation/scripts/k8s_master.sh
b/src/foundation/scripts/k8s_master.sh
index
5cce155
..
13b76cd
100755
(executable)
--- a/
src/foundation/scripts/k8s_master.sh
+++ b/
src/foundation/scripts/k8s_master.sh
@@
-5,6
+5,10
@@
# Use the src of the default route as the default local IP
DEF_SRC_IP=$(ip route get 8.8.8.8 | awk '{ for (nn=1;nn<=NF;nn++) if ($nn~"src") print $(nn+1) }')
MGMT_IP=${1:-${DEF_SRC_IP}}
# Use the src of the default route as the default local IP
DEF_SRC_IP=$(ip route get 8.8.8.8 | awk '{ for (nn=1;nn<=NF;nn++) if ($nn~"src") print $(nn+1) }')
MGMT_IP=${1:-${DEF_SRC_IP}}
+MGMT_HOST=$(nslookup $MGMT_IP | grep "in-addr.arpa" | cut -d " " -f 3 | awk '{ print substr( $0, 1, length($0)-1 ) }') || true
+#MGMT_HOST=$(nslookup $MGMT_IP | grep "in-addr.arpa" | cut -d " " -f 3 | sed 's/.$//') || true
+echo $MGMT_HOST
+
POD_NETWORK_CIDR=${2:-192.168.0.0/16}
SERVICE_CIDR=${3:-172.16.1.0/24}
POD_NETWORK_CIDR=${2:-192.168.0.0/16}
SERVICE_CIDR=${3:-172.16.1.0/24}
@@
-13,11
+17,20
@@
if [ -z "${MGMT_IP}" ]; then
exit 1
fi
exit 1
fi
+if [ -z "${MGMT_HOST}" ]; then
+ echo "MGMT HOST is not set, using MGMT_IP instead."
+ MGMT_HOST=$MGMT_IP
+fi
+
if ! kubectl get nodes --request-timeout=3s; then
sudo kubeadm config images pull
if ! kubectl get nodes --request-timeout=3s; then
sudo kubeadm config images pull
+ #sudo kubeadm init \
+ # --pod-network-cidr="${POD_NETWORK_CIDR}" \
+ # --apiserver-advertise-address="${MGMT_IP}" \
+ # --service-cidr="${SERVICE_CIDR}"
sudo kubeadm init \
--pod-network-cidr="${POD_NETWORK_CIDR}" \
sudo kubeadm init \
--pod-network-cidr="${POD_NETWORK_CIDR}" \
- --apiserver-advertise-address="${MGMT_
IP
}" \
+ --apiserver-advertise-address="${MGMT_
HOST
}" \
--service-cidr="${SERVICE_CIDR}"
if [ "$(id -u)" = 0 ]; then
--service-cidr="${SERVICE_CIDR}"
if [ "$(id -u)" = 0 ]; then