Skip to content

Commit

Permalink
chore: deploy updates to VM metadata (vana-com#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
tnunamak authored Jun 5, 2024
1 parent 849a596 commit 841dc22
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
40 changes: 27 additions & 13 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DEFAULT_NAMESPACE=default
PROJECT=${PROJECT:-corsali-production}
NUM_NODES=${NUM_NODES:-3}
MACHINE_TYPE=${MACHINE_TYPE:-n1-standard-1}
IMAGE=${IMAGE:-timvana/dlp-chatgpt-validator}
IMAGE=${IMAGE:-vanaorg/dlp-chatgpt-validator}
ZONE=${ZONE:-us-central1-a}
DOPPLER_PROJECT=${DOPPLER_PROJECT:-prd}
TAG=${TAG:-latest}
Expand Down Expand Up @@ -57,19 +57,33 @@ fi

echo "Using image: $IMAGE_TAG"

# Loop through node creation
# Loop through node creation or update
for ((i=1; i<=NUM_NODES; i++)); do
VM_NAME="${NAMESPACE}-chatgpt-validator-$i"

# Create the VM instance
gcloud compute instances create "$VM_NAME" \
--project="$PROJECT" \
--zone="$ZONE" \
--machine-type="$MACHINE_TYPE" \
--image-family="ubuntu-2004-lts" \
--image-project="ubuntu-os-cloud" \
--tags="allow-tcp-5555" \
--scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/compute.readonly \
--metadata-from-file startup-script=scripts/startup.sh \
--metadata project="$PROJECT",image="$IMAGE_TAG",env_base64="$ENV_BASE64"
# Check if the instance exists
if gcloud compute instances describe "$VM_NAME" --project="$PROJECT" --zone="$ZONE" > /dev/null 2>&1; then
# Update metadata and startup script for the existing instance
gcloud compute instances add-metadata "$VM_NAME" \
--project="$PROJECT" \
--zone="$ZONE" \
--metadata project="$PROJECT",image="$IMAGE_TAG",env_base64="$ENV_BASE64" \
--metadata-from-file startup-script=scripts/startup.sh

echo "Updated VM instance $VM_NAME"
else
# Create the VM instance if it doesn't exist
gcloud compute instances create "$VM_NAME" \
--project="$PROJECT" \
--zone="$ZONE" \
--machine-type="$MACHINE_TYPE" \
--image-family="ubuntu-2004-lts" \
--image-project="ubuntu-os-cloud" \
--tags="allow-tcp-5555" \
--scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/compute.readonly \
--metadata project="$PROJECT",image="$IMAGE_TAG",env_base64="$ENV_BASE64" \
--metadata-from-file startup-script=scripts/startup.sh

echo "Created VM instance $VM_NAME"
fi
done
4 changes: 2 additions & 2 deletions scripts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# TODO: move this process to an external Vana-only location

export PROJECT=corsali-development
export IMAGE=timvana/dlp-chatgpt-validator
export TAG=vana
export IMAGE=vanaorg/dlp-chatgpt-validator
export TAG=stable

export NUM_NODES=3
export MACHINE_TYPE=n1-standard-2
Expand Down

0 comments on commit 841dc22

Please sign in to comment.