Upgrade on Azure (Terraform)

Disambiguation

To upgrade your Materialize instances, first choose a new operator version and upgrade the Materialize operator. Then, upgrade your Materialize instances to the same version. The following tutorial upgrades your Materialize deployment running on Azure Kubernetes Service (AKS).

The tutorial assumes you have installed Materialize on Azure Kubernetes Service (AKS) using the instructions on Install on Azure (either from the examples/simple directory or the root).

Version compatibility

! Important: When performing major version upgrades, you can upgrade only one major version at a time. For example, upgrades from v26.1.0 to v27.2.0 is permitted but v26.1.0 to v28.0.0 is not. Skipping major versions or downgrading is not supported. To upgrade from v25.2 to v26.0, you must upgrade first to v25.2.15+.

When upgrading, you may need or want to update your fork of the Terraform module to upgrade.

Terraform version Notable changes
v0.6.4
  • Released as part of v26.0.0.
  • Uses terraform-helm-materialize version v0.1.35.

Prerequisites

! Important: The following procedure performs a rolling upgrade, where both the old and new Materialize instances are running before the the old instance are removed. When performing a rolling upgrade, ensure you have enough resources to support having both the old and new Materialize instances running.

Azure subscription

If you do not have an Azure subscription to use for this tutorial, create one.

Azure CLI

If you don’t have Azure CLI installed, install Azure CLI.

Terraform

If you don’t have Terraform installed, install Terraform.

kubectl

If you do not have kubectl, install kubectl.

Python (v3.12+) and pip

If you don’t have Python (v3.12 or greater) installed, install it. See Python.org. If pip is not included with your version of Python, install it.

Helm 3.2.0+

If you don’t have Helm version 3.2.0+ installed, install. For details, see to the Helm documentation.

jq (Optional)

Optional. jq is used to parse the AKS cluster name and region from the Terraform outputs. Alternatively, you can manually specify the name and region. If you want to use jq and do not have jq installed, install.

License key

Starting in v26.0, Materialize requires a license key. If your existing deployment does not have a license key configured, contact Materialize support.

A. Authenticate with Azure

  1. Open a Terminal window.

  2. Authenticate with Azure.

    az login
    

    The command opens a browser window to sign in to Azure. Sign in.

  3. Select the subscription and tenant to use. After you have signed in, back in the terminal, your tenant and subscription information is displayed.

    Retrieving tenants and subscriptions for the selection...
    
    [Tenant and subscription selection]
    
    No     Subscription name    Subscription ID                       Tenant
    -----  -------------------  ------------------------------------  ----------------
    [1]*   ...                  ...                                   ...
    
    The default is marked with an *; the default tenant is '<Tenant>' and
    subscription is '<Subscription Name>' (<Subscription ID>).
    

    Select the subscription and tenant.

  4. Set ARM_SUBSCRIPTION_ID to the subscription ID.

    export ARM_SUBSCRIPTION_ID=<subscription-id>
    

