From 797fe36fbbeb334ddf043afea77ac4298acbc6f8 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 14 Apr 2017 13:42:21 -0700 Subject: [PATCH] Only deploy etcd server automatically with single node --- ...eploy-env-nfs.sh => deploy-example-nfs.sh} | 12 +--- deploy/longhorn-deploy-env-etcd.sh | 36 ---------- deploy/longhorn-deploy-node.sh | 71 ++++++++++++++----- deploy/longhorn-setup-single-node-env.sh | 52 ++++++++++++++ 4 files changed, 108 insertions(+), 63 deletions(-) rename deploy/{longhorn-deploy-env-nfs.sh => deploy-example-nfs.sh} (76%) delete mode 100755 deploy/longhorn-deploy-env-etcd.sh create mode 100755 deploy/longhorn-setup-single-node-env.sh diff --git a/deploy/longhorn-deploy-env-nfs.sh b/deploy/deploy-example-nfs.sh similarity index 76% rename from deploy/longhorn-deploy-env-nfs.sh rename to deploy/deploy-example-nfs.sh index 32d5353..b3dd37d 100755 --- a/deploy/longhorn-deploy-env-nfs.sh +++ b/deploy/deploy-example-nfs.sh @@ -2,13 +2,6 @@ set -e -network=$1 - -if [ "${network}" == "" ]; then - echo Usage: $(basename $0) \ - exit 1 -fi - echo MAKE SURE you have \"nfs-kernel-common\" installed on the host before starting this NFS server echo Press Ctrl-C to bail out in 3 seconds @@ -16,6 +9,8 @@ sleep 3 echo WARNING: This NFS server won\'t save any data after you delete the container +sleep 1 + source ./common.sh NFS_SERVER=longhorn-nfs-server @@ -25,7 +20,6 @@ BACKUPSTORE_PATH=/opt/backupstore docker run -d \ --name ${NFS_SERVER} \ - --net ${network} \ --privileged \ ${NFS_IMAGE} ${BACKUPSTORE_PATH} @@ -33,7 +27,7 @@ nfs_ip=$(get_container_ip ${NFS_SERVER}) echo NFS server is up echo -echo Use following URL as the Backup Target in the Longhorn: +echo Set following URL as the Backup Target in the Longhorn: echo echo nfs://${nfs_ip}:${BACKUPSTORE_PATH} echo diff --git a/deploy/longhorn-deploy-env-etcd.sh b/deploy/longhorn-deploy-env-etcd.sh deleted file mode 100755 index a8171db..0000000 --- a/deploy/longhorn-deploy-env-etcd.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -set -e - -source ./common.sh - -network=$1 - -if [ ${network} == "" ]; then - echo Usage: $(basename $0) \ - exit 1 -fi - -ETCD_SERVER=longhorn-etcd-server -ETCD_IMAGE=quay.io/coreos/etcd:v3.1.5 - -cleanup $ETCD_SERVER - -docker run -d \ - --name $ETCD_SERVER \ - --volume /etcd-data \ - --network ${network} \ - $ETCD_IMAGE \ - /usr/local/bin/etcd \ - --name longhorn-etcd-server \ - --data-dir /tmp/etcd-data:/etcd-data \ - --listen-client-urls http://0.0.0.0:2379 \ - --advertise-client-urls http://0.0.0.0:2379 - -etcd_ip=$(get_container_ip $ETCD_SERVER) -echo etcd server is up at ${etcd_ip} -echo -echo Use following command on each node to deploy longhorn -echo -echo ./longhorn-deploy-node.sh ${network} ${etcd_ip} -echo diff --git a/deploy/longhorn-deploy-node.sh b/deploy/longhorn-deploy-node.sh index a3d83ef..4da92bf 100755 --- a/deploy/longhorn-deploy-node.sh +++ b/deploy/longhorn-deploy-node.sh @@ -4,14 +4,51 @@ set -e source ./common.sh -network=$1 -etcd_ip=$2 +USAGE="Usage: $(basename $0) -e \ [-n \ -p \]" -if [ "$network" == "" -o "$etcd_ip" == "" ]; then - echo usage: $(basename $0) \ \ +while [[ $# -gt 1 ]] +do + key="$1" + + case $key in + -e|--etcd-ip) + etcd_ip="$2" + shift # past argument + ;; + -n|--network) + network="$2" + shift # past argument + ;; + -p|--ui-port) + port="$2" + shift # past argument + ;; + *) + # unknown + # option + echo ${USAGE} + break + ;; + esac + shift +done + +if [ "$etcd_ip" == "" ]; then + echo ${USAGE} exit 1 fi +network_option= + +if [ "$network" != "" ]; then + network_option="--network ${network}" +fi + +ui_port=8080 +if [ "$port" != "" ]; then + ui_port=$port +fi + set +e iscsiadm_check=`iscsiadm --version 2>&1` if [ $? -ne 0 ]; then @@ -20,18 +57,17 @@ if [ $? -ne 0 ]; then fi set -e -LONGHORN_ENGINE_BINARY_NAME="longhorn-engine-binary" + LONGHORN_ENGINE_IMAGE="rancher/longhorn-engine:046b5a5" - -LONGHORN_MANAGER_NAME="longhorn-manager" -LONGHORN_MANAGER_IMAGE="rancher/longhorn-manager:31b613b" - -LONGHORN_DRIVER_NAME="longhorn-driver" +LONGHORN_MANAGER_IMAGE="rancher/longhorn-manager:5329795" LONGHORN_DRIVER_IMAGE="imikushin/storage-longhorn:8b1bb5c" - -LONGHORN_UI_NAME="longhorn-ui" LONGHORN_UI_IMAGE="rancher/longhorn-ui:5528110" +LONGHORN_ENGINE_BINARY_NAME="longhorn-engine-binary" +LONGHORN_MANAGER_NAME="longhorn-manager" +LONGHORN_DRIVER_NAME="longhorn-driver" +LONGHORN_UI_NAME="longhorn-ui" + # longhorn-binary first, provides binary to longhorn-manager cleanup ${LONGHORN_ENGINE_BINARY_NAME} @@ -46,7 +82,7 @@ cleanup ${LONGHORN_MANAGER_NAME} docker run -d \ --name ${LONGHORN_MANAGER_NAME} \ - --network ${network} \ + ${network_option} \ --privileged \ --uts host \ -v /dev:/host/dev \ @@ -76,16 +112,15 @@ echo ${LONGHORN_DRIVER_NAME} is ready manager_ip=$(get_container_ip ${LONGHORN_MANAGER_NAME}) -host_port=8080 - cleanup ${LONGHORN_UI_NAME} + docker run -d \ --name ${LONGHORN_UI_NAME} \ - --network ${network} \ - -p ${host_port}:8000/tcp \ + ${network_option} \ + -p ${ui_port}:8000/tcp \ -e LONGHORN_MANAGER_IP=http://${manager_ip}:9500 \ ${LONGHORN_UI_IMAGE} echo ${LONGHORN_UI_NAME} is ready echo -echo Longhorn is up at port ${host_port} +echo Longhorn is up at port ${ui_port} diff --git a/deploy/longhorn-setup-single-node-env.sh b/deploy/longhorn-setup-single-node-env.sh new file mode 100755 index 0000000..6c6ed39 --- /dev/null +++ b/deploy/longhorn-setup-single-node-env.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -e + +source ./common.sh + +USAGE="Usage: $(basename $0) [-p \]" + +while [[ $# -gt 1 ]] +do + key="$1" + + case $key in + -p|--ui-port) + port="$2" + shift # past argument + ;; + *) + # unknown + # option + echo ${USAGE} + break + ;; + esac + shift +done + +port_option= +if [ "$port" != "" ]; then + port_option="-p $port" +fi + +ETCD_SERVER=longhorn-etcd-server +ETCD_IMAGE=quay.io/coreos/etcd:v3.1.5 + +cleanup $ETCD_SERVER + +docker run -d \ + --name $ETCD_SERVER \ + --volume /etcd-data \ + $ETCD_IMAGE \ + /usr/local/bin/etcd \ + --name longhorn-etcd-server \ + --data-dir /tmp/etcd-data:/etcd-data \ + --listen-client-urls http://0.0.0.0:2379 \ + --advertise-client-urls http://0.0.0.0:2379 + +etcd_ip=$(get_container_ip $ETCD_SERVER) +echo etcd server is up at ${etcd_ip} +echo + +./longhorn-deploy-node.sh -e ${etcd_ip} $port_option