0
0
MLOpsdevops~10 mins

Self-service ML platform architecture in MLOps - Commands & Configuration

Choose your learning style9 modes available
Introduction
Building machine learning models often requires many steps and tools. A self-service ML platform architecture helps teams easily create, train, and deploy models without needing deep technical help every time.
When data scientists want to train models without waiting for IT support
When multiple teams need to share ML tools and resources efficiently
When you want to automate model deployment to production quickly
When you want to track experiments and results in one place
When you want to reuse code and data pipelines across projects
Config File - mlflow_tracking_server.yaml
mlflow_tracking_server.yaml
apiVersion: v1
kind: Service
metadata:
  name: mlflow-tracking
  labels:
    app: mlflow
spec:
  type: ClusterIP
  ports:
    - port: 5000
      targetPort: 5000
      protocol: TCP
      name: http
  selector:
    app: mlflow
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mlflow-tracking
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mlflow
  template:
    metadata:
      labels:
        app: mlflow
    spec:
      containers:
      - name: mlflow
        image: mlflow/mlflow:2.5.0
        ports:
        - containerPort: 5000
        command: ["mlflow", "server", "--backend-store-uri", "sqlite:///mlflow.db", "--default-artifact-root", "/mlflow/artifacts", "--host", "0.0.0.0"]
        volumeMounts:
        - name: mlflow-artifacts
          mountPath: /mlflow/artifacts
      volumes:
      - name: mlflow-artifacts
        emptyDir: {}

This Kubernetes YAML file deploys an MLflow tracking server as a self-service ML platform component.

  • Service: Exposes MLflow server inside the cluster on port 5000.
  • Deployment: Runs one replica of the MLflow server container.
  • Command: Starts MLflow server with SQLite backend and artifact storage in a temporary directory.
Commands
This command creates the MLflow tracking server deployment and service in the Kubernetes cluster so the platform is available for users.
Terminal
kubectl apply -f mlflow_tracking_server.yaml
Expected OutputExpected
deployment.apps/mlflow-tracking created service/mlflow-tracking created
Check that the MLflow tracking server pod is running and ready for use.
Terminal
kubectl get pods -l app=mlflow
Expected OutputExpected
NAME READY STATUS RESTARTS AGE mlflow-tracking-7d8f9c7f5b-abcde 1/1 Running 0 30s
-l - Filter pods by label
Create a new MLflow experiment to organize and track machine learning runs.
Terminal
mlflow experiments create --experiment-name my-first-experiment
Expected OutputExpected
Created experiment with ID 1
--experiment-name - Name the new experiment
Run a sample MLflow project from a GitHub repo with a parameter to train a model and log results automatically.
Terminal
mlflow run https://github.com/mlflow/mlflow-example.git -P alpha=0.5
Expected OutputExpected
2024/06/01 12:00:00 INFO mlflow.projects: === Run (ID '1234567890abcdef') succeeded ===
-P - Set parameters for the run
Key Concept

If you remember nothing else from this pattern, remember: a self-service ML platform lets teams run, track, and share ML work easily without waiting for infrastructure help.

Code Example
MLOps
import mlflow

mlflow.set_tracking_uri("http://localhost:5000")
mlflow.set_experiment("my-first-experiment")

with mlflow.start_run():
    mlflow.log_param("alpha", 0.5)
    mlflow.log_metric("rmse", 1.23)
    print("Run logged successfully")
OutputSuccess
Common Mistakes
Not exposing the MLflow server service correctly in Kubernetes
Users cannot access the tracking UI or API, so the platform is unusable
Create a Kubernetes Service with the correct port and selector to expose MLflow
Running MLflow without specifying backend store and artifact root
MLflow cannot save experiment data or artifacts, losing all tracking info
Always specify --backend-store-uri and --default-artifact-root when starting MLflow server
Not creating experiments before running MLflow projects
Runs get logged to default experiment, making organization and comparison difficult
Create named experiments to keep runs organized
Summary
Deploy an MLflow tracking server to provide a self-service ML platform.
Verify the server is running and accessible inside the cluster.
Create experiments to organize ML runs.
Run ML projects that log parameters and metrics automatically.