Skip to main content

Certification track: Professional Cloud Security Engineer (PSE)

Vaultwarden on GKE Autopilot

Vaultwarden on GKE Autopilot

Vaultwarden is a lightweight, self-hosted Bitwarden-compatible password manager written in Rust. This module deploys Vaultwarden on GKE Autopilot on top of the App_GKE foundation, which provisions and manages the shared Google Cloud and Kubernetes infrastructure.

This guide focuses on the cloud services Vaultwarden uses and how to explore and operate them from the Google Cloud Console and the command line. For the mechanics that are common to every GKE application — Workload Identity, ingress, autoscaling, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC Service Controls, backups, and the deployment lifecycle — refer to the App_GKE foundation guide rather than repeating them here.


1. Overview

Vaultwarden runs as a compiled Rust binary in a StatefulSet. The deployment wires together a focused set of Google Cloud services:

CapabilityGoogle Cloud serviceNotes
ComputeGKE AutopilotRust binary pods, 500m CPU / 512 Mi by default, horizontally autoscaled
DatabaseCloud SQL for PostgreSQL 15 (default) or MySQL 8.0Configurable engine; the init job adjusts automatically
Per-pod storageKubernetes PersistentVolumeClaim10 Gi at /data for vault data, RSA keys, and attachments
Object storageCloud StorageA dedicated vaultwarden-attachments bucket
SecretsSecret ManagerDatabase password; Vaultwarden manages its own admin token internally
IngressCloud Load BalancingExternal LoadBalancer, optional custom domain + managed certificate

Sensible defaults worth knowing up front:

  • StatefulSet with a 10 Gi PVC is the default. Vault data (/data) persists across pod restarts and upgrades. Do not switch to Deployment while stateful_pvc_enabled = true.
  • Registrations are closed by default. signups_allowed = false prevents anonymous account creation. Enable only during initial admin setup, then disable.
  • No admin token is auto-generated. The /admin panel is disabled unless you provide ADMIN_TOKEN in environment_variables. This is the secure default.
  • domain must be set for WebAuthn and TOTP. Without the full public URL, 2FA QR codes link to localhost and organisation invitation emails contain broken links.
  • Health probes target /alive, Vaultwarden's dedicated lightweight health endpoint. Vaultwarden starts quickly as a Rust binary; the startup probe uses a 30 s initial delay.
  • Session affinity is ClientIP by default to route a given Bitwarden client consistently to the same pod.

2. Google Cloud Services & How to Explore Them

All commands assume you have run gcloud container clusters get-credentials <cluster> --region <region> --project <project> and that PROJECT, REGION, and NAMESPACE are set. The namespace and other identifiers are reported in the deployment Outputs.

A. GKE Autopilot — the Vaultwarden workload

Vaultwarden pods are scheduled on Autopilot, which bills for the CPU/memory the pods actually request. A StatefulSet with a PersistentVolumeClaim backs the /data directory so vault data survives pod restarts and upgrades. Horizontal Pod Autoscaling sizes the workload between the minimum and maximum replica counts.

  • Console: Kubernetes Engine → Workloads → select the Vaultwarden workload to see pods, revisions, and events. Kubernetes Engine → Services & Ingress shows the external IP.
  • CLI:
    kubectl get pods,svc,hpa,pvc -n "$NAMESPACE"
    kubectl logs -n "$NAMESPACE" statefulset/<service-name> --tail=100
    kubectl describe hpa -n "$NAMESPACE" # current vs target utilisation
    kubectl describe pvc -n "$NAMESPACE" # per-pod storage status

See App_GKE for how Autopilot, scaling, and the StatefulSet workload type are managed.

B. Cloud SQL — PostgreSQL 15 or MySQL 8.0

Vaultwarden stores all vault data in a managed Cloud SQL instance. The default engine is PostgreSQL 15; set database_type = "MYSQL_8_0" to use MySQL instead. Pods connect privately through the Cloud SQL Auth Proxy sidecar over a Unix socket, so no public IP is exposed. On first deploy an initialization Job creates the application database and user.

  • Console: SQL → select the instance for connections, backups, flags, and metrics.
  • CLI:
    gcloud sql instances list --project "$PROJECT"
    gcloud sql instances describe <instance-name> --project "$PROJECT"
    # Open an interactive shell to inspect schema/data:
    gcloud sql connect <instance-name> --user=<db-user> --project "$PROJECT"

