summaryrefslogtreecommitdiffstats
path: root/xci/installer/kubespray/deploy.sh
diff options
context:
space:
mode:
authorwutianwei <wutianwei1@huawei.com>2018-02-09 09:20:45 +0800
committerwutianwei <wutianwei1@huawei.com>2018-03-20 10:15:34 +0800
commitedf351b82f6df2b5fd91c02be9f22f7ae4dccc55 (patch)
tree9fc6b0902dae3c88a4e75e61ceeb0d339815f5be /xci/installer/kubespray/deploy.sh
parentd0c16a80bac11f52bba7cc6e7152ec47aababe1f (diff)
Access the K8s dashboard and configure the CLI in opnfv host
1. Add the type: NodePort in dashboard service. the default is ClustIP, which cannot access from outside. 2. Print the url ,user, password for user to access dashboard. 3. configure the kubectl CLI in opnfv host. Change-Id: I6cb6e6f7547412139ece0c40a85de67a9edce0ef Signed-off-by: wutianwei <wutianwei1@huawei.com>
Diffstat (limited to 'xci/installer/kubespray/deploy.sh')
-rwxr-xr-xxci/installer/kubespray/deploy.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/xci/installer/kubespray/deploy.sh b/xci/installer/kubespray/deploy.sh
index b68fec90..7695894b 100755
--- a/xci/installer/kubespray/deploy.sh
+++ b/xci/installer/kubespray/deploy.sh
@@ -79,4 +79,36 @@ ssh root@$OPNFV_HOST_IP "set -o pipefail; cd releng-xci/.cache/repos/kubespray;\
-i opnfv_inventory/inventory.cfg cluster.yml -b | tee setup-kubernetes.log"
scp root@$OPNFV_HOST_IP:~/releng-xci/.cache/repos/kubespray/setup-kubernetes.log \
$LOG_PATH/setup-kubernetes.log
+echo
+echo "-----------------------------------------------------------------------"
echo "Info: Kubernetes installation is successfully completed!"
+echo "-----------------------------------------------------------------------"
+
+# Configure the kubernetes authentication in opnfv host.
+ssh root@$OPNFV_HOST_IP "mkdir -p ~/.kube/;\
+ cp -f ~/admin.conf ~/.kube/config; \
+ cp -f ~/kubectl /usr/local/bin"
+
+echo "Login opnfv host ssh root@$OPNFV_HOST_IP
+according to the user-guide to create a service
+https://kubernetes.io/docs/user-guide/walkthrough/k8s201/"
+
+echo
+echo "-----------------------------------------------------------------------"
+echo "Info: Kubernetes login details"
+echo "-----------------------------------------------------------------------"
+
+# Get the dashborad URL
+DASHBOARD_SERVICE=$(ssh root@$OPNFV_HOST_IP "kubectl get service -n kube-system |grep kubernetes-dashboard")
+DASHBOARD_PORT=$(echo ${DASHBOARD_SERVICE} | awk '{print $5}' |awk -F "[:/]" '{print $2}')
+KUBER_SERVER_URL=$(ssh root@$OPNFV_HOST_IP "grep -r server ~/.kube/config")
+echo "Info: Kubernetes Dashboard URL:"
+echo $KUBER_SERVER_URL | awk '{print $2}'| sed -n "s#:[0-9]*\$#:$DASHBOARD_PORT#p"
+
+# Get the dashborad user and password
+MASTER_IP=$(echo ${KUBER_SERVER_URL} | awk '{print $2}' |awk -F "[:/]" '{print $4}')
+USER_CSV=$(ssh root@$MASTER_IP " cat /etc/kubernetes/users/known_users.csv")
+USERNAME=$(echo $USER_CSV |awk -F ',' '{print $2}')
+PASSWORD=$(echo $USER_CSV |awk -F ',' '{print $1}')
+echo "Info: Dashboard username: ${USERNAME}"
+echo "Info: Dashboard password: ${PASSWORD}"