From: Srinivasan Selvam Date: Fri, 16 Aug 2019 09:27:40 +0000 (+0000) Subject: k8s_centos X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=d82d1e5b563990cadf065c377bc234cc00860005;hp=-c;p=eliot.git k8s_centos Signed-off-by: Srinivasan Selvam Change-Id: I7ee802d859e4418d282eb69b405eda250871a4a7 --- d82d1e5b563990cadf065c377bc234cc00860005 diff --git a/scripts/common_centos.sh b/scripts/common_centos.sh index 5532ac2..1fb51b3 100755 --- a/scripts/common_centos.sh +++ b/scripts/common_centos.sh @@ -52,6 +52,13 @@ gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF +# Set SELinux in permissive mode (effectively disabling it) +setenforce 0 +sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config + +yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes +systemctl enable --now kubelet + sudo yum install -y kubeadm-${KUBE_VERSION} sudo systemctl start docker && sudo systemctl enable docker diff --git a/scripts/k8smaster_centos.sh b/scripts/k8smaster_centos.sh index 2681b6e..c78bc0d 100755 --- a/scripts/k8smaster_centos.sh +++ b/scripts/k8smaster_centos.sh @@ -25,12 +25,6 @@ rm hostname.tmp sudo yum install -y kubelet-${KUBE_VERSION} kubectl-${KUBE_VERSION} \ kubernetes-cni-${KUBERNETES_CNI} -sudo systemctl start kubelet #&& sudo systemctl enable kubelet - -sudo docker info | grep -i cgroup -sudo sed -i 's/cgroup-driver=systemd/cgroup-driver=cgroupfs/g' \ -/etc/systemd/system/kubelet.service.d/10-kubeadm.conf - sudo systemctl daemon-reload sudo systemctl restart kubelet diff --git a/scripts/setup.sh b/scripts/setup.sh index 07cecd3..4062c7e 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -70,9 +70,9 @@ setup_k8sworkers() nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) - sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON} < /dev/null - sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER} < /dev/null - sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN} < /dev/null + sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON} < /dev/null 2>&1 + sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER} < /dev/null 2>&1 + sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN} < /dev/null 2>&1 done < nodelist > /dev/null 2>&1 } @@ -87,9 +87,9 @@ setup_k8smaster_centos() # Setup ELIOT Node setup_k8sworkers_centos - cd cni/calico - kubectl apply -f rbac.yaml - kubectl apply -f calico.yaml + kubectl apply -f cni/calico/rbac.yaml + kubectl apply -f cni/calico/calico.yaml + } @@ -102,24 +102,24 @@ setup_k8sworkers_centos() git clone ${ELIOT_REPO} &&\ cd eliot/scripts && source common_centos.sh" + # SETUP_WORKER_COMMON_CENTOS="cd /root/eliot/scripts && source common_centos.sh" + KUBEADM_TOKEN=$(sudo kubeadm token create --print-join-command) KUBEADM_JOIN_CENTOS="sudo ${KUBEADM_TOKEN}" - - # Read all the Worker Node details from nodelist file. - while read line - do - nodeinfo="${line}" - nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) - nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) - nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) - sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON_CENTOS} < /dev/null - #sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_CENTOS} < /dev/null - sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN_CENTOS} < /dev/null - done < nodelist + # Read all the Worker Node details from nodelist file. + while read line + do + nodeinfo="${line}" < /dev/null 2>&1 + nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) < /dev/null 2>&1 + nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) < /dev/null 2>&1 + nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) < /dev/null 2>&1 + sudo sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON_CENTOS} < /dev/null 2>&1 + sudo sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN_CENTOS} < /dev/null 2>&1 + done < nodelist > /dev/null 2>&1 } -#verify kubernetes setup by deploying nginx server. +# verify kubernetes setup by deploying nginx server. verify_k8s_status(){ set -o xtrace @@ -128,7 +128,7 @@ verify_k8s_status(){ install_cadvisor_edge(){ set -o xtrace - SETUP_CADVISOR_ATEDGE="cd eliot/scripts/ && source cadvisorsetup.sh" + SETUP_CADVISOR_ATEDGE="cd eliot/scripts/ && source cadvisorsetup.sh" while read line do nodeinfo="${line}"