Env Sync Tutorial with Python

This tutorial will walk you through the process of enabling Velocity's Env Sync feature for a Velocity Service written in Python.


NOTE: If you are not using the Velocity Operator, contact Velocity to enable a container registry that is local to your cluster.

1. Install rsync locally

brew install rsync
apt-get install rsync
yum install rsync

2. Clone the example repo

git clone
cd velocity-blueprints/examples/env-sync-python/src/web_api

3. Create a .velocity.yaml config

Create the file /src/web_api/.velocity.yaml and copy the following configurations into it:
version: 1
- .:/app
args: [-f ./Dockerfile .]
You can learn more about the .velocity.yaml config here.
Your file tree should now look like this:
├── k8s
│   ├── Chart.yaml
│   ├── templates
│   │   └── web_api.yml
│   └── velocity-values.yml
└── src
   └── web_api
   ├── Dockerfile
├── .velocity.yaml
   └── requirements.txt

4. Create your Velocity Environment

From the k8s directory, run:
helm template . --values velocity-values.yml | veloctl env create -f -
This command creates an environment from a local Helm template that has not been committed to Velocity.

5. Add rsync to your Dockerfile

Update /src/web_api/Dockerfile as follows:
FROM python:3.10-alpine
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN apk add rsync # <----- Add this line
CMD ["sh", "-c", "uvicorn main:app --host --port 8000 --reload"]
NOTE: For FastAPI apps, pass the --reload flag to enable hot reload.

6. Start env sync

Run the following from /src/web_api:
veloctl env sync -s web-api

7. Change the source code

Add the following to /src/web_api/
async def test():
return 'success'

8. View the result

Navigate in your web browser to https://<your-env-domain>/test
Congratulations! Env Sync is set up and working!

Next Steps: