Skip to content

Commit d4509b6

Browse files
authored
Set up sitemaps (#2297)
Set up sitemaps generation on a cronjob to a bucket. The bucket is served via the load balancer on paths prefixed by `/sitemap_` This PR contains: - New bucket for prod and test - New bucket backend for serving assets - Load balancer config to redirect requests to the bucket backend when appropriate - Cron config for prod and test
1 parent c50b373 commit d4509b6

File tree

14 files changed

+132
-78
lines changed

14 files changed

+132
-78
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: generate-sitemap
5+
spec:
6+
schedule: "30 8 * * *"
7+
concurrencyPolicy: Forbid
8+
jobTemplate:
9+
spec:
10+
template:
11+
spec:
12+
containers:
13+
- name: generate-sitemap-cron
14+
image: cron
15+
imagePullPolicy: Always
16+
command: ["/usr/local/bin/generate_sitemap/generate_sitemap.py", "--base_url", "$BASE_URL"]
17+
resources:
18+
requests:
19+
cpu: 1
20+
memory: "4G"
21+
limits:
22+
cpu: 1
23+
memory: "6G"
24+
restartPolicy: OnFailure

deployment/clouddeploy/gke-workers/base/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ resources:
1515
- alias-computation.yaml
1616
- nvd-mirror.yaml
1717
- backup.yaml
18+
- generate-sitemap.yaml
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: generate-sitemap
5+
spec:
6+
jobTemplate:
7+
spec:
8+
template:
9+
spec:
10+
containers:
11+
- name: generate-sitemap-cron
12+
env:
13+
- name: BASE_URL
14+
value: "https://test.osv.dev"
15+
- name: GOOGLE_CLOUD_PROJECT
16+
value: oss-vdb-test

deployment/clouddeploy/gke-workers/environments/oss-vdb-test/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ patches:
1717
- path: nvd-mirror.yaml
1818
- path: alias-computation.yaml
1919
- path: backup.yaml
20+
- path: generate-sitemap.yaml
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: generate-sitemap
5+
spec:
6+
jobTemplate:
7+
spec:
8+
template:
9+
spec:
10+
containers:
11+
- name: generate-sitemap-cron
12+
env:
13+
- name: BASE_URL
14+
value: "https://osv.dev"
15+
- name: GOOGLE_CLOUD_PROJECT
16+
value: oss-vdb

deployment/clouddeploy/gke-workers/environments/oss-vdb/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ patches:
1818
- path: nvd-mirror.yaml
1919
- path: alias-computation.yaml
2020
- path: backup.yaml
21+
- path: generate-sitemap.yaml

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module "osv_test" {
88
logs_bucket = "osv-test-logs"
99
cve_osv_conversion_bucket = "osv-test-cve-osv-conversion"
1010
debian_osv_conversion_bucket = "osv-test-debian-osv"
11+
osv_dev_sitemap_bucket = "test-osv-dev-sitemap"
1112
backups_bucket = "osv-test-backup"
1213
backups_bucket_retention_days = 5
1314
affected_commits_backups_bucket = "osv-test-affected-commits"

deployment/terraform/environments/oss-vdb/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module "osv" {
88
cve_osv_conversion_bucket = "cve-osv-conversion"
99
debian_osv_conversion_bucket = "debian-osv"
1010
logs_bucket = "osv-logs"
11+
osv_dev_sitemap_bucket = "osv-dev-sitemap"
1112
backups_bucket = "osv-backup"
1213
backups_bucket_retention_days = 60
1314
affected_commits_backups_bucket = "osv-affected-commits"

deployment/terraform/modules/osv/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,17 @@ resource "google_storage_bucket" "affected_commits_backups_bucket" {
174174
}
175175
}
176176

177+
resource "google_storage_bucket" "osv_dev_sitemap_bucket" {
178+
project = var.project_id
179+
name = var.osv_dev_sitemap_bucket
180+
location = "US"
181+
storage_class = "STANDARD"
182+
uniform_bucket_level_access = true
183+
lifecycle {
184+
prevent_destroy = true
185+
}
186+
}
187+
177188
# Service account permissions
178189
resource "google_service_account" "deployment_service" {
179190
project = var.project_id

deployment/terraform/modules/osv/variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ variable "debian_osv_conversion_bucket" {
4848
description = "Name of bucket to store converted debian advisories in."
4949
}
5050

51+
variable "osv_dev_sitemap_bucket" {
52+
type = string
53+
description = "Name of bucket to store the osv.dev sitemap."
54+
}
55+
5156
variable "api_url" {
5257
type = string
5358
description = "URL to serve the OSV API on. Domain ownership and DNS settings has to be set up manually."
@@ -61,4 +66,4 @@ variable "esp_version" {
6166
variable "website_domain" {
6267
type = string
6368
description = "Domain to serve the OSV website on. Domain ownership and DNS settings must be manually configured."
64-
}
69+
}

0 commit comments

Comments
 (0)