Add deploy code, moved from rancher/longhorn-manager
This commit is contained in:
parent
507e62ecd7
commit
924da91d9a
28
deploy/common.sh
Normal file
28
deploy/common.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
cleanup(){
|
||||
name=$1
|
||||
set +e
|
||||
docker rm -vf ${name}
|
||||
set -e
|
||||
}
|
||||
|
||||
get_container_ip() {
|
||||
container=$1
|
||||
for i in `seq 1 5`
|
||||
do
|
||||
ip=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container`
|
||||
if [ "$ip" != "" ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
|
||||
if [ "$ip" == "" ]
|
||||
then
|
||||
echo cannot find ip for $container
|
||||
exit -1
|
||||
fi
|
||||
echo $ip
|
||||
}
|
36
deploy/longhorn-deploy-env-etcd.sh
Executable file
36
deploy/longhorn-deploy-env-etcd.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/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
|
39
deploy/longhorn-deploy-env-nfs.sh
Executable file
39
deploy/longhorn-deploy-env-nfs.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
|
||||
sleep 3
|
||||
|
||||
echo WARNING: This NFS server won\'t save any data after you delete the container
|
||||
|
||||
source ./common.sh
|
||||
|
||||
NFS_SERVER=longhorn-nfs-server
|
||||
NFS_IMAGE=docker.io/erezhorev/dockerized_nfs_server
|
||||
|
||||
BACKUPSTORE_PATH=/opt/backupstore
|
||||
|
||||
docker run -d \
|
||||
--name ${NFS_SERVER} \
|
||||
--net ${network} \
|
||||
--privileged \
|
||||
${NFS_IMAGE} ${BACKUPSTORE_PATH}
|
||||
|
||||
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
|
||||
echo nfs://${nfs_ip}:${BACKUPSTORE_PATH}
|
||||
echo
|
91
deploy/longhorn-deploy-node.sh
Executable file
91
deploy/longhorn-deploy-node.sh
Executable file
@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
source ./common.sh
|
||||
|
||||
network=$1
|
||||
etcd_ip=$2
|
||||
|
||||
if [ "$network" == "" -o "$etcd_ip" == "" ]; then
|
||||
echo usage: $(basename $0) \<network_name\> \<etcd_server_ip\>
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set +e
|
||||
iscsiadm_check=`iscsiadm --version 2>&1`
|
||||
if [ $? -ne 0 ]; then
|
||||
echo Cannot find \`iscsiadm\` on the host, please install \`open-iscsi\` package
|
||||
exit 1
|
||||
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_DRIVER_IMAGE="imikushin/storage-longhorn:8b1bb5c"
|
||||
|
||||
LONGHORN_UI_NAME="longhorn-ui"
|
||||
LONGHORN_UI_IMAGE="rancher/longhorn-ui:5528110"
|
||||
|
||||
# longhorn-binary first, provides binary to longhorn-manager
|
||||
cleanup ${LONGHORN_ENGINE_BINARY_NAME}
|
||||
|
||||
docker run --name ${LONGHORN_ENGINE_BINARY_NAME} \
|
||||
--network none \
|
||||
${LONGHORN_ENGINE_IMAGE} \
|
||||
/bin/bash
|
||||
echo ${LONGHORN_ENGINE_BINARY_NAME} is ready
|
||||
|
||||
# now longhorn-manager
|
||||
cleanup ${LONGHORN_MANAGER_NAME}
|
||||
|
||||
docker run -d \
|
||||
--name ${LONGHORN_MANAGER_NAME} \
|
||||
--network ${network} \
|
||||
--privileged \
|
||||
--uts host \
|
||||
-v /dev:/host/dev \
|
||||
-v /var/run:/var/run \
|
||||
-v /var/lib/rancher/longhorn:/var/lib/rancher/longhorn \
|
||||
--volumes-from ${LONGHORN_ENGINE_BINARY_NAME} \
|
||||
${LONGHORN_MANAGER_IMAGE} \
|
||||
launch-manager -d \
|
||||
--orchestrator docker \
|
||||
--engine-image ${LONGHORN_ENGINE_IMAGE} \
|
||||
--etcd-servers http://${etcd_ip}:2379
|
||||
echo ${LONGHORN_MANAGER_NAME} is ready
|
||||
|
||||
# finally longhorn-driver
|
||||
cleanup ${LONGHORN_DRIVER_NAME}
|
||||
|
||||
docker run -d \
|
||||
--name ${LONGHORN_DRIVER_NAME} \
|
||||
--network none \
|
||||
--privileged \
|
||||
-v /run:/run \
|
||||
-v /var/run:/var/run \
|
||||
-v /dev:/host/dev \
|
||||
-v /var/lib/rancher/volumes:/var/lib/rancher/volumes:shared \
|
||||
${LONGHORN_DRIVER_IMAGE}
|
||||
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 \
|
||||
-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}
|
Loading…
Reference in New Issue
Block a user