How to configure Infrahub
This guide explains how to configure your Infrahub instance by setting environment variables that control various aspects of the system, including timeouts, security settings, and integration parameters.
What you'll accomplish
By following this guide, you'll learn how to:
- Identify available configuration options
- Set environment variables in various deployment methods
- Apply configuration changes to a running Infrahub instance
- Verify that your changes have been applied correctly
Prerequisites
Before starting, ensure you have:
- A running Infrahub instance
- Command-line access to the server running Infrahub
- Basic understanding of environment variables
- For production deployments, plan a maintenance window as services will be restarted
Step 1: Identify the configuration option
Determine which configuration setting you want to change.
- Refer to the configuration reference to find available environment variables
- Note the exact variable name and its expected value type
For this guide, we'll use INFRAHUB_HTTP_TIMEOUT as an example. It affects how Infrahub interacts with external HTTP servers such as webhooks and OAuth2 providers. The default value is 10 seconds.
Step 2: Set the variable
Configure the variable before starting or restarting your Infrahub containers.
- Docker Compose
- Kubernetes
Using a .env file keeps your configuration organized and allows you to track changes with version control.
Avoid hardcoding information directly in the docker-compose.yml file. Part of the upgrade process consists of replacing this file, which could lead to loss of your configuration.
Avoid mixing multiple configuration methods as it can lead to confusion about which settings are applied.
Option A: Use a .env file (recommended)
Create or edit a .env file in the same directory as your docker-compose.yml file:
INFRAHUB_HTTP_TIMEOUT=20
This method is preferred for persistent configuration as Docker Compose automatically loads variables from the .env file.
Option B: Export in your shell
Export the environment variable in your shell session:
export INFRAHUB_HTTP_TIMEOUT=20
This method works for temporary changes or testing, but the variable persists only for the current shell session.
Option C: Use a .toml file (not recommended)
Create or edit an infrahub.toml file with your configuration:
[settings]
http_timeout = 20
Then reference the TOML file when starting Infrahub. The application will automatically load configuration from the TOML file.
TOML configuration files use lowercase with underscores for setting names (e.g., http_timeout) rather than the uppercase environment variable format (e.g., INFRAHUB_HTTP_TIMEOUT).
Use Helm values
Update your values.yaml or provide values during upgrade:
infrahubServer:
infrahubServer:
env:
INFRAHUB_HTTP_TIMEOUT: "20"
infrahubTaskWorker:
infrahubTaskWorker:
env:
INFRAHUB_HTTP_TIMEOUT: "20"
Or set directly via command line:
helm upgrade infrahub opsmill/infrahub \
--set infrahubServer.infrahubServer.env.INFRAHUB_HTTP_TIMEOUT=20 --set infrahubTaskWorker.infrahubTaskWorker.env.INFRAHUB_HTTP_TIMEOUT=20 \
-n <your-namespace>
Step 3: Apply the configuration changes
Restart your Infrahub containers to apply the new configuration.
- Docker Compose
- Kubernetes
Depending on your setup, you might need to adjust the commands below to add options.
Recreate and restart your Docker containers to apply the changes:
docker compose up -d --force-recreate
The --force-recreate flag ensures that containers are recreated even if their configuration and images haven't changed, which is necessary for applying new environment variables.
This command restarts all services defined in your docker-compose.yml file. There will be a brief service interruption during the restart.
For Helm deployments
If you're using Helm, upgrade your release with the new values:
helm upgrade infrahub opsmill/infrahub \
-f values.yaml \
-n <your-namespace>
Or with inline values:
helm upgrade infrahub opsmill/infrahub \
--set infrahubServer.infrahubServer.env.INFRAHUB_HTTP_TIMEOUT=20 --set infrahubTaskWorker.infrahubTaskWorker.env.INFRAHUB_HTTP_TIMEOUT=20 \
-n <your-namespace>
Rolling out changes will trigger a pod restart. Depending on your deployment configuration (replicas, rolling update strategy), there may be a brief service interruption.
Step 4: Verify the configuration
Confirm that your configuration change has been applied successfully.
- Docker Compose
- Kubernetes
Depending on your setup, you might need to adjust the commands below to match your container names if you are using a different project name for instance.
Check that the environment variable is set correctly inside the container:
docker exec infrahub-server-1 env | grep INFRAHUB_HTTP_TIMEOUT
You should see output similar to:
INFRAHUB_HTTP_TIMEOUT=20
If you see the expected value in the output, your configuration change has been applied successfully.
Replace <your-namespace> and infrahub-server-* with your actual namespace and pod name.
First, get the name of your Infrahub pod:
kubectl get pods -n <your-namespace> -l app=infrahub-server
Then check the environment variable inside the pod:
kubectl exec -n <your-namespace> <pod-name> -- env | grep INFRAHUB_HTTP_TIMEOUT
For example:
kubectl exec -n infrahub infrahub-server-7d8f9b5c6d-xyz12 -- env | grep INFRAHUB_HTTP_TIMEOUT
You should see output similar to:
INFRAHUB_HTTP_TIMEOUT=20
Alternatively, you can describe the pod to see all environment variables:
kubectl describe pod -n <your-namespace> <pod-name>
If you see the expected value in the output, your configuration change has been applied successfully.
Related resources
- Configuration reference - Complete list of available environment variables
- Production deployment - Best practices for deploying Infrahub
- Installing Infrahub - Installation methods for Infrahub