The instance name, database name, user, and the Secret Manager secret holding the password are all surfaced in the Outputs. For the connection model, automated backups, and password rotation, see App_GKE.

C. PersistentVolumeClaim and Cloud Storage

Vault data (the Vaultwarden SQLite fallback state, RSA signing keys, attachment metadata, and 2FA configuration) is written to a per-pod PersistentVolumeClaim at /data. A dedicated Cloud Storage bucket (vaultwarden-attachments) is also provisioned for attachment files; the workload service account is granted access automatically.

  • Console: Kubernetes Engine → Storage → PersistentVolumeClaims; Cloud Storage → Buckets for the attachments bucket.
  • CLI:
    kubectl get pvc -n "$NAMESPACE"
    kubectl describe pvc -n "$NAMESPACE" <pvc-name>
    gcloud storage buckets list --project "$PROJECT"
    gcloud storage ls gs://<attachments-bucket>/ # bucket name is in the Outputs

See App_GKE for GCS Fuse and CMEK options.

D. Secret Manager

The database password is stored as a Secret Manager secret and injected into pods at runtime. Vaultwarden manages its own internal admin token and RSA signing keys within the /data volume — those are not stored in Secret Manager.

  • Console: Security → Secret Manager.
  • CLI:
    gcloud secrets list --project "$PROJECT"
    gcloud secrets versions access latest --secret=<secret-name> --project "$PROJECT"

The database password secret name is in the Outputs. See App_GKE for the Secret Store CSI integration and rotation.

E. Networking & ingress

By default the workload is exposed through an external Cloud Load Balancing IP. A custom domain with a Google-managed certificate can be enabled, and a static IP can be reserved so the address survives redeploys. Cloud Armor is strongly recommended to protect the Vaultwarden login endpoints from brute-force attacks.

  • Console: Network services → Load balancing; VPC network → IP addresses.
  • CLI:
    kubectl get ingress,svc -n "$NAMESPACE"
    gcloud compute addresses list --project "$PROJECT"

See App_GKE for custom domains, Cloud Armor, and static IP details.

F. Cloud Logging & Monitoring

Pod stdout/stderr flow to Cloud Logging; GKE and Cloud SQL metrics flow to Cloud Monitoring. An uptime check targeting /alive can be enabled.

  • Console: Logging → Logs Explorer; Monitoring → Dashboards / Alerting.
  • CLI:
    gcloud logging read 'resource.type="k8s_container" AND resource.labels.namespace_name="'"$NAMESPACE"'"' \
    --project "$PROJECT" --limit 50

3. Vaultwarden Application Behaviour

  • First-deploy database setup. An initialization Job creates the Vaultwarden database and user and grants privileges before the application starts. It is idempotent and safe to re-run. The correct job image is selected automatically: postgres:15-alpine for PostgreSQL, mysql:8.0-debian for MySQL.
  • No schema migrations on start. Vaultwarden manages its own internal schema evolution automatically. The init job only creates the database and user; no migration command is needed.
  • No scheduled tasks required. Unlike many web applications, Vaultwarden has no mandatory cron jobs. All vault operations are request-driven.
  • Health path. Both the startup and liveness probes target /alive, which returns OK when the server is ready. The initial delay is 30 s, matching Vaultwarden's fast Rust startup.
  • Admin panel. The /admin panel is disabled unless ADMIN_TOKEN is provided via environment_variables. Generate a secure token and pass it as a non-secret env var (or reference it from Secret Manager via secret_environment_variables).
  • SMTP for notifications. Vaultwarden uses SMTP for account verification, 2FA recovery codes, and emergency-access emails. Configure SMTP_HOST, SMTP_PORT, SMTP_FROM, SMTP_USERNAME, and SMTP_PASSWORD (via secret_environment_variables) as a complete set — partial SMTP configuration causes silent delivery failures.

4. Configuration Variables

Variables are grouped exactly as they appear on the deployment platform. Only settings specific to or notable for Vaultwarden are listed; every other input is inherited from App_GKE with its standard behaviour and defaults.

Group 1 — Project & Identity

