Key takeaway
- How to run machine learning training and prediction on Kubernetes: a Flask API, one pod per job, a model store, and where serverless options fit.
Machine learning on Kubernetes is a pattern in which a web API launches a container for each training or prediction job, so many users can run models at the same time without their results colliding. Data scientists build the models; the platform decides where and how they run.
This page is for data science, platform and engineering leads who need to turn models into something a business user can run with a button. It covers the problem, the request flow, how a per-job pod compares with an always-on service, where AI agents fit and what to check before you build.
What is a machine learning prediction platform on Kubernetes?
It is a small web application with an API in front of a Kubernetes cluster. A user uploads data, chooses a model and clicks train or predict. The API records the request in a database and asks Kubernetes to start a pod that does the work. The Kubernetes Jobs documentation describes Jobs as one-off tasks that run to completion and then stop, which is exactly the shape of a training or prediction run.
The Flask documentation describes Flask as a lightweight WSGI web application framework designed to make getting started quick and easy, which is why it is a common choice for the API layer. For background on the data side, see what big data is.
What problem does it solve?
A model in a notebook cannot be used by the business. A team needs a platform that can do three things.
- Train a model on the data a user supplies, then run prediction to produce a forecast.
- Give users a web interface to run a model with a click, without writing code.
- Handle several requests at once, so that one user's run never changes another user's result.
How does the request flow work?
- Upload. The user uploads data through the API, and the details of the data are saved in a database.
- Train. When the user presses train, the API launches a Kubernetes pod to train the model on that data. The finished model is stored in cloud storage.
- Choose. On the prediction page the user sees the available models, uploads input data and picks one.
- Launch. When the user presses predict, the API launches another pod.
- Fetch. The pod reads the details of the input data from the database and downloads the chosen model from cloud storage.
- Predict and save. The pod processes the input with the model, writes the result to the database and exits.
The API can start and remove pods with the official Kubernetes Python client, which is a library for working with the Kubernetes API from Python. To understand the cluster underneath, read Kubernetes architecture and components.
How does a pod per job compare with other ways to serve a model?
A pod per job is not the only design. The right one depends on how often the model runs and how quickly users need an answer.
| Question | Pod per job | Always-on model service | Serverless function |
|---|---|---|---|
| How it runs | A new pod starts for each run and exits | A long-running service holds the model in memory | Code runs on demand when an event arrives |
| Isolation between users | Strong, each run has its own container | Shared process, needs care with concurrent requests | Strong, each call is separate |
| Start-up time | Slower, the pod must start and fetch the model | Fast once running | Depends on the platform and function size |
| Best for | Training and heavy batch prediction | Frequent, low-latency prediction | Small, bursty tasks |
Where do serverless frameworks such as Kubeless fit?
Serverless architectures remove server management from the developer, and FaaS (Function as a Service) lets code run at the moment it is needed. Kubeless was a Kubernetes-native framework for deploying small functions without managing infrastructure, with support for several languages, auto-scaling and event triggers from Kafka and HTTP.
The Kubeless repository says Kubeless is no longer actively maintained by VMware, and the repository was archived on 15 December 2021. For new work, pick a maintained framework.
Where do AI agents fit?
The platform above waits for a person to press a button. An AI agent can take over the routine decisions around it: noticing that new data has arrived, choosing which model to retrain, starting the job, checking the result against agreed limits and asking a person to approve anything unusual. ElixirClaw is the AI agents computing platform from XenonStack and is the product page to read for agent and automation use cases.
What should you check before you build?
- Data handling. Decide where uploaded data is stored, who can see it and how long it is kept.
- Model versions. Record which model version produced each result so a prediction can be explained later.
- Resource limits. Set CPU and memory limits on training pods so one large run cannot starve the rest.
- Failure handling. Decide what happens when a pod fails: retry, alert, or show the user a clear error.
- Access control. Let the API decide who can start training.
- Ownership. Name who approves a model for use and who retires it.
To map one decision your model-serving agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
Frequently asked questions
What is machine learning on Kubernetes?
It is a way of running model training and prediction as containers on a Kubernetes cluster. A web API receives the request and launches a pod that does the work, so many runs can proceed at the same time.
Why run one pod per job?
Each run gets its own container, so results do not collide, and the pod exits when the work is done. Kubernetes describes Jobs as one-off tasks that run to completion and then stop.
Where is the trained model stored?
In the pattern described here the trained model is stored in cloud storage, and the prediction pod downloads the model the user selected before it processes the input.
Is Kubeless still a good choice for serverless on Kubernetes?
Check before you adopt it. Its repository says Kubeless is no longer actively maintained by VMware and was archived on 15 December 2021, so choose a maintained framework for new work.
How do AI agents fit into a prediction platform?
An agent can start retraining, launch jobs through the API, check results against agreed limits and ask a person to approve unusual outcomes, while the platform keeps running the models.
Ready to put AI agents to work? See an ElixirClaw demo: the agentic OS to build, orchestrate and govern AI agents across your enterprise systems.
Explore the XenonStack platform family: ElixirData · ElixirClaw · ElixirHub · NexaStack · MetaSecure · Neural AI · AgentGRC · AgentSRE · AgentAnalyst · AgentInstruct · AgentRAI · AgentScrum · AgentSearch · AgentForce · AI Aviator · SAIF Aviator · CohortIQ · XenonStack AI · XenonStack UAE