콘텐츠로 이동

MLflow 플랫폼 정리

Interactive Diagram

새 탭 ↗
항목값
versionMLflow v3.14.0, Helm chart v0.1.0
공식 문서MLflow Tracking
chart 소스base/mlflow/charts/mlflow-0.1.0
dev overlayoverlays/dev/mlflow

MLflow는 Kubeflow control plane component가 아니라 experiment tracking과 model lifecycle metadata를 위한 별도 application이다. client library 또는 MLflow UI가 experiment와 run을 만들고, server는 parameter, metric, tag, run state, registered model, model version metadata를 backend store에 기록한다. model file, checkpoint, image, dataset snapshot 같은 artifact는 metadata database가 아니라 S3 compatible object storage에 저장한다.

MLflow client가 tracking server에 metadata를 기록하고, server가 backend store와 artifact store 사이에서 artifact를 proxy하는 원격 tracking server 구성. 공식 그림의 database는 PostgreSQL 예시이고 이 글의 구성은 MySQL이다 출처: MLflow 문서, Remote Tracking Server 튜토리얼, MLflow Project, Apache-2.0

현재 dev overlay는 single replica MLflow server를 mlflow namespace에 배포한다. chart는 mlflow server를 실행하고, --app-name=basic-auth로 MLflow basic authentication plugin을 활성화한다. Service와 Ingress는 / root path를 사용한다. Kubeflow Dashboard의 kubeflow-gateway, Dex, oauth2-proxy route에는 연결하지 않는다.

MLflow tracking과 Model Registry의 경계

섹션 제목: “MLflow tracking과 Model Registry의 경계”

MLflow Model Registry는 MLflow backend store의 registered model과 model version metadata를 관리한다. 이는 Kubeflow Hub가 제공하는 Model Registry와 별개의 system이다. 현재 overlay에서 MLFLOW_REGISTRY_STORE_URI는 설정하지 않으므로 registry metadata는 MLFLOW_BACKEND_STORE_URI가 가리키는 mlflow database에 함께 저장된다.

구분MLflowKubeflow Hub
주된 APIexperiment, run, metric, MLflow model versionKubeflow registered model, model version, artifact metadata
metadata storeshared MySQL mlflow logical databaseshared MySQL model_registry logical database
artifact storeSeaweedFS mlflow-artifacts bucket등록된 외부 artifact URI
Dashboard 통합없음, 독립 hostname/model-registry/
KServe 직접 연결현재 없음model-registry:// storage initializer

두 registry를 같은 model catalog로 간주하거나 metadata를 자동 동기화하면 안 된다. MLflow에서 기록한 model을 KServe로 serving하거나 Kubeflow Hub에 등록하려면 artifact URI와 metadata를 명시적으로 전달하는 별도 workflow가 필요하다.

Notebook, Pipeline, Katib, Trainer workload는 학습을 실행하지만 experiment 간 parameter, metric, artifact, model version을 MLflow API 방식으로 비교하는 service를 제공하지 않는다. MLflow는 이 gap을 보완해 Python MLflow client로 기록한 run을 UI와 API에서 조회할 수 있게 한다.

  • experiment tracking: client가 전송한 parameter, metric, tag, run lifecycle을 shared MySQL에 저장한다.
  • artifact proxy: server가 artifact upload와 download를 SeaweedFS S3에 proxy한다. 이때 destination 지정만으로는 부족하고 두 조건이 모두 필요하다. 첫째, server를 mlflow server --serve-artifacts --artifacts-destination s3://mlflow-artifacts로 기동해야 한다(MLFLOW_ARTIFACTS_DESTINATION 환경변수는 --artifacts-destination 값을 채워 줄 뿐, --serve-artifacts를 대신하지 않는다). 둘째, client가 받는 artifact URI가 mlflow-artifacts:/ scheme이어야 한다. run의 artifact URI가 s3://...로 내려가면 client가 object storage에 직접 접속하므로 proxy 경로를 타지 않는다.
  • 독립 browser access: mlflow.<cluster-domain> hostname의 nginx Ingress가 MLflow Service로 traffic을 전달한다.
  • application authentication: MLflow basic-auth plugin이 UI와 API user authentication을 처리한다.
  • Kubeflow workload 연계: Notebook, Pipeline step, Katib Trial, Trainer Job이 MLflow tracking URI와 user credential을 받아 client로 run을 기록할 수 있다. 현재 overlay는 이 workload에 environment variable이나 Secret을 자동 주입하지 않는다.
