Skip to main content

Command Palette

Search for a command to run...

Setup Production like MLflow on Kubernetes with RDS Postgres database

Published
2 min read
Setup Production like MLflow on Kubernetes with RDS Postgres database
V

I am a student learning DevOps and Cloud Computing. My blogs and articles are primarily a platform for me to post whatever I am learning. My passion to explain things in simple words also makes me use this platform as a way to teach fellow learners if possible. I would love to receive feedback from most people coming across my articles.

MLflow is needed to bring structure, reproducibility, and traceability to the machine learning lifecycle. As models evolve through experiments, hyperparameter tuning, and retraining, MLflow provides a centralized way to track experiments, metrics, artifacts, and model versions. In production setups, it acts as a source of truth for what was trained, with which data and parameters, enabling reliable deployments, audits, and collaboration across teams.

Pre-requisites

  • AWS Account

  • psql cli

  • kubectl

  • helm

RDS Postgres DB setup

Pre-requisites

  • AWS Account

  • psql cli

Create an RDS database

Go to RDS console > Databases > Create new database > Easy create > PostgreSQL > master username: postgres > self managed password > Create

Enable access

Go to the database > modify > Connectivity > Select Publicly accessible

Setup DB

Connect to the database with

psql -h <rds-endpoint> -p 5432 -U postgres

CREATE DATABASE mlflow; CREATE USER mlflow_user WITH PASSWORD 'your_secure_password'; GRANT ALL PRIVILEGES ON DATABASE mlflow TO mlflow_user;

\c mlflow

GRANT USAGE, CREATE ON SCHEMA public TO mlflow_user;

Kubernetes cluster setup

Create and connect kubectl to your cluster.

I am using a kind cluster you can also follow the same

kind create cluster —name <cluster-name>

kubectl create ns mlflow

helm repo add community-charts https://community-charts.github.io/helm-charts

helm repo update

helm install mlflow community-charts/mlflow --namespace mlflow --set backendStore.databaseMigration=true --set backendStore.postgres.enabled=true --set backendStore.postgres.host=your-postgres-host --set backendStore.postgres.port=5432 --set backendStore.postgres.database=mlflow --set backendStore.postgres.user=mlflow_user --set backendStore.postgres.password=your_secure_password

Expose the pod

kubectl get pods -n mlflow

Wait for pod to be ready

kubectl port-forward -n mlflow pod/<pod-name> 5000:5000 —address 0.0.0.0

Access MLflow on localhost:7006