Skip to content

Commit 2fec824

Browse files
authored
Create Cloud Run service for website on production (#2143)
- Move terraform config out into out of oss-vdb-test environment into base osv module - Build/push osv-website docker image to oss-vdb registry - Recreate osv-website Cloud Deploy pipeline on production, and add production target.
1 parent c737cd0 commit 2fec824

File tree

6 files changed

+85
-64
lines changed

6 files changed

+85
-64
lines changed

deployment/build-and-stage.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,22 +217,21 @@ steps:
217217
waitFor: ['build-nvd-cve-osv', 'cloud-build-queue']
218218

219219
# Build/push Website image
220-
# TODO(michaelkedar): The image gets saved on oss-vdb-test while we experiment with migration
221220
- name: 'gcr.io/cloud-builders/docker'
222221
entrypoint: 'bash'
223-
args: ['-c', 'docker pull gcr.io/oss-vdb-test/osv-website:latest || exit 0']
222+
args: ['-c', 'docker pull gcr.io/oss-vdb/osv-website:latest || exit 0']
224223
id: 'pull-website'
225224
waitFor: ['setup']
226225
- name: 'gcr.io/cloud-builders/docker'
227226
args: ['buildx', 'build', '--build-arg', 'BUILDKIT_INLINE_CACHE=1',
228-
'-t', 'gcr.io/oss-vdb-test/osv-website:latest', '-t', 'gcr.io/oss-vdb-test/osv-website:$COMMIT_SHA',
229-
'-f', 'gcp/appengine/Dockerfile', '--cache-from', 'gcr.io/oss-vdb-test/osv-website:latest', '--pull', '.']
227+
'-t', 'gcr.io/oss-vdb/osv-website:latest', '-t', 'gcr.io/oss-vdb/osv-website:$COMMIT_SHA',
228+
'-f', 'gcp/appengine/Dockerfile', '--cache-from', 'gcr.io/oss-vdb/osv-website:latest', '--pull', '.']
230229
env:
231230
- BUILDKIT_PROGRESS=plain
232231
id: 'build-website'
233232
waitFor: ['pull-website']
234233
- name: 'gcr.io/cloud-builders/docker'
235-
args: ['push', '--all-tags', 'gcr.io/oss-vdb-test/osv-website']
234+
args: ['push', '--all-tags', 'gcr.io/oss-vdb/osv-website']
236235
waitFor: ['build-website', 'cloud-build-queue']
237236

238237
# Build/push NVD mirror image
@@ -302,11 +301,10 @@ steps:
302301
dir: deployment/clouddeploy/gke-indexer
303302

