Skip to content

Commit

Permalink
Merge pull request #1764 from Logflare/chore/update-prod-deploy-scripts
Browse files Browse the repository at this point in the history
Chore/update prod deploy scripts
  • Loading branch information
Ziinc authored Oct 17, 2023
2 parents 3e00972 + c7f55f5 commit e9d728c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 9 deletions.
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ deploy.staging.main:
--gcs-log-dir="gs://logflare-staging_cloudbuild-logs/logs"

deploy.staging.versioned:
@echo "If running locally, remember to switch project using `gcloud config set project [project id]` !"
gcloud builds submit \
projects/logflare-staging/locations/us-central1/connections/github-logflare/repositories/Logflare-logflare \
--revision=main \
Expand All @@ -149,13 +150,20 @@ deploy.staging.versioned:


deploy.prod.versioned:
@echo "If running locally, remember to switch project using `gcloud config set project [project id]` !"
gcloud builds submit \
projects/logflare-staging/locations/us-central1/connections/github-logflare/repositories/Logflare-logflare \
projects/logflare-232118/locations/europe-west3/connections/github-logflare/repositories/Logflare-logflare \
--revision=main \
--config=cloudbuild/staging/build-image.yaml \
--config=./cloudbuild/prod/build-image.yaml \
--substitutions=_IMAGE_TAG=$(VERSION) \
--region=us-central1 \
--gcs-log-dir="gs://logflare-staging_cloudbuild-logs/logs"
--region=europe-west3 \
--gcs-log-dir="gs://logflare-prod_cloudbuild-logs/logs"


gcloud builds submit \
--no-source \
--config=./cloudbuild/prod/pre-deploy.yaml \
--substitutions=_IMAGE_TAG=$(VERSION),_NORMALIZED_IMAGE_TAG=$(NORMALIZED_VERSION) \
--region=europe-west3 \
--gcs-log-dir="gs://logflare-prod_cloudbuild-logs/logs"
@echo "Instance template has been created successfully. Complete the deployment by navigating to https://console.cloud.google.com/compute/instanceGroups/list?hl=en&project=logflare-232118"
.PHONY: deploy.staging.main
5 changes: 1 addition & 4 deletions cloudbuild/prod/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ images:
- "gcr.io/$PROJECT_ID/logflare_app:${_IMAGE_TAG}"
- "gcr.io/$PROJECT_ID/logflare_app:latest"

timeout: 1800s

options:
dynamicSubstitutions: true
substitutionOption: 'ALLOW_LOOSE'
machineType: N1_HIGHCPU_32
substitutionOption: "ALLOW_LOOSE"
59 changes: 59 additions & 0 deletions cloudbuild/prod/pre-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
steps:
# create instance template
- name: gcr.io/cloud-builders/gcloud
allowExitCodes: [1]
args:
- compute
- instance-templates
- create-with-container
- $_TEMPLATE_NAME
- --machine-type=c2d-standard-56
- --project=logflare-232118
- --network-interface=network=global,network-tier=PREMIUM
- --maintenance-policy=MIGRATE
- --service-account=compute-engine-2022@logflare-232118.iam.gserviceaccount.com
- --scopes=https://www.googleapis.com/auth/cloud-platform
- --tags=phoenix-http,https-server
- --container-image=${_CONTAINER_IMAGE}
- --container-privileged
- --container-restart-policy=always
- --container-env=LOGFLARE_GRPC_PORT=4001,LOGFLARE_MIN_CLUSTER_SIZE=3
- --create-disk=auto-delete=yes,device-name=logflare-c2-16cpu-docker-global-cos89-13,image=projects/cos-cloud/global/images/cos-stable-101-17162-40-52,mode=rw,size=25,type=pd-ssd
- --no-shielded-secure-boot
- --shielded-vtpm
- --shielded-integrity-monitoring
- --labels=container-vm=cos-stable-101-17162-40-52

# # update instance group to the new template
# - name: gcr.io/cloud-builders/gcloud
# args:
# - beta
# - compute
# - instance-groups
# - managed
# - rolling-action
# - start-update
# - ${_INSTANCE_GROUP}
# - --project=logflare-staging
# - --zone=us-central1-a
# - --type=proactive
# - --max-surge=1
# - --max-unavailable=0
# - --min-ready=60
# - --minimal-action=replace
# - --most-disruptive-allowed-action=replace
# - --replacement-method=substitute
# - --version=template=projects/logflare-staging/global/instanceTemplates/${_TEMPLATE_NAME}

substitutions:
# _COOKIE: default
# _CLUSTER: main
# _INSTANCE_TYPE: c2d-standard-56
# _INSTANCE_GROUP: instance-group-staging-${_CLUSTER}
# _IMAGE_TAG: $SHORT_SHA
_TEMPLATE_NAME: logflare-prod-${_NORMALIZED_IMAGE_TAG}
_CONTAINER_IMAGE: gcr.io/logflare-staging/logflare_app:${_IMAGE_TAG}
timeout: 1800s
options:
dynamicSubstitutions: true
substitutionOption: "ALLOW_LOOSE"

0 comments on commit e9d728c

Please sign in to comment.