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.
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.

Restarting after a configuration change

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

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