Explorar el Código

02k8s-install-centos.sh

lizw hace 10 meses
padre
commit
2b49cedb0a
Se han modificado 1 ficheros con 15 adiciones y 5 borrados
  1. 15 5
      sd_dsl/02k8s-install-centos.sh

+ 15 - 5
sd_dsl/02k8s-install-centos.sh

@@ -1430,11 +1430,19 @@ function cert::renew() {
 function init::node_config() {
   local master_index=${master_index:-1}
   local worker_index=${worker_index:-1}
-  log::info "[init]" "Get $MGMT_NODE InternalIP."
-  command::exec "${MGMT_NODE}" "
-    ip -4 route get 8.8.8.8 2>/dev/null | head -1 | awk '{print \$7}'
-  "
-  get::command_output "MGMT_NODE_IP" "$?" "exit"
+  # 获取MGMT_NODE机器的内网IP
+  if [[ "$MGMT_NODE" == "127.0.0.1" || "$MGMT_NODE_IP" == "" ]]; then
+      log::info "[init]" "Get $MGMT_NODE InternalIP."
+      command::exec "${MGMT_NODE}" "
+          ip -4 route get 8.8.8.8 2>/dev/null | head -1 | awk '{print \$7}'
+      "
+      get::command_output "MGMT_NODE_IP" "$?" "exit"
+      if [[ "$MGMT_NODE" != "$MGMT_NODE_IP" ]]; then
+          log::warning "[init]" "ip不相同: $MGMT_NODE(MGMT_NODE) != $MGMT_NODE_IP(MGMT_NODE_IP)"
+      fi
+  else
+      MGMT_NODE_IP=$MGMT_NODE
+  fi
   # master
   for host in $MASTER_NODES
   do
@@ -2798,6 +2806,8 @@ while [ "${1:-}" != "" ]; do
                             ;;
     -U | --upgrade-kernel ) UPGRADE_KERNEL_TAG=1
                             ;;
+    --mgmt-node-ip )        MGMT_NODE_IP="first_master_ip"
+                            ;;
     -of | --offline-file )  shift
                             OFFLINE_TAG=1
                             OFFLINE_FILE=${1:-$OFFLINE_FILE}