# Day16: AWS Containers

### Monolithic Architecture

In a **Monolithic Architecture**, a single application is responsible for all aspects of the system. This includes:

* **Load Balancing**
    
* **Marketing**
    
* **Frontend**
    
* **Backend**
    

**Characteristics:**

* **Tightly Coupled Functionality**: All components of the application are interconnected and interdependent. Changes to one part of the system can affect others.
    

### Microservices Architecture

**Microservices Architecture** involves multiple applications or services, each responsible for a specific function or set of functions.

**Characteristics:**

* **Isolated Functionality**: Each service operates independently and is stateless. This allows for isolated updates and scaling.
    

### VMs vs Containers

#### Virtual Machines (VMs)

* **Isolation**: VMs provide isolation through separate operating systems and virtualized hardware. This can lead to resource conflicts, security issues, and inefficient use of space.
    
* **Resource Overhead**: Higher, as each VM includes its own OS in addition to the application.
    
* **Startup Time**: Slower, as it requires booting a full operating system.
    
* **Management**: Typically managed through hypervisors like VMware or Hyper-V.
    

#### Containers

* **Structure**: Containers share the host OS kernel and include only the application and its dependencies.
    
* **Isolation**: Achieved through process-level isolation using namespaces and control groups.
    
* **Resource Overhead**: Lower, as containers are lightweight and share the host OS.
    
* **Startup Time**: Faster (seconds), since containers leverage the already running host OS.
    
* **Management**: Managed using services like AWS ECS (Elastic Container Service), EKS (Elastic Kubernetes Service), or other container orchestration tools.
    

### Kubernetes

* **Definition**: Kubernetes is an open-source container orchestration system designed for automating deployment, scaling, and management of containerized applications.
    
* **Origin**: Created by Google and now maintained by the Cloud Native Computing Foundation (CNCF).
    
* **Commonly Known As**: "k8s," with "8" representing the number of letters between "k" and "s."
    
* **Advantage**: Kubernetes can run containers distributed across multiple VMs.
    
* **Unique Component**: **Pods** – a group of one or more containers sharing storage, network resources, and other settings.
    
* **Use Case**: Ideal for managing large-scale microservices architectures with numerous services.
    

### Docker

* **Definition**: Docker is a platform-as-a-service (PaaS) that uses OS-level virtualization to deliver software in packages called containers.
    
* **History**: Docker popularized open-source containerization. When people refer to containers, they often think of Docker.
    
* **Components**:
    
    * **Docker CLI**: Command-line interface for managing containers.
        
    * **Dockerfile**: A configuration file that describes how to build a container.
        
    * **Docker Compose**: A tool for defining and running multi-container Docker applications.
        
    * **Docker Swarm**: An orchestration tool for managing multi-container deployments.
        
    * **Docker Hub**: A public repository for container images.
        
* **OCI**: The Open Container Initiative, established by Docker, creates industry standards for container formats and runtimes. It is now maintained by the Linux Foundation.
    
* **Trends**: Docker has faced criticism for introducing a paid model for open-source software, leading to alternatives like Podman gaining popularity.
    

### Podman, Buildah, Skopeo

* **Podman**: An OCI-compliant container engine that is a drop-in replacement for Docker. Unlike Docker, Podman does not use a daemon and supports creating pods similar to Kubernetes.
    
* **Buildah**: A tool for building OCI container images.
    
* **Skopeo**: A tool for moving container images between different types of container storage.
    

### Container Services

#### Primary Services

* **Elastic Container Service (ECS)**:
    
    * **No-Cloud Starts**: Provides self-managed EC2 instances.
        
    * **AWS Fargate**: A serverless compute engine for containers.
        
    * **Scale to Zero Cost**: Can scale down to zero to save costs.
        
* **Elastic Kubernetes Service (EKS)**:
    
    * **Open Source**: Uses Kubernetes for container orchestration.
        
    * **Avoids Vendor Lock-In**: Supports standard Kubernetes features.
        
* **AWS Lambda**:
    
    * **Focus**: Only on code. Supports short-running tasks and custom container deployments.
        

#### Provisioning and Deployment

* **Elastic Beanstalk (EB)**: Platform-as-a-Service (PaaS) that simplifies the deployment and management of applications.
    
* **App Runner**: Platform-as-a-Service specifically designed for running containerized applications.
    
* **AWS Copilot CLI**: Simplifies the building, releasing, and operating of containerized applications on AWS App Runner, ECS, and Fargate.
    

#### Supporting Services

* **Elastic Container Registry (ECR)**: A managed repository for Docker images.
    
* **X-Ray**: Analyzes and debugs distributed applications and microservices.
    
* **Step Functions**: Orchestrates workflows by stitching together AWS Lambda functions and ECS tasks.