VariableDefaultDescription
project_id(required)Target Google Cloud project.
regionus-central1Region for the workload and regional resources.

Group 2 — Deployment Environment

VariableDefaultDescription
tenant_deployment_iddemoShort suffix that makes resource names unique per environment.
support_users[]Emails granted project access and monitoring alerts.
resource_labels{}Labels applied to all resources for cost/ownership tracking.

Group 3 — Application Identity & Vaultwarden Settings

VariableDefaultDescription
application_namevaultwardenBase name for resources. Do not change after first deploy.
application_display_nameVaultwarden Password ManagerFriendly name shown in the Console.
application_description(set)Workload description annotation.
application_version1.32.7Vaultwarden image version tag; increment to roll out a new version.
domain""Full public URL (e.g. https://vault.example.com). Required for WebAuthn, TOTP QR codes, org invites, and attachment links.
signups_allowedfalseAllow new user self-registration. Enable only during initial setup; disable immediately after creating admin accounts.
web_vault_enabledtrueServe the Vaultwarden web UI. Disable for API-only access via native clients.

Group 4 — Runtime & Scaling

VariableDefaultDescription
deploy_applicationtrueSet false to provision infrastructure only.
container_image_sourcecustomcustom builds from the Dockerfile; prebuilt uses an existing image URI.
cpu_limit500mCPU per pod. Vaultwarden is a lightweight Rust binary.
memory_limit512MiMemory per pod.
min_instance_count1Minimum replicas. Keep ≥ 1 to avoid vault unavailability on cold start.
max_instance_count3Maximum replicas (autoscaler ceiling).
container_port80Vaultwarden's Rocket HTTP port. Must match ROCKET_PORT.
enable_cloudsql_volumetrueCloud SQL Auth Proxy sidecar for Unix socket connections. Required.
enable_vertical_pod_autoscalingfalseLet Autopilot tune resource requests automatically.

Group 5 — Environment Variables & Secrets

VariableDefaultDescription
environment_variables(SMTP/log defaults)Plain-text settings. Core ROCKET_PORT, SIGNUPS_ALLOWED, WEB_VAULT_ENABLED, DATA_FOLDER, and optionally DOMAIN are injected automatically. Default includes LOG_LEVEL=warn, SHOW_PASSWORD_HINT=false, and SMTP stub values.
secret_environment_variables{}Map of env var → Secret Manager secret name (e.g. { SMTP_PASSWORD = "vaultwarden-smtp-pass" }).
secret_rotation_period2592000sSecret Manager rotation notification cadence.
secret_propagation_delay30Seconds to wait after secret creation before proceeding.

Group 6 — GKE Backend & Cluster

VariableDefaultDescription
service_typeLoadBalancerHow the Service is exposed.
workload_typeStatefulSetUse StatefulSet for persistent /data storage (default and recommended).
session_affinityClientIPRoutes a given client consistently to the same pod.
network_tags["nfsserver"]Node/pod network tags for firewall rules.
gke_cluster_name""GKE cluster name; leave empty for auto-discovery.
namespace_name""Kubernetes namespace; leave empty to auto-generate.

Group 7 — StatefulSet Persistent Storage

VariableDefaultDescription
stateful_pvc_enabledtrueProvision a PVC for Vaultwarden's /data directory.
stateful_pvc_size10GiPVC size. Increase for large vaults with many attachments.
stateful_pvc_mount_path/dataMount path, matching the DATA_FOLDER env var.
stateful_pvc_storage_classstandard-rwoKubernetes StorageClass.
stateful_headless_servicenullCreate a headless Service for StatefulSet DNS.
stateful_pod_management_policynullPod creation order: OrderedReady or Parallel.
stateful_update_strategynullUpdate strategy: RollingUpdate or OnDelete.
stateful_fs_group0fsGroup GID set in the pod security context.

Group 8 — Resource Quota

VariableDefaultDescription
enable_resource_quotafalseCap namespace CPU/memory/object counts.
quota_memory_requests / quota_memory_limits""Must use binary units (4Gi, 8192Mi) — bare integers are read as bytes and block scheduling.

Group 9 — Reliability Policies

VariableDefaultDescription
enable_pod_disruption_budgettrueProtect availability during node upgrades.
pdb_min_available1Raise min_instance_count above 1 if you need eviction headroom.
enable_topology_spreadfalseSpread pods across zones.

Group 10 — Observability & Health

VariableDefaultDescription
startup_probe_configHTTP /alive, 30 s delay, 6 failuresVaultwarden's dedicated health path; 30 s matches fast Rust startup.
health_check_configHTTP /alive, 30 s delay, 3 failuresLiveness probe.
uptime_check_configdisabledOptional Cloud Monitoring uptime check targeting /alive.
alert_policies[]Optional metric alert policies.

Group 11 — Workload Automation (Jobs & Scheduled Tasks)

VariableDefaultDescription
initialization_jobs[]Leave empty to use the built-in database setup job (selects the correct image for PostgreSQL or MySQL automatically).
cron_jobs[]Vaultwarden has no required scheduled tasks; add custom CronJobs here if needed.

Group 12 — CI/CD & GitHub Integration

Standard App_GKE Cloud Build / Cloud Deploy integration — see App_GKE. Key inputs: enable_cicd_trigger, github_repository_url, github_token, enable_cloud_deploy.

Group 13 — Filesystem (NFS)

VariableDefaultDescription
enable_nfsfalseOptional Filestore NFS volume. Not required for single-replica Vaultwarden (the PVC covers /data). Enable for shared supplementary storage across replicas.
nfs_mount_path/mnt/nfsMount path inside the container.

Group 14 — Cloud Storage & Artifact Registry

VariableDefaultDescription
create_cloud_storagetrueProvision the attachments bucket.
storage_buckets[{ name_suffix = "data" }]Additional buckets.
gcs_volumes[]GCS Fuse volume mounts.
manage_storage_kms_iam / enable_artifact_registry_cmekfalseCMEK options.

Group 16 — Database Backend

VariableDefaultDescription
database_typePOSTGRES_15POSTGRES_15 (default) or MYSQL_8_0. The init job image is selected automatically.
application_database_namevaultwardenDatabase name. Immutable after first deploy.
application_database_uservaultwardenApplication user. Immutable after first deploy.
database_password_length32Generated password length (16–64).
enable_auto_password_rotationfalseZero-downtime DB password rotation.

Group 17 — Backup & Maintenance

VariableDefaultDescription
backup_schedule0 2 * * *Automated backup cron (UTC).
backup_retention_days30Retention; 30-day default reflects vault recovery importance.
enable_backup_import / backup_source / backup_urirestore optionsRestore from a backup on deploy.

Group 18 — Custom SQL Scripts

enable_custom_sql_scripts, custom_sql_scripts_bucket, custom_sql_scripts_path, custom_sql_scripts_use_root — run SQL from a GCS bucket after provisioning. See App_GKE.

Group 19 — Custom Domain, Static IP & Networking

VariableDefaultDescription
enable_custom_domaintrueProvision Ingress for custom hostnames + managed certificate. Only takes effect once application_domains is non-empty.
application_domains[]Hostnames to serve. Also set domain to the full https:// URL.
reserve_static_iptrueStable external IP across redeploys; recommended for DNS stability.

Group 20 — Identity-Aware Proxy (IAP)

VariableDefaultDescription
enable_iapfalseRequire Google sign-in. Note: IAP in front of Vaultwarden may prevent Bitwarden native clients from connecting.
iap_authorized_users / iap_authorized_groups[]Who may access.
iap_oauth_client_id / iap_oauth_client_secret""Required when IAP is enabled (sensitive).
iap_support_email""Shown on the OAuth consent screen.

Group 21 — Cloud Armor

VariableDefaultDescription
enable_cloud_armorfalseRecommended for Vaultwarden. Attach a Cloud Armor WAF policy to protect the login endpoint from brute-force.
admin_ip_ranges[]CIDRs allowed privileged access.
cloud_armor_policy_namedefault-waf-policyPolicy name.

Group 22 — VPC Service Controls & Audit Logging

VariableDefaultDescription
enable_vpc_scfalseEnforce a VPC-SC perimeter (requires organization_id).
vpc_cidr_ranges / vpc_sc_dry_run(set)Access level CIDRs / dry-run mode.
enable_audit_loggingfalseDetailed Cloud Audit Logs.

5. Outputs

These values are returned on a successful deployment and are the quickest way to locate and explore the running resources.

OutputDescription
service_nameKubernetes Service name.
namespaceNamespace the workload runs in.
service_cluster_ipIn-cluster ClusterIP.
stage_service_cluster_ipsMap of ClusterIPs for stage-specific services (Cloud Deploy).
service_external_ipExternal LoadBalancer IP (when a static IP is reserved).
service_urlURL to reach Vaultwarden.
database_instance_nameCloud SQL instance name.
database_nameApplication database name.
database_userApplication database user.
database_password_secretSecret Manager secret holding the DB password.
database_host / database_portDB endpoint (127.0.0.1 via the Auth Proxy) / port.
storage_bucketsCreated Cloud Storage buckets.
network_name / network_exists / regionsVPC network, presence, available regions.
container_image / container_registryDeployed image and Artifact Registry repo.
monitoring_enabled / monitoring_notification_channelsMonitoring status and channels.
initialization_jobs / db_import_jobNames of the setup and (optional) import jobs.
deployment_id / tenant_id / resource_prefixNaming identifiers.
project_id / project_numberProject identifiers.
cicd_enabled / github_repository_url / github_repository_owner / github_repository_name / cicd_configurationCI/CD status and details.
artifact_registry_repository / cloudbuild_trigger_name / cloudbuild_trigger_idRegistry and build trigger.
kubernetes_readyWhether the cluster/workload is ready.
vpc_sc_enabled / vpc_sc_perimeter_name / vpc_sc_dry_run_modeVPC-SC status.
audit_logging_enabled / artifact_registry_cmek_enabledAudit logging and CMEK status.

6. Configuration Pitfalls & Sensible Defaults

Risk: Critical (data loss / outage / security) — High (service degraded) — Medium (cost or partial degradation) — Low (minor).

SettingSensible valueRiskConsequence if wrong
signups_allowedfalseCriticalAny internet user can self-register on the vault while true. Disable immediately after creating admin accounts.
enable_cloudsql_volumetrueCriticalVaultwarden connects to Cloud SQL via Unix socket; disabling causes CrashLoopBackOff immediately.
application_database_name / _userset onceCriticalImmutable after first deploy; renaming recreates the DB/user and Vaultwarden sees an empty vault.
enable_backup_importfalse unless restoringCriticalEnabling without a valid backup_uri fails the import job.
quota_memory_requests / _limitsbinary unitsCriticalBare integers are bytes and block all scheduling.
workload_type + stateful_pvc_enabledStatefulSet / trueCriticalSetting workload_type = "Deployment" alongside stateful_pvc_enabled = true fails at plan time.
domainfull https:// URLHighWithout it, TOTP QR codes link to localhost, org invite emails contain broken links, and attachment URLs are invalid.
database_typeset onceHighChanging after first deploy causes Vaultwarden to connect to an empty database; all credentials appear lost.
container_port80HighMust match ROCKET_PORT; a mismatch means the readiness probe fails and the pod never becomes Ready.
min_instance_count1High0 scales to zero; a password manager becomes unavailable for several seconds on cold start — Bitwarden clients show connection errors.
stateful_pvc_size10GiHighToo small fills up when users store attachments, causing write errors. Increase before filling.
session_affinityClientIPMediumWithout stickiness, in-progress vault sync operations may route to different pods and encounter stale state.
enable_cloud_armorenable for productionMediumWithout Cloud Armor, the Vaultwarden login endpoint is open to brute-force attacks from the internet.
backup_retention_days30 (default, raise for prod)MediumA password manager without adequate backup retention means credential loss on database failure.
pdb_min_available vs min_instance_countleave headroomMedium1/1 can stall node upgrades (single pod cannot be evicted).
enable_iap with native clientsuse with careMediumIAP requires browser-based OAuth; native Bitwarden clients cannot complete the IAP flow.
smtp_* env varsconfigure as a complete setHighPartial SMTP configuration causes silent email delivery failures — 2FA recovery codes and invitation emails are never sent.

For the foundation behaviour referenced throughout — IAM and Workload Identity, autoscaling, ingress and certificates, CI/CD, Cloud Armor, IAP, Binary Authorization, VPC-SC, backups, and image mirroring — see App_GKE. Vaultwarden-specific application configuration shared with the Cloud Run variant is described in Vaultwarden_Common.