overlays/dev/mlflow
-> base/mlflow/charts/mlflow-0.1.0
-> values.yaml
-> shared MySQL backend store Secret reference
-> SeaweedFS S3 endpoint와 artifact credential reference
-> MLflow basic-auth Secret mount
-> ingress.yaml
-> cert-manager Certificate
-> nginx Ingress

kustomization.yaml은 Helm chart와 ingress.yaml만 render한다. mlflow-db-secret, mlflow-minio-artifact, mlflow-auth-secret은 chart가 생성하지 않으며 local Secret management로 별도 provision해야 한다. overlay에 있는 *.secret.yaml 파일은 key contract를 보여 주는 수동 template이지만 현재 kustomization resources에는 포함되지 않는다.

항목현재 값의미
imageghcr.io/mlflow/mlflow:v3.14.0-fullMLflow server image
replica1single MLflow server Pod
Servicemlflow.mlflow.svc.cluster.local:5000cluster 내부 MLflow HTTP endpoint
backend storeMLFLOW_BACKEND_STORE_URI from mlflow-db-secret.uriMySQL mlflow database metadata connection
registry store미설정backend store를 registry metadata store로 사용
artifact destinations3://mlflow-artifactsserver-proxied artifact storage root
S3 endpointhttp://seaweedfs-s3.seaweedfs.svc.cluster.local:8333SeaweedFS S3 API
S3 credentialmlflow-minio-artifact.accesskey, secretkeymlflow-artifacts bucket 전용 identity여야 함
server authentication--app-name=basic-authMLflow basic-auth plugin 활성화
auth configurationmlflow-auth-secret.basic_auth_inibasic-auth 초기 user와 permission configuration
Flask secretmlflow-auth-secret.secretkeysession signing key
GC CronJob비활성soft-deleted run과 artifact를 자동 삭제하지 않음
metrics / ServiceMonitor비활성Prometheus scrape manifest를 만들지 않음
NetworkPolicy비활성namespace traffic policy는 별도 관리 필요

MLflow server는 MLFLOW_BACKEND_STORE_URI 하나로 run metadata와 MLflow Model Registry metadata를 같은 MySQL mlflow logical database에 기록한다. database bootstrap Job은 workload 시작 전에 이 database를 생성해야 하며, URI를 담는 Secret의 uri key는 mysql+pymysql://<user>:<password>@<mysql-writer>.<db-namespace>.svc.cluster.local:3306/mlflow 형식이어야 한다. user는 mlflow database에 필요한 DDL과 DML 권한만 가져야 한다.

artifact storage는 mlflow-artifacts bucket과 해당 bucket만 읽고 쓸 수 있는 SeaweedFS S3 identity를 사용해야 한다. MLflow Pod는 AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, MLFLOW_S3_ENDPOINT_URL을 통해 S3 client를 구성한다. 다른 application의 bucket이나 KFP control credential은 공유하지 않는다. shared infrastructure 정책은 공용 데이터 서비스(MySQL·Object Storage)를 따른다.

인증 경로는 Kubeflow Dashboard와 다르다. nginx Ingress controller가 mlflow.<cluster-domain> TLS connection을 종료하고 cluster-local mlflow:5000 HTTP Service로 전달한다. Certificate는 kubeflow-self-signing-issuer ClusterIssuer를 사용한다. ssl-redirect: "false"는 HTTP request를 HTTPS로 redirect하지 않는다는 의미이며, TLS entrypoint 자체를 제거하지 않는다.

MLflow의 basic-auth plugin은 basic_auth_ini에 정의된 초기 user와 권한 정책을 사용한다. 이 overlay의 auth database URI는 /tmp/auth/auth.db이고 /tmp는 Pod emptyDir volume이다. 따라서 Pod replacement 또는 node failure 후에는 plugin이 관리하는 user database가 유지되지 않는다. durable basic-auth user lifecycle이 필요하면 auth database URI를 persistent external database로 옮기거나, MLflow access를 external authentication gateway로 재설계해야 한다.

