This is a Python-based service designed to synchronize data from Trakt to Toggl. The service supports periodic execution using Kubernetes CronJobs and can also be run manually in a Python environment for development or testing purposes.
-
app/
: Contains the Python application.-
sync.py
: Main script for the synchronization logic. -
requirements.txt
: Lists Python dependencies. -
Dockerfile
: Defines how to build the container.
-
-
k8s/
: Kubernetes configuration files.-
base/
: Templates and base configuration for ConfigMaps and Secrets. -
secrets/
: Sensitive data (excluded from Git) for production use.
-
- Python 3.8 or higher.
- A virtual environment tool (e.g.,
venv
orvirtualenv
).
- Create and activate a virtual environment
python3 -m venv trakt-to-toggl
source trakt-to-toggl/bin/activate
- Install dependencies:
pip install -r app/requirements.txt
- Set up environment variables: Create a .env file in the
app
directory and customize it with your keys and preferences:
TRAKT_CLIENT_ID=<your_client_id>
TRAKT_CLIENT_SECRET=<your_client_secret>
TRAKT_HISTORY_DAYS=7
TOGGL_API_TOKEN=...
TOGGL_WORKSPACE_ID=
TOGGL_PROJECT_ID=
TOGGL_TAGS=automated,trakt-to-toggl
- Run the script:
python app/sync.py
Logs are provided on the standard output.
- Create Kubernetes namespace:
kubectl apply -f k8s/base/namespace.yaml
- Set up Secrets and ConfigMaps:
Use the k8s/base/secret-template.yaml and k8s/base/configmap-template.yaml to create your Secrets and ConfigMaps. Apply them to the cluster:
kubectl apply -f k8s/secrets/trakt_tokens_secret.yaml
kubectl apply -f k8s/values/configmap-values.yaml
- Deploy the CronJob:
kubectl apply -f k8s/base/cronjob.yaml
- Test it with a manual run:
kubectl create job --from=cronjob/trakt-to-toggl trakt-to-toggl-manual-run
- Check the logs:
kubectl logs trakt-to-toggl-manual-run-...