IaC for MLOps on Google Cloud Platform
- A Google Cloud Platform account
- Terraform >= 1.14
- Artifact Registry: Repository for MLflow Docker container
- Cloud SQL: MLflow back-end store (PostgreSQL) for experiment tracking
- Cloud Storage: bucket for MLflow artifacts store
- Cloud Run: Serves MLflow container
- Secrets Manager: Securely stores database credentials and sensitive URIs
- IAM: Manages service account permissions to architecture components
Open Cloud Shell on GCP and run git clone https://github.com/keiferc/mlops-gcp.git.
# Set variables
cd mlops-gcp/terraform/
cp terraform.tfvars.example terraform.tfvars # fill placeholders
# Enable APIs
gcloud services enable cloudresourcemanager.googleapis.com --project=<PROJECT_ID>
terraform init
terraform validate
terraform plan # check plan logic
terraform apply -target=google_project_service.apis # enable APIs
# Deploy MLflow container to Artifact Registry
terraform apply -target=google_artifact_registry_repository.mlflow
cd ../docker/
gcloud auth configure-docker <REGION>-docker.pkg.dev
gcloud builds submit --tag <REGION>-docker.pkg.dev/<PROJECT_ID>/mlflow-repo/mlflow:latest --project <PROJECT_ID> .
# Deploy infrastructure
cd ../terraform/
terraform plan # check plan logic
terraform applyInspect resources with terraform show and destroy resources with terraform destroy.
View MLFlow UI by running the following on Cloud Shell:
gcloud run services proxy mlflow-server --region=<REGION> --project=<PROJECT_ID> --port=8080then clicking the Web Preview icon.
- uv >= 0.10
uv sync --dev
uv run pre-commit autoupdate
uv run pre-commit install- Write self-documenting code
- Manage dependencies with
uv(e.g.,uv add polars) - Submit pull requests to
dev