Upgrade on GCP
View as MarkdownThe following tutorial upgrades your Materialize deployment running on Google Kubernetes Engine (GKE). The tutorial assumes you have installed the example on Install on GCP.
Upgrade guidelines
When upgrading:
-
Always check the version-specific upgrade notes for your target version:
-
Always upgrade the Materialize Operator before upgrading the Materialize instances.
Prerequisites
Required Tools
Upgrade process
Step 1: Update TF module source version
Update each module’s source to point to the desired release tag, substituting
<RELEASE_TAG> in the code block below with your tag version:
The following code block is not comprehensive. Only the core modules and their dependency chain are shown below.
If your configuration includes additional modules (networking, storage, database, node pools, etc.) provided by Materialize, update those to the same release tag as well.
module "gke" {
source = "github.com/MaterializeInc/materialize-terraform-self-managed//gcp/modules/gke?ref=<RELEASE_TAG>"
# ... your existing configuration ...
}
module "cert_manager" {
source = "github.com/MaterializeInc/materialize-terraform-self-managed//kubernetes/modules/cert-manager?ref=<RELEASE_TAG>"
# ... your existing configuration ...
# Your configuration may have additional dependencies here.
depends_on = [module.gke]
}
module "operator" {
source = "github.com/MaterializeInc/materialize-terraform-self-managed//gcp/modules/operator?ref=<RELEASE_TAG>"
# ... your existing configuration ...
# Your configuration may have additional dependencies here.
depends_on = [module.cert_manager]
}
module "materialize_instance" {
source = "github.com/MaterializeInc/materialize-terraform-self-managed//kubernetes/modules/materialize-instance?ref=<RELEASE_TAG>"
# ... your existing configuration ...
# Your configuration may have additional dependencies here.
depends_on = [module.operator]
}
# Update the source of any additional Materialize-provided modules to the same release tag
Step 2: Explicitly request rollout if using v1alpha1
v1alpha1 is the default CRD version for the Materialize Helm
chart. The Terraform modules default to v1 starting in v4.0.0.
With v1alpha1, instance rollouts require manually rotating a
UUID.
crd_version defaults to
v1. If your instance uses v1alpha1 and you are upgrading to module
version v4.0.0 or greater, set crd_version = "v1alpha1" explicitly to
stay on v1alpha1. Otherwise, applying migrates the instance to v1 and
triggers a rollout. See Adopting the v1
CRD.
To check the CRD version of the Materialize manifest that was applied, run the following:
terraform state show 'module.materialize_instance.kubectl_manifest.materialize_instance' \
| grep -iE 'api_?version|kind'
- If you are using
v1, skip to the Apply the updated TF step. -
If you are using
v1alpha1, you need to update yourterraform.tfvarsfile to set therequest_rolloutvariable to a new UUID value, substituting the example value in the code block below with a UUID you generate (for example, withuuidgen):# ... # ... request_rollout = "DBB4FCEC-1837-44F6-9CF2-3894678DD8D5" # ONLY for v1alpha1
Step 3: Apply the updated TF
-
Initialize the Terraform directory to download the required providers and modules:
terraform init -
Review the execution plan before applying. In particular, check for any resources Terraform plans to destroy and recreate (shown as
-/+in the plan), especially stateful resources such as your cluster, storage, and database:terraform plan -
After reviewing the plan, apply the Terraform configuration.
terraform apply
Step 4: Verify the upgrade
Configure kubectl to connect to your GKE cluster, replacing <your-project-id>
with your GCP project ID:
# gcloud container clusters get-credentials <your-gke-cluster-name> --region <your-region> --project <your-project-id>
gcloud container clusters get-credentials $(terraform output -raw gke_cluster_name) \
--region $(terraform output -raw gke_cluster_location) \
--project <your-project-id>
terraform apply returns once the Materialize custom resource is updated.
The Operator then rolls out the new generation asynchronously, so the new
environmentd pods may take a few minutes to become ready.
-
Check the status of the
materializenamespace:kubectl -n materialize get all -
Check the status of the
materialize-environmentnamespace:kubectl -n materialize-environment get all -
Once a new
environmentdis up (may take a few minutes), confirm the runningenvironmentdversion matches the version you upgraded to. Check theImagefield in the pod description.kubectl -n materialize-environment describe pod -l app=environmentd
If you run into an error during the upgrade, refer to the Troubleshooting.
Enable the monitoring stack
The Terraform modules can install a monitoring stack — Grafana, Thanos, Loki,
Grafana Alloy, and Alertmanager — alongside your deployment, with the
Materialize dashboards pre-installed. You can turn it on during an upgrade, in
the same terraform apply as the version bump.
The stack below arrived in TF v10.0.0, replacing the earlier single Prometheus and Grafana. TF v10.1.0 then added durable state for Grafana and a load balancer to reach it on.
kubernetes/modules/prometheus and kubernetes/modules/grafana were removed
in v10.0.0, not deprecated in place. If your configuration references either
directly, that reference breaks — pin the previous major until you have
migrated.
If you were running the old stack, upgrading destroys its Helm releases and PersistentVolumeClaims. Up to 15 days of local Prometheus data goes with them, along with anything hand-created in the old Grafana. There is no backfill. See Upgrading from the previous stack.
If you use the example configuration
Set the following in your terraform.tfvars:
enable_observability = true
If you instantiate the modules yourself
-
Add the
monitoringmodule, using the same release tag as the rest of your modules:module "monitoring" { source = "github.com/MaterializeInc/materialize-terraform-self-managed//gcp/modules/monitoring?ref=<RELEASE_TAG>" prefix = var.name_prefix project_id = var.project_id region = var.region namespace = "monitoring" # The operator module already creates this namespace. create_namespace = false materialize_instance_namespace = "materialize-environment" materialize_operator_namespace = "materialize" # Grafana's own state. Omit to leave Grafana on SQLite. grafana_database = { network_id = module.networking.network_id } # Reach Grafana without port forwarding. Omit to keep it on ClusterIP. grafana_load_balancer = { ingress_cidr_blocks = var.ingress_cidr_blocks } depends_on = [module.operator] } -
Turn on the operator’s scrape annotations so its pods are collected:
module "operator" { # ... helm_values = { observability = { enabled = true prometheus = { scrapeAnnotations = { enabled = true } } } } }
What this creates
Applying the above adds Cloud Storage buckets for metrics and logs, and — from
TF v10.1.0 — a db-f1-micro Cloud SQL instance for Grafana’s own state and an
internal load balancer to reach Grafana on. The database and the load balancer
are both billable.
0.0.0.0/0 is refused at plan
time for Grafana specifically.
For accessing Grafana, pointing the stack at a database you already run, sizing profiles, and retention, see Grafana.