github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/deploy/dev/k8s/utils/deploy_ais.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 IMAGE_NAME=aistorage/aisnode-minikube 6 7 source ../utils.sh 8 9 echo "Enter number of storage targets:" 10 read -r TARGET_CNT 11 is_number ${TARGET_CNT} 12 13 echo "Enter number of proxies (gateway):" 14 read -r PROXY_CNT 15 is_number ${PROXY_CNT} 16 if [[ ${PROXY_CNT} -lt 1 ]]; then 17 exit_error "${PROXY_CNT} is less than 1" 18 fi 19 20 source utils/parse_fsparams.sh 21 source utils/parse_cld.sh 22 23 export DOCKER_IMAGE="${IMAGE_NAME}:latest" 24 25 echo "Build and push to local registry: (y/n) ?" 26 read -r build 27 if [[ "$build" == "y" ]]; then 28 export REGISTRY_URL="localhost:5000" && \ 29 ./utils/build_aisnode.sh 30 export DOCKER_IMAGE="${REGISTRY_URL}/${DOCKER_IMAGE}" 31 fi 32 33 34 PRIMARY_PORT=8080 35 36 export HOSTNAME_LIST="$(minikube ip)" 37 export AIS_BACKEND_PROVIDERS=${AIS_BACKEND_PROVIDERS} 38 export TARGET_CNT=${TARGET_CNT} 39 INSTANCE=0 40 41 echo "Enable HTTPS: (y/n)?" 42 read -r https 43 if [[ "$https" == "y" ]]; then 44 source utils/create_certs.sh 45 export HOST_URL="https://$(minikube ip):${PRIMARY_PORT}" 46 export AIS_USE_HTTPS=true 47 export AIS_SKIP_VERIFY_CRT=true 48 export AIS_SERVER_CRT="/var/certs/tls.crt" 49 export AIS_SERVER_KEY="/var/certs/tls.key" 50 export PROTOCOL="HTTPS" 51 else 52 export HOST_URL="http://$(minikube ip):${PRIMARY_PORT}" 53 export AIS_USE_HTTPS=false 54 export AIS_SKIP_VERIFY_CRT=false 55 export AIS_SERVER_CRT="" 56 export AIS_SERVER_KEY="" 57 export PROTOCOL="HTTP" 58 fi 59 60 export AIS_PRIMARY_URL=$HOST_URL 61 62 # Deploying kubernetes cluster 63 echo "Starting kubernetes deployment..." 64 65 echo "Starting primary proxy deployment..." 66 for i in $(seq 0 $((PROXY_CNT-1))); do 67 export POD_NAME="ais-proxy-${i}" 68 export PORT=$((PRIMARY_PORT+i)) 69 export INSTANCE=${INSTANCE} 70 export AIS_LOG_DIR="/tmp/ais/${INSTANCE}/log" 71 (minikube ssh "sudo mkdir -p ${AIS_LOG_DIR}") 72 ([[ $(kubectl get pods | grep -c "${POD_NAME}") -gt 0 ]] && kubectl delete pods ${POD_NAME}) || true 73 envsubst < kube_templates/aisproxy_deployment.yml | kubectl apply -f - 74 INSTANCE=$((INSTANCE+1)) 75 done 76 77 echo "Waiting for the primary proxy to be ready..." 78 kubectl wait --for="condition=ready" --timeout=2m pod ais-proxy-0 79 80 echo "Starting target deployment..." 81 82 for i in $(seq 0 $((TARGET_CNT-1))); do 83 export POD_NAME="ais-target-${i}" 84 export PORT=$((9090+i)) 85 export PORT_INTRA_CONTROL=$((9080+i)) 86 export PORT_INTRA_DATA=$((10080+i)) 87 export TARGET_POS_NUM=$i 88 89 export INSTANCE=${INSTANCE} 90 export AIS_LOG_DIR="/tmp/ais/${INSTANCE}/log" 91 (minikube ssh "sudo mkdir -p ${AIS_LOG_DIR}") 92 93 ([[ $(kubectl get pods | grep -c "${POD_NAME}") -gt 0 ]] && kubectl delete pods ${POD_NAME}) || true 94 envsubst < kube_templates/aistarget_deployment.yml | kubectl create -f - 95 INSTANCE=$((INSTANCE+1)) 96 done 97 98 echo "Waiting for the targets to be ready..." 99 kubectl wait --for="condition=ready" --timeout=2m pods -l type=aistarget 100 101 echo "List of running pods" 102 kubectl get pods -o wide 103 104 echo "Done." 105 echo "" 106 (cd ../../../ && make cli) 107 echo "" 108 109 export AIS_ENDPOINT=$HOST_URL 110 111 echo "Set the \"AIS_ENDPOINT\" for use of CLI:" 112 echo "export AIS_ENDPOINT=$HOST_URL"