Setting environment variables

Tonic uses environment variables for many of its configuration options. For example, the ENABLE_LOG_COLLECTION environment variable determines whether you share logs with Tonic.
Tonic also uses environment variables to enable custom generators and pre-release features for customers.
For Tonic instances that are deployed using the Tonic Installation Manager (TIM), you use the TIM script to set environment variable values.
For Tonic instances that are deployed manually using Kubernetes or Docker, you set environment variables in a .yaml file.
  • For Kubernetes deployments, the file is values.yaml.
  • For Docker deployments, the file is docker-compose.yaml.

Setting an environment variable in the correct service

Each environment variable is tied to a specific service. Most environment variables are used by either the Tonic web server or the worker.
The .yaml files contain a section for each service. Within each section is a subsection for the environment variables for that service.
You add each environment variable to the environment variables for the appropriate service.
TIM manages this automatically by adding the environment variables to both services.

Restarting after a configuration change

When you change an environment variable, the change does not take effect until the services are restarted.

Updating in TIM

When you use TIM to install Tonic, the script includes a step to set environment variable values.
To set additional environment variable values or to change the configured values, rerun the TIM script.
TIM always adds each environment variable to both the worker and web server services. This ensures that the correct service can find the value.
TIM automatically restarts the services after the update. Note that in addition to updating the environment variables, TIM updates to the latest version of Tonic. You should avoid using Tonic while the update is in progress.

Updating in Kubernetes

For Kubernetes, in values.yaml, the service sections (web_server and worker) are under tonicai. Within those sections, the environment variables are under env.
env: {
You add the environment variable to the appropriate env section, based on the service that that variable is associated with. For example:
env: {
After you update the yaml file, to restart the service and complete the update, run:
$ helm upgrade <name_of_release> -n <namespace_name> <path-to-helm-chart>
The above helm upgrade command is always safe to use when you provide specific version numbers. However, if you use the latest tag, it might result in Tonic containers that have different versions.
If this occurs, you can run the Tonic update process to ensure that all of the containers are updated and synchronized on the latest Tonic version.
Alternatively, you can:
  • Delete each deployment (kubectl delete pod …), or scale the deployment replicas to 0 and then back to 1. This ensures that all pods restart with the latest version.
  • Use helm to uninstall and re-install Tonic.

Updating in Docker

For Docker, in docker-compose.yaml, the service sections (tonic_web_server and tonic_worker) are under services. Within those sections, the environment variables are under environment.
If your Tonic instance is deployed using Docker, then you can either:
  • Set the value directly in docker-compose.yaml.
  • Set the value in your .env file, and add a reference to the variable in docker-compose.yaml.
To set the value directly in docker-compose.yaml, add the variable and value to the appropriate environment section, based on the service that the variable is associated with. For example:
If you set the value in .env, then to add the reference in docker-compose.yaml:
After you update the yaml file, to restart the service and complete the update:
$ docker-compose down
$ docker-compose pull && docker-compose up -d