Single logo
  • Courses
  • Blog
  • About
Join for freeJoin free
Machine Learning
  • First Look at a Dataset: 6 Checks Before You Plot or Model
  • Plotting Distributions with seaborn: Histograms, KDE, Counts and log1p
  • Scatter Plots and Pair Plots: See How Two Columns Relate
  • Finding Outliers: Box Plots, Violin Plots and the IQR Rule
  • Correlation and Heatmaps: Covariance, df.corr() and What They Miss
  • Train-Test Split and Data Leakage: Split First, Learn After
  • Handling Missing Data: Count the Blanks, Then Fill Them with SimpleImputer
  • Encoding Categorical Data: OrdinalEncoder, OneHotEncoder and LabelEncoder
  • Feature Scaling: StandardScaler, MinMaxScaler and Which Models Care
  • Pipelines and ColumnTransformer: All Preprocessing and the Model in One Object
  • Feature Selection and the Curse of Dimensionality: Keep the Columns That Matter
  • Project: Preprocess Rain in Australia from Raw CSV to Model-Ready Data
    Regression
    • Linear Regression and the Cost Function: Draw a Line, Score It
    • Gradient Descent Explained: Feel the Slope, Step Downhill
    • Linear Regression in scikit-learn: Fit, Predict and Read the Price Tags
    • Regression Metrics: MAE, RMSE, R-squared and the Baseline to Beat
    • Polynomial Regression, Overfitting and Underfitting: Bend the Line, Watch the Test Score
    • Regularisation with Ridge and Lasso: Put a Price on Big Weights
    Classification and Evaluation
    • Logistic Regression and the Sigmoid: Score, Squash, Decide
    • Logistic Regression in scikit-learn: predict, predict_proba and Softmax
    • Why Accuracy Lies: The Confusion Matrix, Baselines and Type I/II Errors
    • Precision, Recall and F1 Score: Two Questions and One Balance
    • ROC Curve, AUC and Choosing a Classification Threshold
    • Handling Imbalanced Data: class_weight, SMOTE and the Resampling Leak
    • Cross-Validation: KFold, StratifiedKFold, cross_val_score and cross_validate
    Classic Algorithms
    • K-Nearest Neighbours (KNN): Distance, k and Why Scaling Is a Must
    • Naive Bayes: Prior Times Likelihood, a Spam Filter by Hand and GaussianNB
    • Support Vector Machines (SVM): The Widest Road, C, Kernels and gamma
    • Decision Trees: Gini, max_depth and Feature Importances on Rain in Australia
    • Bagging and Random Forest: Many Shaky Trees, One Steady Answer
    • Boosting: Residuals by Hand, AdaBoost, Gradient Boosting and XGBoost
    • Voting and Stacking: Does a Team of Models Beat the Best One?
    Model Selection and Tuning
    • Hyperparameter Tuning with GridSearchCV and RandomizedSearchCV
    • Which Features Matter? Feature Importances, Permutation Importance and SHAP
    • Project: The Classification Master Template, from Raw CSV to a Saved Model
    • K-Means Clustering: Find Groups in Data With No Labels
    • Choosing k for K-Means: the Elbow Method and the Silhouette Score
    • Hierarchical Clustering and DBSCAN: Dendrograms, Linkage, eps and Noise
    • Dimensionality Reduction with PCA: 13 Columns Down to 2
    • Association Rules and Market Basket Analysis: Support, Confidence, Lift and Apriori
    • Recommender Systems: Item-Based Collaborative Filtering with Cosine Similarity
    • Bag of Words with CountVectorizer: Turn Text into Word Counts
    • TF-IDF with TfidfVectorizer: Common Words Fade, Rare Words Speak
    • Build a Text Classifier with TF-IDF and a Pipeline: Naive Bayes vs LinearSVC
    • Why Neural Networks: Pixels, One Neuron and Layers
    • The Forward Pass and Activation Functions: ReLU, Sigmoid, Tanh and Softmax
    • Loss and Backpropagation: How Wrong, and Who Is to Blame
    • The Training Loop: Epochs, Mini-Batches, Learning Rate and Optimisers
    • Your First Neural Network with Keras: MNIST Digits at 97.7%
    • The Same Network in PyTorch: DataLoader, nn.Module and the Five-Line Training Loop
    • Convolutional Neural Networks (CNN) Basics: Filters, Feature Maps and Pooling
    • Embeddings: Words as Vectors, Cosine Similarity and nn.Embedding
    • Similarity Search: Finding the Closest Vectors with NumPy and NearestNeighbors
    • Dropout, Early Stopping and Batch Norm: Judge Each One by the Validation Curve
    • Transfer Learning on Images: A Frozen ResNet-18, a Small Head and an Honest Baseline
    • Attention Explained Without the Maths: Query, Key, Value and the Word "it"
    • Transformer Building Blocks in PyTorch: Follow the Shapes Through Attention and a Block
    • Pretrained Models from Hugging Face: A Sentiment Pipeline and Sentence Embeddings on a CPU
    • Loading a Language Model and Running Inference: Download, Load, Tokenize, Generate
    • Model Size and Memory: Parameters x Bytes, Quantization, and Where to Run a Model
    • Training on a GPU: Mixed Precision, Gradient Accumulation and Checkpoints That Really Resume
    • When NOT to Fine-Tune: A Decision Tree of Prompt, RAG, Tools, Then Fine-Tuning
    • Full Fine-Tuning vs LoRA vs QLoRA: What Each One Changes and What It Costs
    • LoRA Fine-Tune of a Tiny Model: Teach SmolLM2-135M Your House Style on a CPU
    • Knowledge Distillation: Teach a Model 100 Times Smaller From a Teacher's Soft Labels
    • Serving Open Models: Continuous Batching, vLLM and Cold Starts
      Engineering Basics
      • Python Virtual Environments: One Project, One Toolbox
      • Git and GitHub Fundamentals: Commits, Branches, Push and Pull
      • Testing a FastAPI App with pytest: Three Small Tests
      • Config and Logging Instead of Hard-Coded Values in ML Training
      • SQL Essentials for Python: SELECT, WHERE, JOIN and GROUP BY
      Data and Features in Production
      • Time Splits and Group Splits: Make the Split Match How the Model Is Used
      • Time Series Basics: Lags, Rolling Windows and Walk-Forward Backtesting
      • Feature Engineering Patterns, Each One Tested: Date Parts, Differences, Windows and Target Encoding
      • Point-in-Time Correctness: Join Features as of Each Event with merge_asof
      • Data Validation and Schema Checks: Stop Bad Input Before It Reaches the Model
      • Training-Serving Skew: Same Model, Different Inputs, and How to Detect It
      • Feature Stores: Offline and Online Stores, and When You Actually Need One
      • Data Versioning with DVC: Tie Every Model to the Exact Data That Trained It
      Experiments and Model Quality
      • MLOps in One Picture: Code, Data, Model and the Lifecycle Loop
      • Experiment Tracking with MLflow: Log Params, Metrics and the Model, Then Compare Runs
      • MLflow Model Registry Aliases: Serve the Champion, Ship a New Version and Roll Back in One Line
      • The Cost of Being Wrong: Baselines, a Price per Mistake and the Cheapest Threshold
      • Probability Calibration: Can You Trust the 0.8? Reliability Curves, Platt and Isotonic
      • Slice Evaluation and Fairness Checks: Score the Model Group by Group
      Serving Models
      • Saving and Loading Models with joblib: One Pipeline, One File
      • FastAPI Hello World: Routes, uvicorn and the Free Swagger Page
      • Deploy a Machine Learning Model with FastAPI: POST /predict for a Saved Model
      • Docker Essentials for ML: Images, Containers and Volumes with a Model API
      • Containerising a Model API: A Dockerfile for FastAPI and scikit-learn, Line by Line
      • Online, Batch or Streaming? Picking the Serving Pattern for an ML Model
      • A Production FastAPI for an ML Model: Input Limits, /health, /ready and a Model Version
      • Batch Scoring a Million Rows: Chunks, a Run ID and a Safe Rerun
      • Latency Math: p50, p95, p99 and Why the Tail Reaches Your Users
      • Measuring Latency of an ML API: Timing Inside with OpenTelemetry, Outside with a Load Test and Locust
      • Making ML Inference Fast: ONNX, Micro-Batching and Quantisation, Measured
      • Sizing and Autoscaling an Inference Service: From One Replica to a Replica Count
      Pipelines, CI/CD and Cloud
      • The Training Pipeline as a DAG: Steps, Files, Retries and a Safe Rerun
      • Orchestrating ML Pipelines with Airflow: Schedule, Retries and Backfill
      • Retries and Backoff for Reliable Tasks: Retry What Heals, Wait Longer, Add Jitter, Set Limits
      • CI with GitHub Actions: Run the Tests and Build the Docker Image on Every Push
      • CI/CD for ML: A Quality Gate That Blocks a Weaker Model, Even When Every Test Passes
      • Which Cloud for What: AWS, Azure, Google Cloud, GPU Clouds, Edge and Platforms
      • IaaS, PaaS, Containers or Serverless? Choosing Where a Model API Runs
      • Kubernetes at a High Level: Pods, a Deployment and a Service for a Model API
      • Managed ML Platforms: What SageMaker, Vertex AI and Azure ML Give You, and Tie You To
      • Deploying a Model API to AWS: ECR, Secrets Manager, CloudWatch and Fargate, Then Teardown
      • Cloud Cost Thinking for ML: Size x Count x Hours x Rate, and Three Decisions Worth Ten Times
      Monitoring and Release
      • Monitoring Drift and Retraining: When a Model Gets Worse With No Code Change
      • Drift Detection in Code: PSI Bin by Bin, the KS Test, Evidently and a Measured Threshold
      • Shadow, Canary and Rollback: Releasing a New Model Without Betting Everything on It
      • A/B Tests for Models: Did the New Model Make Things Better for People?
      • When Labels Arrive Weeks Late: What to Watch Before You Can Grade the Model
      • Retraining Triggers: Schedule, Drift and Performance, Wired to One Retrain Pipeline
      • The User Feedback Loop: Why Thumbs Up Isn't the Truth, and What a Small Random Review Adds
      • Debugging a Model in Production: A Four-Step Runbook, Cheap Checks First
      • Project: Car Price Predictor End to End, from CSV to a FastAPI Price API
      1. Blog
      2. /
      3. Machine Learning
      4. /
      5. MLOps and Production ML

      Kubernetes at a High Level: Pods, a Deployment and a Service for a Model API

      The ticket priority API on a local Kubernetes cluster: three Pods from one Deployment, one steady Service name, a deleted Pod replaced on its own, a rolling update from ticket-api:1 to :2, and a missing image that stalls safely. Then the honest question: do you need it?

      Chaand Sheikh

      ·27 November 2026Pipelines, CI/CD and Cloud

      What you will learn

      • Explain Kubernetes as a manager that keeps what you asked for matched with what's running
      • Name the pieces: cluster, node, Pod, control plane
      • Read a Deployment and a Service manifest, and what a readiness probe does
      • Follow a rolling update to a new model image, and what happens when the image is missing

      Before you start

      • Docker Essentials for ML
      • IaaS, PaaS, Containers or Serverless?

      Our model sits inside a container, and that runs fine on one machine. So what happens when one machine isn't enough? This article looks at Kubernetes from high up: what it is, what it takes off your hands, and whether you need it at all.

      Three words cover most of what you need: Pod, Deployment and Service. All the output below comes from the ticket priority API running on a small local cluster.

      A shop with a shift manager

      Think of a shop with a shift manager. You don't tell the manager who stands where. You say one thing: "I want three people at the counter." Someone goes home sick. The manager sees two, you asked for three, so another person gets called in. And customers ring one shop number, and whoever's free picks up.

      That's the whole idea of Kubernetes. You write down what you want, and something keeps putting it right.

      One machine, nobody watching

      Now without that manager. One machine, one container, our API answering requests.

      • The machine dies, and nothing answers until a person notices.
      • Traffic jumps, so you start a second copy, and now something has to split the requests.
      • A new model comes out. Stop the old one, start the new one, and there's a gap where nothing answers.

      On one machine you can script around this. With many machines and many services, you want a manager, and Kubernetes is a widely used one.

      Cluster, node, Pod

      • A cluster is a group of machines. Each machine is called a node.
      • A Pod is the smallest thing Kubernetes runs. For us, it's one Pod with our container inside.
      • Pods come and go, and each new one gets a new address. Keep that in mind.
      • The control plane is the shop manager. It compares what you asked for with what's running, and closes the gap.

      A Deployment: how many, and of what

      You ask by writing a manifest, a YAML file. Here's the Deployment:

      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: ticket-api
      spec:
        replicas: 3
        selector:
          matchLabels:
            app: ticket-api
        template:
          metadata:
            labels:
              app: ticket-api
          spec:
            containers:
              - name: api
                image: ticket-api:1
                ports:
                  - containerPort: 8000
                env:
                  - name: API_KEY
                    valueFrom:
                      secretKeyRef:
                        name: ticket-key
                        key: api-key
                readinessProbe:
                  httpGet:
                    path: /health
                    port: 8000
      • replicas: 3 is the note to the manager.
      • image: ticket-api:1 is the same container image as before.
      • containerPort: 8000 is where uvicorn listens.
      • The API key comes from a Kubernetes secret called ticket-key, created once with kubectl create secret generic, so the key isn't in the image or the YAML.

      Apply it, wait for the rollout, and list the Pods:

      kubectl apply -f k8s/
      kubectl rollout status deployment/ticket-api --timeout=180s
      kubectl get pods
      deployment.apps/ticket-api created
      service/ticket-api created
      Waiting for deployment "ticket-api" rollout to finish: 0 of 3 updated replicas are available...
      Waiting for deployment "ticket-api" rollout to finish: 1 of 3 updated replicas are available...
      Waiting for deployment "ticket-api" rollout to finish: 2 of 3 updated replicas are available...
      deployment "ticket-api" successfully rolled out
      NAME                          READY   STATUS    RESTARTS   AGE
      ticket-api-749676d77f-bwggl   1/1     Running   0          14s
      ticket-api-749676d77f-gl46z   1/1     Running   0          14s
      ticket-api-749676d77f-l6l6n   1/1     Running   0          14s

      Three Pods, all running. Now delete one on purpose:

      kubectl delete pod ticket-api-749676d77f-bwggl --wait=false
      kubectl get pods
      NAME                          READY   STATUS      RESTARTS   AGE
      ticket-api-749676d77f-bwggl   0/1     Completed   0          16s
      ticket-api-749676d77f-gl46z   1/1     Running     0          16s
      ticket-api-749676d77f-l6l6n   1/1     Running     0          16s
      ticket-api-749676d77f-rb2vb   0/1     Running     0          1s

      The control plane saw two against three, and a new Pod, rb2vb, was already starting one second later. A Deployment is a request that keeps being checked.

      A Service: one steady name

      Pods keep changing address, so how does anyone call them? With a Service. It gives you one steady name, like the shop's phone number.

      apiVersion: v1
      kind: Service
      metadata:
        name: ticket-api
      spec:
        selector:
          app: ticket-api
        ports:
          - port: 80
            targetPort: 8000
      A Service in front of the Pods request Service ticket-api :80 app=ticket-api Pod gl46z 1/1 ready port 8000 Pod l6l6n 1/1 ready port 8000 Pod rb2vb 0/1 not ready waits for /health
      The Service picks up any Pod with the label. A Pod gets requests only once its readiness probe answers.

      The selector says app: ticket-api, so it picks up any Pod wearing that label, and new Pods join by themselves. Port 80 outside, target port 8000 on the container.

      kubectl get service ticket-api
      NAME         TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE
      ticket-api   ClusterIP   10.96.3.195   <none>        80/TCP    14s

      On a local cluster you can forward a port to the Service and send a ticket through it:

      kubectl port-forward service/ticket-api 18080:80
      curl -s localhost:18080/predict -H "x-api-key: $API_KEY" --json @ticket.json
      {"priority":"low","p_high":0.2274}

      One more thing: the readiness probe in the Deployment calls /health, and a Pod only gets requests once that answers. That's why rb2vb above showed 0/1: running, but zero of one ready, so it waited. A moment later it was 1/1.

      Putting out a new model

      A new model means one line changes in the Deployment: image: ticket-api:1 becomes image: ticket-api:2. Apply it again:

      kubectl apply -f k8s/
      kubectl rollout status deployment/ticket-api --timeout=240s

      Repeated "Waiting" lines are trimmed from this output:

      deployment.apps/ticket-api configured
      service/ticket-api unchanged
      Waiting for deployment "ticket-api" rollout to finish: 1 out of 3 new replicas have been updated...
      Waiting for deployment "ticket-api" rollout to finish: 2 out of 3 new replicas have been updated...
      Waiting for deployment "ticket-api" rollout to finish: 1 old replicas are pending termination...
      deployment "ticket-api" successfully rolled out

      Watching the Pods (kubectl get pods -w) shows the order:

      1. A new Pod with version 2 starts next to the three old ones (Pending, ContainerCreating, Running 0/1).
      2. Once /health answers, it turns 1/1 and starts getting requests.
      3. Then one old Pod goes to Terminating, and the next new one starts.
      4. One step at a time, until the rollout says successfully rolled out.
      NAME         READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES         SELECTOR
      ticket-api   3/3     3            3           70s   api          ticket-api:2   app=ticket-api

      This is a rolling update. Some Pods were always answering, so the gap from earlier is closed.

      When the new image doesn't exist

      Now point the Deployment at an image that isn't there:

      Waiting for deployment "ticket-api" rollout to finish: 1 out of 3 new replicas have been updated...
      error: timed out waiting for the condition
      NAME                          READY   STATUS             RESTARTS   AGE
      ticket-api-5bb4877b9-gcbjx    0/1     ImagePullBackOff   0          46s
      ticket-api-765786b8db-629h5   1/1     Running            0          87s
      ticket-api-765786b8db-rzqb9   1/1     Running            0          63s
      ticket-api-765786b8db-xf62s   1/1     Running            0          75s

      The new Pod sits in ImagePullBackOff, the rollout stalls, and the three old Pods carry on answering. A request through the Service still came back {"priority":"low","p_high":0.2274}. A bad release stalls safely instead of taking the API down.

      So do you need it?

      Let's be honest. Kubernetes asks a lot of you: clusters, networking, upgrades and permissions. The big clouds run the control plane for you: EKS on AWS, GKE on Google Cloud, AKS on Azure. Your manifests and Pods are still yours, though.

      • One model API and a small team: a managed container service is usually plenty (see IaaS, PaaS, containers or serverless).
      • Many services, several teams, or people who already know it: this is where it pays off.

      The rule: start with the simpler service, and move when the team and the workload ask for it.

      Recap

      WordWhat it does
      Control planeKeeps checking what you asked for against what's running, and closes the gap
      PodRuns the container; comes and goes with a new address
      DeploymentHow many and of what: replicas: 3, image: ticket-api:1
      ServiceOne steady name in front of the Pods, by label
      Readiness probeNo requests until /health answers
      Rolling updateNew Pods in, old Pods out, one at a time; a missing image stalls safely

      Try it yourself: write down, in order, what happens to the Pods when the image changes to ticket-api:2. Then check your list against the steps above.

      Built this? Share your solution in the StudyEasy AI Community.

      Join free on Skool →
      ← Previous
      IaaS, PaaS, Containers or Serverless? Choosing Where a Model API Runs
      Next →
      Managed ML Platforms: What SageMaker, Vertex AI and Azure ML Give You, and Tie You To
      Single logo

      StudyEasy AI Community

      Hosted onSkool

      Learn AI engineering, share what you build, and connect with other learners.

      • Free resources: lesson files, notebooks and code

      • Ask questions and join engineering discussions

      • Meet real people learning and building with AI

      Join free on Skool
      Go deeper with a course

      Machine Learning Engineer: From First Model to ML Engineer

      Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (opens in a new tab)

      Related articles
      Python Virtual Environments: One Project, One Toolbox

      Why every Python project gets its own virtual environment: two projects that need different versions of requests, python -m venv .venv, activation, pip install and the PyCharm setting that activates it for you.

      Git and GitHub Fundamentals: Commits, Branches, Push and Pull

      The Git you use every day, on a tiny hello-ml project: commits as save points, the staging area, a branch merged with a fast-forward, then push, clone, pull and pull requests with a teammate.

      Testing a FastAPI App with pytest: Three Small Tests

      A tiny FastAPI app with a Hello World route and a name route that refuses numbers, three pytest tests that check it, and what happens when the validation is deleted by mistake.

      Config and Logging Instead of Hard-Coded Values in ML Training

      Take the hard-coded values out of a car price training script: one config.toml read with tomllib, logging with levels and a run id on every line, and secrets read from the environment. Same RMSE, 2195, before and after.

      On this page
      • A shop with a shift manager
      • One machine, nobody watching
      • Cluster, node, Pod
      • A Deployment: how many, and of what
      • A Service: one steady name
      • Putting out a new model
      • When the new image doesn't exist
      • So do you need it?
      • Recap
      Single logo

      StudyEasy AI Community

      Hosted onSkool

      Learn AI engineering, share what you build, and connect with other learners.

      • Free resources: lesson files, notebooks and code

      • Ask questions and join engineering discussions

      • Meet real people learning and building with AI

      Join free on Skool
      Go deeper with a course

      Machine Learning Engineer: From First Model to ML Engineer

      Learn machine learning in Python, then ship it: data analysis, regression, classification, tuning, deployment and MLOps.View on Udemy ↗: Machine Learning Engineer: From First Model to ML Engineer (opens in a new tab)

      Single logo

      Empowering Education, One Course at a Time

      About
      About usContact usFAQs
      Legal
      Terms of ServicePrivacy Policy

      © 2026 StudyEasy Organization. All rights reserved.