|
| 1 | +# TLM Deployment Guide |
| 2 | + |
| 3 | +## Requirements |
| 4 | + |
| 5 | +- Terraform CLI |
| 6 | + ``` |
| 7 | + brew install terraform |
| 8 | + ``` |
| 9 | +- Azure CLI |
| 10 | + ``` |
| 11 | + brew install azure-cli |
| 12 | + ``` |
| 13 | +- Helm |
| 14 | + ``` |
| 15 | + brew install helm |
| 16 | + ``` |
| 17 | +- Azure account in Cleanlab's tenant |
| 18 | + - ask Kelsey if you need to be invited |
| 19 | +- Minimum required Azure role assignments: |
| 20 | + - `Reader` on the OpenAI service resource group `tlm-staging-rg` |
| 21 | + - `Storage Blob Data Reader` on the `tlmtfstate` storage account |
| 22 | + |
| 23 | +Below are optional Azure roles to request on the `Production` subscription. Ask Kelsey if you want permissions. |
| 24 | +* `Reader` for global read access |
| 25 | +* `Azure Kubernetes Service Contributor` for access to live/historical container logs, `kubectl` usage, and more |
| 26 | +
|
| 27 | +## Initial Setup |
| 28 | +
|
| 29 | +Import the existing resources to Terraform: |
| 30 | +``` |
| 31 | +terraform import -var-file="staging.tfvars" 'module.app.azurerm_role_assignment.openai_identity_sa' "/subscriptions/a47bf188-5236-4db5-bde5-16655f9d07ec/resourceGroups/tlm-staging-rg/providers/Microsoft.CognitiveServices/accounts/tlm-openai/providers/Microsoft.Authorization/roleAssignments/5c088622-3f50-84c7-e52e-09d253ed0325" |
| 32 | + |
| 33 | +terraform import -var-file="staging.tfvars" 'module.app.helm_release.this' tlm/tlm |
| 34 | +``` |
| 35 | +
|
| 36 | +## Deploying to Azure staging environment |
| 37 | +
|
| 38 | +Follow these instructions to deploy TLM app changes through CLI. Note that after merging to main, you must wait for the `Release TLM App / build-push-chat-backend-acr` step to finish before starting the deployment process. |
| 39 | +
|
| 40 | +1. Run `az login` and select the `Production` subscription |
| 41 | +2. Change your working directory: `cd deploy/terraform/app` |
| 42 | +3. Set up your Terraform variables: |
| 43 | +
|
| 44 | + * If this is your first time deploying, `cp staging.tfvars.example staging.tfvars` |
| 45 | + * Modify the `.tfvars` file by setting `app_image_tag` to the Git commit SHA that you want to deploy |
| 46 | +
|
| 47 | +4. `terraform init` |
| 48 | +5. `terraform plan -var-file="staging.tfvars" -out=tfplan.plan` |
| 49 | + |
| 50 | + The plan should be `0 to add, 1 to change, 0 to destroy`. It will only include modifying the Helm release resource `module.app.helm_release.this` to update the `chat_backend.image.tag`, plus modifying some metadata. If anything else is included in the plan, check that your branch has the latest version of the Terraform script, or reach out in [#azure](https://cleanlabinc.slack.com/archives/C093X788A6L). |
| 51 | +
|
| 52 | +6. If the plan looks good, apply the changes by running `terraform apply tfplan.plan`. |
| 53 | +
|
| 54 | + Note that this will **NOT** prompt you to confirm the changes because they were already saved by the planning step, so be careful! |
| 55 | +
|
| 56 | +## Debugging |
| 57 | +
|
| 58 | +If you encounter permission issues (4xx status codes) when running any of the `terraform` commands, try unsetting the `ARM_*` environment variables. These can interfere with Azure-related authentication when managing resources. |
| 59 | +
|
| 60 | +``` |
| 61 | +unset ARM_CLIENT_ID ARM_CLIENT_SECRET ARM_TENANT_ID ARM_SUBSCRIPTION_ID |
| 62 | +``` |
0 commit comments