Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Container Solutions on AWS

Container Solutions on AWS

Containers improved the deployments of both simple and complex applications by providing repeatable and isolated environments. In this presentation, we will talk about what containers really are, and the underlying technology that differentiates them from Virtual Machines and explain why they are faster and perfect for agile development and deployments. Afterwards, we will focus on container solutions of ECS (Elastic Container Service) which includes a variety of tools that suits different levels of use cases. We will talk about how to orchestrate your services on AWS ECS, manage images, lifecycle of containers, service discovery and monitoring. We will also talk about newly introduced container services of ECS, Fargate and EKS (Elastic Kubernetes Service)

OpsGenie Engineering

June 23, 2018
Tweet

More Decks by OpsGenie Engineering

Other Decks in Technology

Transcript

  1. Container Solutions on AWS Mustafa Akın Site Reliability Engineer (SRE)

    @opsgenie @mustafaakin https://www.linkedin.com/in/mustafaakin/ #OgInsights
  2. Outline - Virtualization & Container Primitives - Containers, Microservices and

    Use Cases - Amazon Container Services: - Amazon Elastic Container Registry (ECR) - Amazon Elastic Container Service (ECS) and Fargate - Amazon Elastic Container Service for Kubernetes #OgInsights @mustafaakin
  3. Virtualization “In computing, virtualization refers to the act of creating

    a virtual (rather than actual) version of something, including virtual computer hardware platforms, storage devices, and computer network resources.” -- Wikipedia #OgInsights @mustafaakin
  4. Time Slice: Scheduling Problem P1 P2 P3 P2 P1 P2

    P2 P2 P1 P3 Effectiveness Fairness Correctness #OgInsights @mustafaakin
  5. Virtualization Timeline: Timesharing 1971: Unix V1 by Bell Labs Ken

    Thompson & Dennis Ritchie with a PDP-11 #OgInsights @mustafaakin
  6. Virtualization Timeline: Timesharing 1984: HP 9000 Workstation and Server, running

    HP-UX, which is based on UNIX System V. #OgInsights @mustafaakin
  7. Virtualization Timeline: Isolation V2 2002: Linux Namespaces 2006: cgroups for

    Linux 2008: Linux Containers #OgInsights @mustafaakin
  8. Why Virtualization is required? Physical Server 48 CPU x 192

    GB Memory VM #1 4 CPU - 8 GB VM #2 12 CPU 16 GB VM #3 8 CPU 2 GB VM #4 16 CPU 48 GB VM #5 0.5 CPU - 512 MB #OgInsights @mustafaakin
  9. Why Virtualization is required? Physical Server 48 CPU x 192

    GB Memory Container #1 4 CPU - 8 GB Container #2 12 CPU 16 GB Container #3 8 CPU 2 GB Container #4 16 CPU 48 GB Container #5 0.5 CPU - 512 MB #OgInsights @mustafaakin
  10. What is a container? - A lightweight virtualization system -

    Makes use of operating system level isolation - Hardware is not virtualized #OgInsights @mustafaakin
  11. Virtual Machine - Boots in 15-50 seconds in EC2 -

    Emulation of CPU, RAM, Disks, Network - Complete isolation - Complete root access Docker - Starts in sub-seconds if image is present - Isolation of existing devices - Shared kernel - Defaults to limited privileged root user #OgInsights @mustafaakin
  12. Cattle vs Pets - cow-432-21072018.mydomain.com - Not important individually -

    Old and sick ones are shot/killed - lassie.mydomain.com - Personal relationship, love them - You cry when they die #OgInsights @mustafaakin
  13. Container Internals • Namespaces ◦ Isolate processes in the Linux

    kernel • Cgroups ◦ Account and Limit Resource / Devices usage ▪ CPU, Memory, Disk, Network #OgInsights @mustafaakin
  14. Why would you use Docker? - Scale up & down

    fast - Single process = Single responsibility - Image Version = Update & Rollback - Clean environments - Utilization - Easy Packaging #OgInsights @mustafaakin
  15. Microservices and Container Mega Application 150+ Services Deployed as a

    whole Also fails as a whole How to monitor a single part? Simple update causes complete refresh Com piles at 15 M inutes Scale up requires another copy of all Requires too many CPU & RAM Boots in 5 minutes #OgInsights @mustafaakin
  16. Why not VM per microservice then? - Slow boot time

    - Performance overhead - No isolation - Monitoring is harder - Utilization #OgInsights @mustafaakin
  17. Containers should not be treated like VMs - No SSH

    - One top level process - No snapshot & restore of containers - Root accounts should not be used - No Ansible/Puppet/Chef for configuring container, use Dockerfile - Containers should not embed credentials, should get them externally #OgInsights @mustafaakin
  18. Docker images are Layered java:8 maven my-app-v1 mybuilder java:9 uservice

    ubuntu imagemagick image-resizer micro-service install-go my-app-v2 new-container new-container new-container new-container #OgInsights @mustafaakin
  19. Amazon ECR: Elastic Container Registry - The Docker image repository

    backed by S3 - Can delete old images by lifecycle policies - Push/Pull Protected by IAM - Integration with ECS $ IMAGE_NAME=137175318439.dkr.ecr.eu-west-1.amazonaws.com/mywebapp:1.0.1 $ docker build . -t ${IMAGE_NAME} $ docker push ${IMAGE_NAME} #OgInsights @mustafaakin
  20. Docker Image Dev-Stage-Prod Parity - Prepare the image locally -

    Can run locally - Better visibility for developers #OgInsights @mustafaakin
  21. Container Use Cases Fast & Clean Environments java:8 my-app-v1 new-container

    new-container new-container #OgInsights @mustafaakin
  22. Container Use Cases Microservices app:v1 app:v1 app:v2 image-resize-service app:v2 image-resize-service

    file-server app:v1 app:v1 app:v1 app:v1 image-resize-service #OgInsights @mustafaakin
  23. Container Use at OpsGenie - Continuous Integration Tests - Packaging

    and Compiling - Staging environment - Branch deploy for developers - Deployment of some server software - Elasticsearch, Redis, Local DynamoDB, Jaeger #OgInsights @mustafaakin
  24. Kubernetes@OpsGenie Personal OpsGenie Instances with 20+ Services - app.mustafa.opgenie-test-domain.com -

    alert-service.mustafa.opgenie-test-domain.com Production, coming soon :) #OgInsights @mustafaakin
  25. Docker is not the ultimate solution. The concept to embrace

    is containerization. Docker is just a tool. #OgInsights @mustafaakin
  26. Resource Management Problems at Scale - State of cluster -

    Number of tasks - Efficient usage of remaining resources - Recovering from errors - Over-fitting & under-utilization - Multi-tenancy #OgInsights @mustafaakin
  27. Multi Node Orchestration of Docker - Since Docker arise, people

    tried to create orchestration tools - Docker tried Swarm → not a success - Swarm Mode → better, but still has shortcomings - Google already had Omega, Borg and converted them to Kubernetes which gained much traction - Amazon created ECS, Fargate, EKS - Third party solutions: Rancher, Nomad #OgInsights @mustafaakin
  28. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 #OgInsights @mustafaakin
  29. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 #OgInsights @mustafaakin
  30. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Master Master #OgInsights @mustafaakin
  31. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 #OgInsights @mustafaakin
  32. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 LOAD BALANCER #OgInsights @mustafaakin
  33. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 LOAD BALANCER SERVICE DISCOVERY #OgInsights @mustafaakin
  34. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 LOAD BALANCER SERVICE DISCOVERY STATEFUL SERVICES #OgInsights @mustafaakin
  35. Multi Node Orchestration of Docker Master Server #1 Server #2

    Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 LOAD BALANCER SERVICE DISCOVERY CONFIGURATION AND SECRETS STATEFUL SERVICES #OgInsights @mustafaakin
  36. Additional AWS Services - Lambda - CodeBuild - XRay -

    Load Balancers (ALB, ELB, NLB) - Secret Manager - Parameter Store - SQS, SNS, MQ #OgInsights @mustafaakin
  37. - Wraps Docker API - ECS agent in EC2 -

    Virtual clusters managed by AWS - Task definitions that defines 1 to many containers - ECS cluster run-task command - VPC Task networking awsvpc - Tasks can have IAM roles independent of the host - Cloudwatch Logs integration - Placement: - Availability zone, instance types, bin-packing, spreading #OgInsights @mustafaakin
  38. Master Server #1 Server #2 Server #3 Server #4 Server

    #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 EC2 + Docker EC2 + Docker EC2 + Docker EC2 + Docker Managed by AWS Managed by You PLEASE RUN MY CONTAINER #OgInsights @mustafaakin
  39. Scheduling in ECS - Task: - Run and die -

    Batch processing - Service: - Ensures a number of containers are run - Can work with Elastic Load Balancer - Daemon: - Runs in every worker node - Logging, monitoring, backups #OgInsights @mustafaakin
  40. Master Server #1 Server #2 Server #3 Server #4 Server

    #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 EC2 + Docker EC2 + Docker EC2 + Docker EC2 + Docker Managed by AWS PLEASE RUN MY CONTAINER #OgInsights @mustafaakin
  41. - Extension for ECS - Worker nodes are managed by

    AWS - Auto-scale services, set desired task count #OgInsights @mustafaakin
  42. AWS Lambda - Function as a service - Runs in

    security tightened Linux containers - Wrappers for Java, Python, Go, Nodejs PLEASE RUN MY FUNCTION WHEN SOME EVENT HAPPENS #OgInsights @mustafaakin
  43. Master Server #1 Server #2 Server #3 Server #4 Server

    #1 Server #2 Server #3 Server #4 Master Master Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 Server #1 Server #2 Server #3 Server #4 EC2 + Kubelet EC2 + Kubelet EC2 + Kubelet EC2 + Kubelet Managed by AWS PLEASE MAKE MY CONFIGURATION HAPPEN #OgInsights @mustafaakin
  44. - Based on Kubernetes - Master nodes are managed by

    AWS for a fee - Worker nodes are added by user - CNCF Kubernetes Conformant #OgInsights @mustafaakin
  45. kops - Official Kubernetes product - Custom clusters on AWS

    - Any network driver - Custom etcd and master configuration - Alpha/Beta APIs can be enabled #OgInsights @mustafaakin
  46. - Declarative API - Simple Objects - Combine objects to

    make more complex objects - Pod → Replica Set → Deployment - Service Discovery - Service, Ingress - Data - Volume, Secrets - Role Based Access - User, Role, ServiceAccount #OgInsights @mustafaakin