I have 2 projects - one for staging and production. I want to deploy the same agent to staging and production with different secrets.
What is the recommended best practice? How to deal with multiple livekit.toml files?
How to automate it in github actions?
The recommended pattern is one deployment per LiveKit Cloud project, using the same codebase but separate deployments and secrets per environment.
When you run lk agent create, a livekit.toml is generated and tied to the currently selected default project. For staging and production, link both projects in the CLI and switch with lk project set-default before deploying. Each project gets its own deployment and independently managed secrets, as described in the Agent deployment quickstart.
@darryncampbell I am still a bit confused…
lk agent createwould createlivekit.tomlfile. Should this file be check in to the repo? Or should this file be created from scratch everytime?- If
livekit.tomlshould be checked into the repo, how can I check in multipletomlfiles for different projects? - For future deployments using
lk agent deploy, how can I point to the righttomlfile when I have multipletomlfiles?
Sure, so:
- Create the agent locally
- Run
lk cloud authto authenticate against both your dev and prod cloud projects - Deploy the agent to your cloud dev environment (
lk agent create, then select the appropriate cloud project and appropriate secrets / env file - note that the LiveKit URL, Key and Secret in the selected env file should match your cloud dev environment). This creates a livekit.toml file, which you can rename to livekit.toml.dev. This also deploys your agent to dev - Deploy the agent to your cloud prod environment (
lk agent create, then repeat the steps above, renaming the resulting livekit.toml to livekit.toml.prod) - To redeploy your dev agent run
lk agent deploy –secrets-file <your dev env file> –config <your dev toml file> - To redeploy your prod agent run
lk agent deploy –secrets-file <your prod env file> –config <your prod toml file> - Make sure you don’t have environment variables defined for LIVEKIT_URL etc. Otherwise these will be picked up in preference to the above. This also means you don’t have to worry about
lk project set-default
@darryncampbell That was helpful. Two quick clarification:
- The environment file should have LIVEKIT_URL, Key and Secret during
lk agent createbut not during futurelk agent deploy? - Any harm in having them assuming they are no change in their values?
Each project has its own URL, key, and secret so your prod and dev will have unique values, but those will not change (they are associated with the project, not the agent)
is there an example of deploying a livekit agent using github action?
I think this is what you are looking for:
This is great! I like the Deploy an existing agent on file change example. Is there a way to specifiy which tomlfile to use in that github action example? I will have multiple livekit.toml files, oneper environment. I want to point the github action to the right tomlfile as needed.