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.
macOS
Debian
CentOS
brew install rsync
apt-get install rsync
yum install rsync
git clone https://github.com/techvelocity/velocity-blueprints.git
cd velocity-blueprints/examples/env-sync-python/src/web_api
Create the file
/src/web_api/.velocity.yaml
and copy the following configurations into it:version: 1
services:
web-api:
sync:
live_updates:
- .:/app
build_and_push:
velocity_builder:
args: [-f ./Dockerfile .]
Your file tree should now look like this:
.
├── k8s
│ ├── Chart.yaml
│ ├── templates
│ │ └── web_api.yml
│ └── velocity-values.yml
└── src
└── web_api
├── Dockerfile
├── main.py
├── .velocity.yaml
└── requirements.txt
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.

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
COPY main.py .
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port 8000 --reload"]
Run the following from
/src/web_api
:veloctl env sync -s web-api
Add the following to
/src/web_api/main.py
:@app.get('/test')
async def test():
return 'success'
Navigate in your web browser to
https://<your-env-domain>/test
Congratulations! Env Sync is set up and working!
Last modified 2mo ago