Only deploy etcd server automatically with single node

This commit is contained in:
Sheng Yang 2017-04-14 13:42:21 -07:00
parent 924da91d9a
commit 797fe36fbb
4 changed files with 108 additions and 63 deletions

View File

@ -2,13 +2,6 @@
set -e
network=$1
if [ "${network}" == "" ]; then
echo Usage: $(basename $0) \<network\>
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

View File

@ -1,36 +0,0 @@
#!/bin/bash
set -e
source ./common.sh
network=$1
if [ ${network} == "" ]; then
echo Usage: $(basename $0) \<network\>
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

View File

@ -4,14 +4,51 @@ set -e
source ./common.sh
network=$1
etcd_ip=$2
USAGE="Usage: $(basename $0) -e \<etcd_ip\> [-n \<network\> -p \<ui_port\>]"
if [ "$network" == "" -o "$etcd_ip" == "" ]; then
echo usage: $(basename $0) \<network_name\> \<etcd_server_ip\>
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}

View File

@ -0,0 +1,52 @@
#!/bin/bash
set -e
source ./common.sh
USAGE="Usage: $(basename $0) [-p \<ui_port\>]"
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