########################### 11.0.5 Cloud Service Models ########################### Think of cloud services like different levels of a restaurant experience: ===================================== 1. Infrastructure as a Service (IaaS) ===================================== **Restaurant Analogy: Rent a Kitchen** .. code-block:: text You rent a kitchen space with: + Stove, oven, refrigerator (provided) + Basic utilities (provided) - You bring your own ingredients - You do all the cooking - You clean up everything - You hire your own chef **In Cloud Terms:** IaaS provides the basic building blocks for cloud IT. You get virtual machines, networking, and storage, but you manage everything else. **What You Get:** - Virtual machines (like your laptop, but in the cloud) - Virtual networks (connect your VMs) - Storage (save your files) - Load balancers (distribute traffic) **What You Manage:** - Operating system (Windows, Linux) - Applications and frameworks - Security patches - Scaling and monitoring **Perfect for Containers:** .. code-block:: yaml # IaaS gives you VMs where you run Kubernetes Your Container Journey on IaaS: 1. Rent virtual machines from cloud provider 2. Install Docker on the VMs 3. Set up Kubernetes cluster 4. Deploy your containers 5. Manage everything yourself **Modern Container Evolution (2024):** .. code-block:: text IaaS → CaaS (Container as a Service) → Serverless Containers Traditional IaaS: Managed CaaS: Serverless: ├─ You manage VMs ├─ Provider manages ├─ No infrastructure ├─ Install Kubernetes │ Kubernetes control │ management ├─ Patch and update │ plane ├─ Pay per request └─ Monitor everything ├─ You deploy pods └─ Auto-scaling to zero └─ Shared responsibility **Examples:** **Pure IaaS:** - **AWS EC2** (Elastic Compute Cloud) - **Google Compute Engine** (GCE) - **Azure Virtual Machines** - **DigitalOcean Droplets** **Container-Focused IaaS (CaaS):** - **AWS EKS** (Managed Kubernetes control plane) - **Google GKE** (Google Kubernetes Engine) - **Azure AKS** (Azure Kubernetes Service) - **AWS Fargate** (Serverless containers) **Use Cases:** - Migrating existing applications to cloud - Need full control over the environment - Custom software that needs specific OS configuration - Development and testing environments **Pricing Model:** .. code-block:: text Pay for: + VM size (CPU, RAM) + Storage space + Network traffic + Time running (per hour/second) Example: Small VM: $20/month Large VM: $200/month Storage: $0.10/GB/month =============================== 2. Platform as a Service (PaaS) =============================== **Restaurant Analogy: Order from a Menu** .. code-block:: text You sit down at a restaurant: + Kitchen is ready (provided) + Chef is provided + Tables and service (provided) - You choose from the menu - You can't change the recipes - Limited customization **In Cloud Terms:** PaaS provides a complete development and deployment environment. You focus on your code, the platform handles everything else. **What You Get:** - Runtime environment (Java, Python, Node.js) - Database services - Web servers - Development tools - Automatic scaling - Monitoring and logging **What You Manage:** - Your application code - Configuration settings - Data and content **Container Platform Examples:** .. code-block:: text PaaS Container Platforms: ┌─────────────────────────────────────┐ │ Your Code & Containers │ ← You manage ├─────────────────────────────────────┤ │ Kubernetes Platform │ ← Platform manages │ Container Registry │ │ CI/CD Pipelines │ │ Monitoring & Logging │ │ Security & Compliance │ │ Auto-scaling │ │ Load Balancing │ └─────────────────────────────────────┘ **Examples:** - **AWS Elastic Beanstalk** (deploy code, AWS handles infrastructure) - **Google App Engine** (serverless platform) - **Azure App Service** (web app platform) - **Heroku** (developer-friendly platform) - **Red Hat OpenShift** (Kubernetes PaaS) **Container PaaS Workflow:** .. code-block:: bash # Example: Deploying to Google App Engine (PaaS) # 1. Write your app (same as always) echo "FROM python:3.9 COPY . /app WORKDIR /app RUN pip install -r requirements.txt CMD ['python', 'app.py']" > Dockerfile # 2. Deploy (platform handles everything else) gcloud app deploy # That's it! Platform handles: # - Building the container # - Managing Kubernetes # - Setting up load balancers # - Configuring monitoring # - Auto-scaling **Use Cases:** - Rapid application development - Focus on code, not infrastructure - Automatic scaling requirements - Standardized deployment patterns **Pricing Model:** .. code-block:: text Pay for: + Application usage (requests, compute time) + Storage and database usage + Additional services used Example: Basic web app: $10-50/month High-traffic app: $100-1000/month (Scales automatically with usage) =============================== 3. Software as a Service (SaaS) =============================== **Restaurant Analogy: Food Delivery** .. code-block:: text Order food delivery: + Everything is prepared (provided) + Delivered to your door (provided) + Just eat and enjoy (provided) - No cooking required - No cleanup required - No ingredient shopping **In Cloud Terms:** SaaS provides complete, ready-to-use applications. You just log in and use them. **What You Get:** - Fully functional applications - Automatic updates - Security management - Data backup - Multi-device access - Collaboration features **What You Manage:** - Your data and content - User accounts and permissions - Customization within the app **DevOps SaaS Tools You Already Use:** .. code-block:: text Development SaaS: + GitHub (code repository) + VS Code Online (development environment) + Docker Hub (container registry) CI/CD SaaS: + GitHub Actions (pipeline automation) + CircleCI (continuous integration) + Jenkins Cloud (build automation) Monitoring SaaS: + DataDog (application monitoring) + New Relic (performance monitoring) + Sentry (error tracking) **Examples:** - **Gmail** (email service) - **Microsoft 365** (office applications) - **Slack** (team communication) - **Zoom** (video conferencing) - **Salesforce** (customer relationship management) - **GitHub** (version control and CI/CD) **Use Cases:** - Standard business applications - No development required - Immediate productivity - Collaboration across teams **Pricing Model:** .. code-block:: text Pay for: + User licenses (per user per month) + Storage limits + Premium features Example (2024 pricing): GitHub: Free for public repos, $4/user/month for private Slack: Free for small teams, $8.75/user/month for pro Microsoft 365: $6-22/user/month depending on plan Docker Hub: Free tier, $5/month for pro features ============================================ 4. Function as a Service (FaaS) / Serverless ============================================ **Restaurant Analogy: Food Truck** .. code-block:: text Order from a food truck: + Truck appears when you need food + Pay only for the meal you eat + No setup or cleanup required + Scales automatically (more trucks for events) - Limited menu options - Can't customize the kitchen **In Cloud Terms:** FaaS lets you run code without thinking about servers at all. You upload a function, and it runs only when triggered. **What You Get:** - Event-driven execution (HTTP requests, file uploads, database changes) - Automatic scaling (from 0 to thousands of instances) - Pay-per-execution pricing - Built-in high availability **What You Manage:** - Just your application code - Function configuration - Event triggers and integrations **Perfect for Microservices:** .. code-block:: python # AWS Lambda function example def lambda_handler(event, context): # Your containerized app logic here user_id = event['user_id'] # Process business logic result = process_user_data(user_id) return { 'statusCode': 200, 'body': json.dumps(result) } **Serverless Container Services (2024):** .. code-block:: text Modern Serverless Evolution: Traditional Serverless: Serverless Containers: ├─ Limited runtime support ├─ Any container image ├─ Function size limits ├─ Larger applications ├─ Cold start latency ├─ Improved cold starts └─ Vendor lock-in └─ More portable Examples: ├─ AWS Lambda + Custom Runtime → AWS Fargate ├─ Google Cloud Functions → Google Cloud Run ├─ Azure Functions → Azure Container Instances └─ Vercel Functions → Vercel Edge Runtime **Examples:** **Pure FaaS:** - **AWS Lambda** (most popular) - **Google Cloud Functions** - **Azure Functions** - **Vercel Functions** (web-focused) **Serverless Containers:** - **AWS Fargate** (serverless EKS/ECS) - **Google Cloud Run** (serverless containers) - **Azure Container Instances** - **Railway, Render** (developer-friendly platforms) **Use Cases:** - API endpoints and webhooks - Image/file processing - Real-time data processing - Scheduled tasks and cron jobs - Event-driven microservices **Pricing Model:** .. code-block:: text Pay for: + Function execution time (milliseconds) + Memory allocation during execution + Number of requests Example (AWS Lambda 2024): Free Tier: 1M requests + 400,000 GB-seconds/month After free tier: ├─ $0.20 per 1M requests ├─ $0.0000166667 per GB-second └─ Example: 10M requests/month ≈ $25-50 ================================================= Service Model Evolution: The Abstraction Spectrum ================================================= .. code-block:: text 2024 Service Landscape: Low Abstraction → High Abstraction IaaS CaaS PaaS FaaS/Serverless SaaS │ │ │ │ │ ├─ Raw VMs ├─ Managed K8s ├─ App Platform ├─ Functions ├─ Ready Apps ├─ You manage ├─ Shared mgmt ├─ Code focus ├─ Event-driven ├─ Just use it │ everything │ (nodes+pods) │ (runtime) │ (no servers) │ (config only) │ │ │ │ │ Examples: Examples: Examples: Examples: Examples: ├─ AWS EC2 ├─ AWS EKS ├─ Heroku ├─ AWS Lambda ├─ GitHub ├─ GCP GCE ├─ GCP GKE ├─ Vercel ├─ Vercel Funcs ├─ Slack └─ Azure VMs └─ Azure AKS └─ Railway └─ Cloudflare └─ Zoom ======================== Service Model Comparison ======================== .. code-block:: text ┌─────────────────┬─────────────┬─────────────┬─────────────┐ │ Responsibility │ IaaS │ PaaS │ SaaS │ ├─────────────────┼─────────────┼─────────────┼─────────────┤ │ Applications │ You │ You │ Provider │ │ Data │ You │ You │ You │ │ Runtime │ You │ Provider │ Provider │ │ Middleware │ You │ Provider │ Provider │ │ OS │ You │ Provider │ Provider │ │ Virtualization │ Provider │ Provider │ Provider │ │ Servers │ Provider │ Provider │ Provider │ │ Storage │ Provider │ Provider │ Provider │ │ Networking │ Provider │ Provider │ Provider │ └─────────────────┴─────────────┴─────────────┴─────────────┘ **Control vs Convenience:** .. code-block:: text More Control ←───────────────────────────→ More Convenience IaaS PaaS SaaS ├─ Full control ├─ Balanced approach ├─ Just use it ├─ More complex ├─ Faster development ├─ No setup ├─ More work ├─ Some restrictions ├─ Limited control └─ Maximum flexibility └─ Good for most apps └─ Immediate productivity ======================================= Container Journey Across Service Models ======================================= **How Your Container Skills Apply:** .. code-block:: text IaaS Container Deployment: ┌────────────────────────────────────┐ │ 1. Rent VMs │ │ 2. Install Docker yourself │ │ 3. Set up Kubernetes cluster │ │ 4. Configure networking │ │ 5. Deploy your containers │ │ 6. Manage everything │ └────────────────────────────────────┘ PaaS Container Deployment: ┌────────────────────────────────────┐ │ 1. Push your container image │ │ 2. Platform handles deployment │ │ 3. Platform manages Kubernetes │ │ 4. Auto-scaling configured │ │ 5. Monitoring included │ │ 6. Just write code! │ └────────────────────────────────────┘ SaaS (No containers needed): ┌────────────────────────────────────┐ │ 1. Sign up for service │ │ 2. Log in and use │ │ 3. No deployment needed │ │ 4. Everything is pre-built │ └────────────────────────────────────┘ ================================ Choosing the Right Service Model ================================ **Decision Framework:** .. code-block:: text Ask yourself: "Do I need custom infrastructure?" ├─ YES → Consider IaaS │ ├─ Legacy applications │ ├─ Specific OS requirements │ └─ Custom networking │ └─ NO → "Do I want to write code?" ├─ YES → Consider PaaS │ ├─ Web applications │ ├─ APIs and microservices │ └─ Custom business logic │ └─ NO → Use SaaS ├─ Standard business apps ├─ Productivity tools └─ Ready-made solutions **Real-World Example: E-commerce Company:** .. code-block:: text Company uses ALL THREE models: SaaS: ├─ Gmail for email ├─ Slack for team communication ├─ Salesforce for customer management └─ GitHub for code management PaaS: ├─ Web frontend on Google App Engine ├─ APIs on AWS Elastic Beanstalk ├─ Database on Azure SQL Database └─ Container platform on Red Hat OpenShift IaaS: ├─ Data analytics VMs on AWS EC2 ├─ Legacy systems on Azure VMs ├─ Development environments └─ Custom Kubernetes clusters ================================ Cost Comparison by Service Model ================================ **Example: Small Web Application** .. code-block:: text IaaS Approach: ├─ VM costs: $50/month ├─ Storage: $10/month ├─ Networking: $5/month ├─ Management time: 20 hours/month x $50/hour = $1000 └─ Total: $1,065/month PaaS Approach: ├─ Platform usage: $80/month ├─ Database service: $25/month ├─ Management time: 2 hours/month x $50/hour = $100 └─ Total: $205/month SaaS Approach: ├─ Use existing solution: $50/month ├─ Customization: Limited ├─ Management time: 0 hours └─ Total: $50/month ===================================== Serverless: The Emerging Fourth Model ===================================== **Function as a Service (FaaS):** .. code-block:: text Restaurant Analogy: Meal Kit Delivery + Pre-measured ingredients (provided) + Recipe instructions (provided) + You just follow the steps - Pay only when you cook - No kitchen rental when not cooking **Serverless Container Examples:** .. code-block:: yaml # AWS Lambda with container support FROM public.ecr.aws/lambda/python:3.9 COPY app.py ${LAMBDA_TASK_ROOT} COPY requirements.txt ${LAMBDA_TASK_ROOT} RUN pip install -r requirements.txt CMD ["app.lambda_handler"] .. code-block:: bash # Deploy container as serverless function aws lambda create-function \ --function-name my-container-function \ --package-type Image \ --code ImageUri=123456789012.dkr.ecr.us-west-2.amazonaws.com/my-func:latest **Benefits:** - Pay only for execution time - Automatic scaling to zero - No server management - Perfect for event-driven applications **Examples:** - **AWS Lambda** (serverless functions) - **Google Cloud Functions** (event-driven functions) - **Azure Functions** (serverless compute) - **Cloudflare Workers** (edge computing) .. note:: **Your Container Skills Are Universal!** Whether you choose IaaS, PaaS, or even serverless, your Docker and Kubernetes knowledge applies: - Same Dockerfile syntax - Same container concepts - Same orchestration principles - Same monitoring approaches The service model just changes HOW MUCH the platform manages for you!