Wire GCS backup to neuron-db-backup-prod bucket (neuron-494301)
Bucket created, SA key stored in Vault at secret/gcs. CronJob ExternalSecret updated to pull from secret/gcs. Hourly restic backup now runs to both R2 and GCS.
This commit is contained in:
@@ -1,70 +1,11 @@
|
|||||||
# Google Cloud Storage — neuron backup bucket + dedicated service account
|
# Google Cloud Storage — neuron backup bucket (neuron-494301 / neurontechnologies)
|
||||||
# Paired with: k8s/neuron-technologies/prod/backup-cronjob.yaml (restic → GCS)
|
# Bucket: gs://neuron-db-backup-prod (created 2026-04-25, US multi-region)
|
||||||
# k8s/backup/cronjob.yaml (restic → GCS for Gitea/Postgres)
|
# SA: neuron-agent@neuron-494301.iam.gserviceaccount.com (Storage Admin)
|
||||||
|
# Key: stored in Vault at secret/gcs.neuron_backup_sa_key
|
||||||
|
# CronJob: k8s/neuron-technologies/prod/backup-cronjob.yaml
|
||||||
|
|
||||||
variable "gcp_project_id" {
|
variable "gcp_project_id" {
|
||||||
description = "Google Cloud project ID"
|
description = "Google Cloud project ID for neurontechnologies"
|
||||||
type = string
|
type = string
|
||||||
default = "neuron-785695"
|
default = "neuron-494301"
|
||||||
}
|
|
||||||
|
|
||||||
provider "google" {
|
|
||||||
project = var.gcp_project_id
|
|
||||||
credentials = fileexists("${path.module}/vault-gcp-sa.json") ? file("${path.module}/vault-gcp-sa.json") : null
|
|
||||||
}
|
|
||||||
|
|
||||||
# ── Neuron prod DB backup bucket ──────────────────────────────────────────────
|
|
||||||
resource "google_storage_bucket" "neuron_backup" {
|
|
||||||
name = "neuron-backup-${var.gcp_project_id}"
|
|
||||||
location = "US"
|
|
||||||
force_destroy = false
|
|
||||||
|
|
||||||
uniform_bucket_level_access = true
|
|
||||||
|
|
||||||
versioning {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
lifecycle_rule {
|
|
||||||
condition { age = 90 }
|
|
||||||
action { type = "Delete" }
|
|
||||||
}
|
|
||||||
|
|
||||||
labels = {
|
|
||||||
managed-by = "terraform"
|
|
||||||
service = "neuron"
|
|
||||||
purpose = "backup"
|
|
||||||
tier = "prod"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# ── Dedicated service account for backup writes ───────────────────────────────
|
|
||||||
resource "google_service_account" "neuron_backup" {
|
|
||||||
account_id = "neuron-backup"
|
|
||||||
display_name = "Neuron Backup"
|
|
||||||
description = "Used by k8s restic CronJobs to write hourly backups to GCS"
|
|
||||||
project = var.gcp_project_id
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_storage_bucket_iam_member" "neuron_backup_writer" {
|
|
||||||
bucket = google_storage_bucket.neuron_backup.name
|
|
||||||
role = "roles/storage.objectAdmin"
|
|
||||||
member = "serviceAccount:${google_service_account.neuron_backup.email}"
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "google_service_account_key" "neuron_backup" {
|
|
||||||
service_account_id = google_service_account.neuron_backup.name
|
|
||||||
# After first apply: copy the base64 key into Vault:
|
|
||||||
# vault kv put secret/data/gcs neuron_backup_sa_key="$(terraform output -raw neuron_backup_sa_key_base64 | base64 -d)"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "neuron_backup_gcs_bucket" {
|
|
||||||
value = google_storage_bucket.neuron_backup.name
|
|
||||||
description = "GCS bucket name for use in RESTIC_REPOSITORY_GCS"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "neuron_backup_sa_key_base64" {
|
|
||||||
value = google_service_account_key.neuron_backup.private_key
|
|
||||||
sensitive = true
|
|
||||||
description = "Base64-encoded SA key JSON — store in Vault: secret/data/gcs.neuron_backup_sa_key"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ spec:
|
|||||||
# ── GCS (secondary) ──
|
# ── GCS (secondary) ──
|
||||||
RESTIC_PASSWORD_GCS: "{{ .restic_password_gcs }}"
|
RESTIC_PASSWORD_GCS: "{{ .restic_password_gcs }}"
|
||||||
GCS_SA_KEY_JSON: "{{ .gcs_neuron_backup_sa_key }}"
|
GCS_SA_KEY_JSON: "{{ .gcs_neuron_backup_sa_key }}"
|
||||||
GOOGLE_PROJECT_ID: "neuron-785695"
|
GOOGLE_PROJECT_ID: "neuron-494301"
|
||||||
RESTIC_REPOSITORY_GCS: "gs:neuron-backup-neuron-785695:/"
|
RESTIC_REPOSITORY_GCS: "gs:neuron-db-backup-prod:/"
|
||||||
data:
|
data:
|
||||||
- secretKey: restic_password
|
- secretKey: restic_password
|
||||||
remoteRef:
|
remoteRef:
|
||||||
@@ -59,7 +59,7 @@ spec:
|
|||||||
schedule: "0 * * * *"
|
schedule: "0 * * * *"
|
||||||
concurrencyPolicy: Forbid
|
concurrencyPolicy: Forbid
|
||||||
failedJobsHistoryLimit: 3
|
failedJobsHistoryLimit: 3
|
||||||
successfulJobsHisticsLimit: 3
|
successfulJobsHistoryLimit: 3
|
||||||
jobTemplate:
|
jobTemplate:
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 2
|
backoffLimit: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user