B. Upgrade process

  1. Go to the Terraform directory for your Materialize deployment. For example, if you deployed from the examples/simple directory:

    cd terraform-azurerm-materialize/examples/simple
    
  2. Optional. You may need to update your fork of the Terraform module to upgrade.

    Terraform version Notable changes
    v0.6.4
    • Released as part of v26.0.0.
    • Uses terraform-helm-materialize version v0.1.35.
    💡 Tip: If upgrading from a deployment that was set up using an earlier version of the Terraform modules, additional considerations may apply when using an updated Terraform modules to your existing deployments.
  3. Optional. Create a virtual environment, specifying a path for the new virtual environment:

    python3 -m venv <path to the new virtual environment>
    

    Activate the virtual environment:

    source <path to the new virtual environment>/bin/activate
    
  4. Install the required packages.

    pip install -r requirements.txt
    
  5. Configure kubectl to connect to your cluster:

    • <cluster_name>. Your cluster name has the form <your prefix>-aks; e.g., mz-simple-aks.

    • <resource_group_name>, as specified in the output. You resource group name has the form <your prefix>-rg; e.g., mz-simple-rg.

    az aks get-credentials --resource-group <resource_group_name> --name <cluster_name>
    

    Alternatively, you can use the following command to get the cluster name and resource group name from the Terraform output (in your terraform.tfstate file):

    az aks get-credentials --resource-group $(terraform output -raw resource_group_name) --name $(terraform output -json aks_cluster | jq -r '.name')
    

    To verify that you have configured correctly, run the following command:

    kubectl get nodes
    

    For help with kubectl commands, see kubectl Quick reference.

  6. Back up your terraform.tfvars file.

    cp terraform.tfvars original_terraform.tfvars
    
  7. Update the terraform.tfvars to set the Materialize Operator version:

    Variable Description
    operator_version New Materialize Operator version.
    • If the variable does not exist, add the variable and set to the new version.
    • If the variable exists, update the value to the new version.
    ##... Existing content not shown for brevity
    ##... Leave the existing variables unchanged
    operator_version="v26.0.0"  # Set to the desired operator version
    
  8. Initialize the terraform directory.

    terraform init
    
  9. Run terraform plan with both the terraform.tfvars and your mz_instances.tfvars files and review the changes to be made.

    terraform plan -var-file=terraform.tfvars -var-file=mz_instances.tfvars
    

    The plan should show the changes to be made for the materialize_operator.

  10. If you are satisfied with the changes, apply.

    terraform apply -var-file=terraform.tfvars -var-file=mz_instances.tfvars
    

    To approve the changes and apply, enter yes.

    Upon successful completion, you should see output with a summary of changes.

  11. Verify that the operator is running:

    kubectl -n materialize get all
    

    Verify the operator upgrade by checking its events:

    kubectl -n materialize describe pod -l app.kubernetes.io/name=materialize-operator
    
    • The Containers section should show the --helm-chart-version argument set to the new version.

    • The Events section should list that the new version of the orchestratord have been pulled.

  12. Back up your mz_instances.tfvars file.

    cp mz_instances.tfvars original_mz_instances.tfvars
    
  13. Update the mz_instances.tfvars to specify the upgrade variables for each instance:

    Variable Description
    create_database Set to false.
    environmentd_version New Materialize instance version. This should be the same as the operator version: v26.0.0.
    request_rollout or force_rollout A new UUID string. Can be generated with uuidgen.
    • request_rollout triggers a rollout only if changes exist.
    • force_rollout triggers a rollout even if no changes exist.
    inPlaceRollout Set to false to perform a rolling upgrade. For rolling upgrades, ensure you have enough resources to support having both the old and new Materialize instances running during the upgrade.
    license_key Required. Set to the value of your license key. If your existing deployment does not have a license key, contact Materialize support. If you have a license key, substitute your license key for <ENTER YOUR LICENSE KEY HERE>.

    For example, the following instance specifies:

    • a create_database of false,
    • an inPlaceRollout of false,
    • an environmentd_version of "v26.0.0",
    • a request_rollout of "22222222-2222-2222-2222-222222222222", and
    • a license_key (substituting your license key for <ENTER YOUR LICENSE KEY HERE>).
    materialize_instances = [
        {
          name           = "demo"
          namespace      = "materialize-environment"
          database_name  = "demo_db"
          cpu_request    = "1"
          memory_request = "2Gi"
          memory_limit   = "2Gi"
          create_database = false
          license_key    = "<ENTER YOUR LICENSE KEY HERE>"        # Required.
          environmentd_version = "v26.0.0"
          inPlaceRollout: false                                   # When false, performs a rolling upgrade rather than in-place
          requestRollout: 22222222-2222-2222-2222-222222222222    # Enter a new UUID
        }
    ]
    
    WARNING! Please consult the Materialize team before setting inPlaceRollout to true and performing an in-place rollout. In almost all cases a rolling upgrade is preferred.
  14. Run terraform plan with both the terraform.tfvars and your mz_instances.tfvars files and review the changes to be made.

    terraform plan -var-file=terraform.tfvars -var-file=mz_instances.tfvars
    

    The plan should show the changes to be made for the Materialize instance.

  15. If you are satisfied with the changes, apply.

    terraform apply -var-file=terraform.tfvars -var-file=mz_instances.tfvars
    

    To approve the changes and apply, enter yes.

    Upon successful completion, you should see output with a summary of changes.

  16. Verify that the components are running after the upgrade:

    kubectl -n materialize-environment get all
    

    Verify upgrade by checking the balancerd events:

    kubectl -n materialize-environment describe pod -l app=balancerd
    

    The Events section should list that the new version of the balancerd have been pulled.

    Verify the upgrade by checking the environmentd events:

    kubectl -n materialize-environment describe pod -l app=environmentd
    

    The Events section should list that the new version of the environmentd have been pulled.

  17. Open the Materialize Console. The Console should display the new version.

Back to top ↑