304303
# Website
305-
# TODO(michaelkedar): Move off of oss-vdb-test for prod
306304
- name: 'gcr.io/cloud-builders/gcloud'
307-
args: ['deploy', 'releases', 'create', 'osv-$SHORT_SHA', '--project=oss-vdb-test', '--region=us-central1',
305+
args: ['deploy', 'releases', 'create', 'osv-$SHORT_SHA', '--project=oss-vdb', '--region=us-central1',
308306
'--delivery-pipeline=osv-website', '--images',
309-
"osv-website=gcr.io/oss-vdb-test/osv-website:$COMMIT_SHA"
307+
"osv-website=gcr.io/oss-vdb/osv-website:$COMMIT_SHA"
310308
]
311309
dir: deployment/clouddeploy/osv-website
312310

deployment/clouddeploy/osv-website/clouddeploy.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ serialPipeline:
77
stages:
88
- targetId: staging-website
99
profiles: [ staging ]
10-
# - targetId: production-website
11-
# profiles: [ prod ]
10+
- targetId: production-website
11+
profiles: [ prod ]
1212
---
1313

1414
apiVersion: deploy.cloud.google.com/v1
@@ -22,18 +22,18 @@ executionConfigs:
2222
- usages:
2323
- RENDER
2424
- DEPLOY
25-
serviceAccount: deployment@oss-vdb-test.iam.gserviceaccount.com # TODO(michaelkedar): remember to change service account back
26-
# ---
25+
serviceAccount: [email protected]
26+
---
2727

28-
# apiVersion: deploy.cloud.google.com/v1
29-
# kind: Target
30-
# metadata:
31-
# name: production-website
32-
# description: oss-vdb website instance
33-
# run:
34-
# location: projects/oss-vdb/locations/us-west2
35-
# executionConfigs:
36-
# - usages:
37-
# - RENDER
38-
# - DEPLOY
39-
# serviceAccount: [email protected]
28+
apiVersion: deploy.cloud.google.com/v1
29+
kind: Target
30+
metadata:
31+
name: production-website
32+
description: oss-vdb website instance
33+
run:
34+
location: projects/oss-vdb/locations/us-west2
35+
executionConfigs:
36+
- usages:
37+
- RENDER
38+
- DEPLOY
39+
serviceAccount: [email protected]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: serving.knative.dev/v1
2+
kind: Service
3+
metadata:
4+
name: osv-website
5+
spec:
6+
template:
7+
metadata:
8+
annotations:
9+
autoscaling.knative.dev/minScale: '1'
10+
run.googleapis.com/vpc-access-connector: projects/oss-vdb/locations/us-west2/connectors/connector
11+
spec:
12+
containers:
13+
- image: osv-website
14+
env:
15+
- name: REDISHOST
16+
value: '10.85.52.228'
17+
- name: REDISPORT
18+
value: '6379'
19+
startupProbe:
20+
httpGet:
21+
path: /_ah/warmup # TODO(michaelkedar): Better endpoint for these
22+
livenessProbe:
23+
httpGet:
24+
path: /_ah/warmup

deployment/deploy-prod.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ steps:
2424
args: ['deploy', 'releases', 'promote', '--quiet', '--release=osv-$SHORT_SHA', '--region=us-central1', '--delivery-pipeline=osv-api', '--to-target=production-api-multi', '--annotations=tag=$TAG_NAME']
2525
- name: gcr.io/cloud-builders/gcloud
2626
args: ['deploy', 'releases', 'promote', '--quiet', '--release=osv-$SHORT_SHA', '--region=us-central1', '--delivery-pipeline=gke-indexer', '--to-target=production-indexer', '--annotations=tag=$TAG_NAME']
27+
- name: gcr.io/cloud-builders/gcloud
28+
args: ['deploy', 'releases', 'promote', '--quiet', '--release=osv-$SHORT_SHA', '--region=us-central1', '--delivery-pipeline=osv-website', '--to-target=production-website', '--annotations=tag=$TAG_NAME']
2729

2830
# Tag the deployed images with the git tag
2931
- name: gcr.io/cloud-builders/gcloud
@@ -50,6 +52,8 @@ steps:
5052
args: ['container', 'images', 'add-tag', '--quiet', 'gcr.io/oss-vdb/cpe-repo-gen:$COMMIT_SHA', 'gcr.io/oss-vdb/cpe-repo-gen:$TAG_NAME']
5153
- name: gcr.io/cloud-builders/gcloud
5254
args: ['container', 'images', 'add-tag', '--quiet', 'gcr.io/oss-vdb/osv-server:$COMMIT_SHA', 'gcr.io/oss-vdb/osv-server:$TAG_NAME']
55+
- name: gcr.io/cloud-builders/gcloud
56+
args: ['container', 'images', 'add-tag', '--quiet', 'gcr.io/oss-vdb/osv-website:$COMMIT_SHA', 'gcr.io/oss-vdb/osv-website:$TAG_NAME']
5357

5458
serviceAccount: 'projects/oss-vdb/serviceAccounts/[email protected]'
5559
options:

deployment/terraform/environments/oss-vdb-test/website.tf

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
resource "google_cloud_run_v2_service" "website" {
2+
project = var.project_id
3+
name = "osv-website"
4+
location = "us-west2"
5+
6+
template {
7+
containers {
8+
image = "gcr.io/oss-vdb/osv-website:latest" # Placeholder image.
9+
}
10+
}
11+
12+
lifecycle {
13+
ignore_changes = [
14+
# To be managed by Cloud Deploy.
15+
template,
16+
traffic,
17+
labels,
18+
client
19+
]
20+
prevent_destroy = true
21+
}
22+
}
23+
24+
# Allow unauthenticated access
25+
resource "google_cloud_run_service_iam_binding" "website" {
26+
project = var.project_id
27+
location = google_cloud_run_v2_service.website.location
28+
service = google_cloud_run_v2_service.website.name
29+
role = "roles/run.invoker"
30+
members = [
31+
"allUsers"
32+
]
33+
}
34+
35+
# TODO: Set up Google Cloud Load Balancing + Network Endpoint Group (NEG)

0 commit comments

Comments
 (0)