Title: Lab 12 — Serverless and Kubernetes Model Serving, Side by Side
Course: AIINFRA 101: Applied Infrastructure & Containerization > Section: Week 12 — Managed & Serverless Kubernetes in the Cloud

🛠️ Lab 12 — Serverless and Kubernetes Model Serving, Side by Side (50 pts)

Goal: Build the same simple prediction service two ways — once as a serverless AWS Lambda function, and once as a containerized app on a local Kubernetes cluster — so you can directly compare the developer experience, scaling behavior, and operational model of each, at zero cloud cost. Steps:

1. Set up AWS Lambda (free tier). Follow AWS's official "Run a Serverless Hello World with AWS Lambda" tutorial to create your first function in the console. AWS's free tier includes 1 million requests and 400,000 GB-seconds of compute per month, forever — this lab stays well within that.
2. Invoke it manually. Use the Lambda console's "Test" feature to manually invoke your Hello World function with a sample event payload. Confirm you can see the execution result and the CloudWatch log output.
3. Extend the function to serve a prediction. Train a tiny scikit-learn model locally (e.g., a small classifier on the Iris dataset), serialize it with joblib, and package it as a Lambda deployment (zip or container image). Modify your handler to accept a payload of feature values, load the model, and return a JSON prediction.
4. Test the extended Lambda. Invoke it with two or three sample payloads and record the JSON responses.
5. Install Minikube. Install Minikube (free, open source) locally and follow the official Kubernetes "Hello Minikube" tutorial to confirm your cluster starts and you can deploy a basic app with kubectl.
6. Containerize a model-serving app. Reuse (or adapt) a FastAPI + scikit-learn serving app from earlier in this course. Add a /health endpoint that returns a 200 status, and a /predict endpoint that mirrors the Lambda's prediction logic. Build it into a Docker image.
7. Deploy to Minikube. Write a Kubernetes Deployment manifest (with a liveness/readiness probe pointed at /health) and a Service manifest, then apply both with kubectl apply -f. Confirm the pod reaches Running and passes its health check.
8. (Optional stretch) Try Knative on kind. Set up a local cluster with kind, install Knative Serving with the Kourier networking layer, and redeploy your containerized model as a Knative Service. Observe how Knative scales your pod to zero when idle and back up on a request — serverless behavior, on your own Kubernetes cluster.
9. Write your comparison. In 300–400 words, compare the two approaches: What did you configure by hand in each case? Which one scaled to zero more naturally? Where did the operational burden (patching, health checks, scaling rules) fall on you versus the platform?

Deliverables: Submit your Lambda function code (with sample invocation payloads and responses), your Kubernetes manifests (Deployment + Service, and Knative YAML if attempted), a screenshot or terminal output showing your pod passing its health check, and your written comparison (300–400 words).