Deploy to Kubernetes
Run the kit on any Kubernetes cluster with the generated manifests.
The Kubernetes kit contains manifests that run your model on any cluster: a managed one in a cloud, or your own. This page is about deploying a single model. To run the mlflow platform itself on Kubernetes, see Self-hosting on Kubernetes.
Download the Kubernetes kit
Open the Deploy anywhere tab of the Deploy & export panel, and select Download kit on the Kubernetes card. Unzip it. Besides the files every kit has (see Deploy with Docker), it holds four manifests in deploy/kubernetes/:
| File | What it creates |
|---|---|
deployment.yaml | A Deployment with 2 replicas of the model container. |
service.yaml | A ClusterIP Service on port 80 that forwards to the container's port 8080. |
hpa.yaml | A HorizontalPodAutoscaler that keeps between 2 and 10 replicas at 70% average CPU. |
ingress.example.yaml | An optional Ingress example. |
You need kubectl pointed at your cluster, Docker, and a container registry that the cluster can pull from. envsubst (part of the gettext package) fills the image name into the Deployment.
Apply the manifests
Build and push the image
Choose the registry path. my-model and v-1 stand for the image name and tag generated in your kit's README.
export IMAGE=<REGISTRY>/my-model:v-1
docker build -t $IMAGE .
docker push $IMAGEIf the registry is private, create an image pull secret in the cluster and reference it in deployment.yaml under imagePullSecrets.
Apply the Deployment and Service
envsubst < deploy/kubernetes/deployment.yaml | kubectl apply -f -
kubectl apply -f deploy/kubernetes/service.yaml -f deploy/kubernetes/hpa.yaml
kubectl rollout status deployment/my-modeldeployment.yaml refers to ${IMAGE}, and envsubst replaces it with the value you exported.
Try it
kubectl port-forward svc/my-model 8080:80
curl http://localhost:8080/healthThe Deployment is hardened by default. Pods run as a non-root user, with a read-only root file system, no privilege escalation, all Linux capabilities dropped, and the default seccomp profile. A writable /tmp is provided as an empty volume. Each pod requests 250m CPU and 512 MiB of memory, with limits of 1 CPU and 2 GiB, and has readiness and liveness probes on /health.
The Service is cluster-internal on purpose
The prediction service has no authentication. The Service type is ClusterIP, so only workloads inside the cluster can reach it. Use ingress.example.yaml only behind an ingress controller that authenticates callers, and set its <HOSTNAME> and <INGRESS_CLASS> first.
Scale and update
Scaling is automatic between 2 and 10 replicas. The autoscaler needs the metrics-server add-on in the cluster. Edit hpa.yaml to change the range or the CPU target, or edit replicas in deployment.yaml if you remove the autoscaler.
To release a new version of the model, download a new kit, build and push the new image under a new tag, then update the Deployment:
kubectl set image deployment/my-model model=<REGISTRY>/my-model:<NEW_TAG>
kubectl rollout status deployment/my-modelThe container is named model in the Deployment, which is the name kubectl set image needs. Kubernetes replaces pods gradually, so the model keeps answering during the update. If the new version misbehaves, go back with:
kubectl rollout undo deployment/my-modelUse a new tag for each image. Reusing a tag can leave nodes running an old cached copy.
Call the endpoint
From inside the cluster, call the Service by name. The request body is the kit's sample.json.
curl -X POST http://my-model/predict \
-H "Content-Type: application/json" \
-d @sample.jsonFrom your machine, use the port-forward command above and call http://localhost:8080/predict. The answer has a predictions list, and classification models add probabilities and classes. Requests are limited to 5 MB and 1,000 records. The routes and error codes are in Deploy with Docker.
Next steps
Updated 2026-11-22