Setting environment variables
Tonic uses environment variables for many of its configuration options. For example, the
ENABLE_LOG_COLLECTIONenvironment 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.
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.
When you change an environment variable, the change does not take effect until the services are restarted.
For Kubernetes, in values.yaml, the service sections (
worker) are under
tonicai. Within those sections, the environment variables are under
"ENVIRONMENT_VARIABLE_NAME": "Variable value"
You add the environment variable to the appropriate
envsection, based on the service that that variable is associated with. For example:
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>
helm upgradecommand is always safe to use when you provide specific version numbers. However, if you use the
latesttag, it might result in Tonic containers that have different versions.
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.
For Docker, in docker-compose.yaml, the service sections (
tonic_worker) are under
services. Within those sections, the environment variables are under
ENVIRONMENT_VARIABLE_NAME: Variable value
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
environmentsection, 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