using compass to deploy harbor for private docker registry 41/57041/6
authorhu xinhui <xinhui_hu@foxmail.com>
Fri, 4 May 2018 05:00:33 +0000 (13:00 +0800)
committerwutianwei <wutianwei1@huawei.com>
Wed, 9 May 2018 01:01:58 +0000 (01:01 +0000)
Change-Id: Ice2ee902632a390938c8f5facf3010e712d9c9c3
Signed-off-by: hu xinhui <xinhui_hu@foxmail.com>
deploy.sh
deploy/compass_vm.sh
deploy/launch.sh

index 9c72a5c..fb51a3e 100755 (executable)
--- a/deploy.sh
+++ b/deploy.sh
 # export TAR_URL=file:///home/compass/compass4nfv.iso
 #export TAR_URL=
 
+#export DEPLOY_HARBOR="true"
+#export HABOR_VERSION="1.5.0"
+
+# Set url for download the tar file of harbor
+#export HABOR_DOWNLOAD_URL=https://storage.googleapis.com/harbor-releases/release-$HABOR_VERSION/harbor-offline-installer-v$HABOR_VERSION.tgz
 # Set hardware deploy jumpserver PXE NIC
 # You need to comment out it when virtual deploy.
 #export INSTALL_NIC=eth1
index 1717157..2f909b6 100755 (executable)
@@ -181,6 +181,34 @@ function recover_compass() {
     log_info "launch_compass exit"
 }
 
+function launch_harbor() {
+    local harbor_install_dir=$WORK_DIR/installer
+
+    if [[ ! -d $harbor_install_dir ]]; then
+        mkdir -p $harbor_install_dir
+    fi
+
+    local harbor_cfg=$harbor_install_dir/harbor/harbor.cfg
+    local harbor_docker_compose=$harbor_install_dir/harbor/docker-compose.yml
+    rm -f $WORK_DIR/cache/harbor-offline-installer-v$HABOR_VERSION.tgz
+    curl --connect-timeout 10 -o $WORK_DIR/cache/harbor-offline-installer-v$HABOR_VERSION.tgz  $HABOR_DOWNLOAD_URL
+    tar -zxf $WORK_DIR/cache/harbor-offline-installer-v$HABOR_VERSION.tgz -C $harbor_install_dir
+
+    sed "s/^hostname = .*/hostname = $INSTALL_IP/g" -i $harbor_cfg
+    sed "s/80:80/8080:80/g" -i $harbor_docker_compose
+    sed "s/443:443/8443:443/g" -i $harbor_docker_compose
+    cd $harbor_install_dir/harbor/
+    sudo ./prepare
+    if [ -n "$(docker-compose -f $harbor_docker_compose ps -q)"  ]
+    then
+        log_info "stopping existing Harbor instance ..."
+        docker-compose -f $harbor_docker_compose down -v
+        log_info "remove the odler harbor images ..."
+        sudo docker images | grep 'vmware' | awk '{print $3;}' | xargs docker rmi -f
+    fi
+    ./install.sh
+}
+
 function _check_hosts_reachable() {
     retry=0
 
index 76e8f25..8a00900 100755 (executable)
@@ -90,6 +90,13 @@ else
     log_info "deploy host macs: $machines"
 fi
 
+if [[ "$DEPLOY_HARBOR" == "true" ]]; then
+   if ! launch_harbor;then
+       log_error "launch_harbor failed"
+       exit 1
+   fi
+fi
+
 if [[ "$REDEPLOY_HOST" != "true" ]]; then
     if ! set_compass_machine; then
         log_error "set_compass_machine fail"