namespaceresource이름역할
mlflowDeploymentmlflowMLflow tracking API, UI, artifact proxy, basic-auth plugin
mlflowServiceAccountmlflowServiceAccount token automount 없이 server Pod를 실행
mlflowServicemlflowport 5000 HTTP endpoint
mlflowCertificatemlflow-ingressgateway-certsMLflow hostname TLS Secret 발급
mlflowIngressmlflow-ingressnginx ingress controller에서 MLflow Service로 routing
mlflowSecretmlflow-db-secretMySQL backend store URI, 별도 provision 필요
mlflowSecretmlflow-minio-artifactSeaweedFS S3 credential, 별도 provision 필요
mlflowSecretmlflow-auth-secretFlask session key와 basic-auth configuration, 별도 provision 필요
mysqlPercona MySQL Cluster + Serviceps-db, ps-db-haproxymlflow logical database writer endpoint
seaweedfsDeployment + Serviceseaweedfs-s3SeaweedFS S3 API port 8333
seaweedfsbucketmlflow-artifactsMLflow run artifact root, bootstrap 필요

PlantUML 원본:

PlantUML Diagram
  1. Notebook, Pipeline step, Katib Trial, Trainer Job 또는 외부 client가 MLflow tracking URI와 basic-auth credential을 사용해 experiment 또는 run API를 호출한다.
  2. nginx Ingress가 request를 mlflow Service로 전달하고 MLflow basic-auth plugin이 user credential을 검증한다.
  3. MLflow server가 run metadata, parameter, metric, tag, registered model과 version metadata를 Percona MySQL mlflow database에 기록한다.
  4. client의 artifact upload 또는 download request는 MLflow artifact proxy로 들어온다.
  5. server가 mlflow-minio-artifact credential과 seaweedfs-s3:8333 endpoint로 SeaweedFS mlflow-artifacts bucket을 읽거나 쓴다.

PlantUML 원본:

PlantUML Diagram
  • 선행 (이게 먼저 Ready 여야 함): mlflow namespace, <mysql-writer>.<db-namespace>.svc.cluster.local, SeaweedFS seaweedfs-s3:8333, mlflow-artifacts bucket, MLflow가 참조하는 세 Secret, kubeflow-self-signing-issuer ClusterIssuer, nginx ingress controller.
  • 후행 (나를 의존): MLflow tracking URI와 credential을 주입받아 run을 기록하는 Notebook, Pipeline, Katib, Trainer 또는 external application workload.
  • MLflow server는 Kubernetes API를 호출하지 않으며 ServiceAccount token automount도 꺼져 있다.
  • MLflow Service는 cluster 내부 HTTP endpoint이며, 외부 browser traffic은 독립 nginx Ingress를 사용한다. Kubeflow gateway의 Dex SSO와 AuthorizationPolicy는 이 traffic path에 적용되지 않는다.
  • mlflow-artifacts bucket은 MLflow artifact용이다. KFP mlpipeline bucket, Model Registry artifact URI, SeaweedFS filer UI와 같은 storage backend를 사용하더라도 identity와 bucket contract는 분리한다.
  • Deployment/mlflow: tracking server, MLflow Model Registry metadata API, artifact proxy, basic-auth plugin을 실행한다.
  • Secret/mlflow-db-secret: required key uri. MLflow backend store MySQL URI를 제공한다.
  • Secret/mlflow-minio-artifact: required key accesskey, secretkey. SeaweedFS S3 identity를 제공한다.
  • Secret/mlflow-auth-secret: required key secretkey, basic_auth_ini. Flask session signing과 basic-auth configuration을 제공한다.
  • Certificate/mlflow-ingressgateway-certs와 Ingress/mlflow-ingress: 독립 hostname TLS와 HTTP routing을 제공한다.
MLflow client -> ingress -> MLflow server -> MySQL metadata / SeaweedFS artifacts
운영 contract설명
metadataPercona MySQL mlflow database를 사용한다
artifactsSeaweedFS의 mlflow-artifacts bucket을 사용한다
browser entry독립 nginx Ingress로 노출한다