X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ffoundation%2Fscripts%2Fk8s_master.sh;h=337209ddb7f091da178c676476b44463ced44e14;hb=5cc1b8658cb9185ac5bc6f72d5b6cbc6fa2c37dc;hp=67eecf596e0743f0b4545f026c17670107945eb7;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/foundation/scripts/k8s_master.sh b/src/foundation/scripts/k8s_master.sh index 67eecf5..337209d 100755 --- 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}} +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} @@ -13,12 +17,21 @@ if [ -z "${MGMT_IP}" ]; then exit 1 fi -if ! kubectl get nodes; then +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 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}" \ + # --apiserver-advertise-address="${MGMT_HOST}" \ + # --service-cidr="${SERVICE_CIDR}" if [ "$(id -u)" = 0 ]; then echo "export KUBECONFIG=/etc/kubernetes/admin.conf" | \