Optimize 2 points on the installation for CNI 35/2235/3
authorTrevor Tao <trevor.tao@arm.com>
Wed, 12 Feb 2020 13:57:55 +0000 (21:57 +0800)
committerTrevor Tao <trevor.tao@arm.com>
Wed, 12 Feb 2020 14:12:16 +0000 (22:12 +0800)
Optimize the installation of k8s CNI at 2 sides:

1. Change the parameter order for the most needed
parameters first as the following:
    CNI_TYPE
    POD_NETWORK_CIDR
    K8s_MASTER_IP
    SERVICE_CIDR
    CLUSTER_IP
    DEV_NAME

so that when installing manually, less parameters need to
be input because the default parameters are enough.

2. Taint the master node first for the case there is just
the master node to use. So the daemon pods of a CNI could
be scheduled on the master. If not, the installation for
the CNI may fail due to no node to schedule the pods.

The user could drain or set NoSchedule to close the master
for scheduling if needed:
kubectl drain <master node name>
or:
kubectl taint nodes <master node name> key=value:NoSchedule

Signed-off-by: Trevor Tao <trevor.tao@arm.com>
Change-Id: I8198814af22e687ccb223b9c2b767e64943588a7
Signed-off-by: Trevor Tao <trevor.tao@arm.com>
src/foundation/scripts/setup-cni.sh
src/foundation/scripts/startup.sh

index 1e16d97..f0689de 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# shellcheck disable=SC1073,SC1072,SC1039,SC2059,SC2046
 set -o xtrace
 set -e
 
@@ -10,9 +11,9 @@ fi
 
 CNI_TYPE=${1:-calico}
 POD_NETWORK_CIDR=${2:-192.168.0.0/16}
-CLUSTER_IP=${3:-172.16.1.136} # Align with the value in our K8s setup script
-K8S_MASTER_IP=${4:-10.169.41.173}
-SERVICE_CIDR=${5:-172.16.1.0/24}
+K8S_MASTER_IP=${3:-10.169.41.173}
+SERVICE_CIDR=${4:-172.16.1.0/24}
+CLUSTER_IP=${5:-172.16.1.136} # Align with the value in our K8s setup script
 DEV_NAME=${6:-}
 
 SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
@@ -107,12 +108,19 @@ install_danm(){
   install_flannel
 }
 
+
 install_cilium(){
   ${SCRIPTS_DIR}/cni/cilium/cilium_install.sh
 
   # Deploying cilium CNI
   kubectl create -f ${SCRIPTS_DIR}/cni/cilium/quick-install.yaml
 }
+
+# Remove the taints on master node
+# Taint master before installing the CNI for the case that there is
+# only one master node
+kubectl taint nodes --all node-role.kubernetes.io/master- || true
+
 case ${CNI_TYPE} in
  'calico')
         echo "Install calico ..."
@@ -152,5 +160,3 @@ case ${CNI_TYPE} in
         ;;
 esac
 
-# Remove the taints on master node
-kubectl taint nodes --all node-role.kubernetes.io/master- || true
index 4cc66f5..1687d9d 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/bash
+# shellcheck disable=SC1073,SC1072,SC1039,SC2059,SC2046
 #Install the k8s-master & k8s-worker node from Mgnt node
 #
 set -e
@@ -102,7 +103,7 @@ deploy_k8s () {
 
 
   #Deploy etcd & CNI from master node
-  SETUP_CNI="cd iec/src/foundation/scripts && source setup-cni.sh $CNI_TYPE $POD_NETWORK_CIDR $CLUSTER_IP $K8S_MASTER_IP $SVC_CIDR"
+  SETUP_CNI="cd iec/src/foundation/scripts && source setup-cni.sh $CNI_TYPE $POD_NETWORK_CIDR $K8S_MASTER_IP $SVC_CIDR $CLUSTER_IP"
   sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_CNI}
   SETUP_HELM="cd iec/src/foundation/scripts && source helm.sh"
   sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_HELM}