Fix the bug of installation failure 55/1455/2
authorJingzhao.Ni <Jingzhao.Ni@arm.com>
Fri, 23 Aug 2019 05:04:08 +0000 (13:04 +0800)
committerJingzhao.Ni <Jingzhao.Ni@arm.com>
Fri, 23 Aug 2019 09:05:34 +0000 (17:05 +0800)
When using the K8s with 1.13.0 version, it will result
deployment failed. It mainly because that parsing the
"kubeadm join" command in older version is different
from 1.15.2 version. When deploying the K8s with 1.13.0
by scripts, the IP address was consider as token key.
Finally, it results in the worker node installation failed.

Signed-off-by: Jingzhao.Ni <Jingzhao.Ni@arm.com>
Change-Id: I088392e416bf4ef92be78196a83987279d29e268

src/foundation/scripts/startup.sh

index f9a41e9..123039d 100755 (executable)
@@ -51,8 +51,11 @@ deploy_k8s () {
   sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${INSTALL_SOFTWARE}
   sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_MASTER} | tee ${LOG_FILE}
 
-  TOKEN_ID=$(grep "\--token " ./${LOG_FILE} | cut -f5 -d' ')
-  TOKEN_CA_SH256=$(grep "\--discovery-token-ca-cert-hash " ./${LOG_FILE} |cut -f2 -d':')
+  TOKEN=$(grep "\--token " ./${LOG_FILE})
+  TOKEN_ID=$(echo ${TOKEN#*"token "}|cut -f1 -d' ')
+
+  SH256=$(grep "\--discovery-token-ca-cert-hash " ./${LOG_FILE})
+  TOKEN_CA_SH256=${SH256#*"sha256:"}
 
   KUBEADM_JOIN_CMD="kubeadm join ${K8S_MASTER_IP}:6443 --token ${TOKEN_ID} --discovery-token-ca-cert-hash sha256:${TOKEN_CA_SH256}"