Mais conteúdo relacionado Semelhante a More Containers Less Operations (20) Mais de Donnie Prakoso (6) More Containers Less Operations1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Donnie Prakoso, MSc
AWS Technology Evangelist, ASEAN
More Containers, Less Operations
CTO Day - HCMC
@donnieprakoso
2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
>hello world_
Donnie Prakoso, MSc
AWS Technology Evangelist, ASEAN
@donnieprakoso
donnieprakoso
• Speak in Go and Python
• Machine Learning and Serverless
• I AWS User Groups
3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Let’s Discuss Something
• A retrospective look on why containers
for our development
• What is microservices and why we
should consider to adopt it?
• Introduction to Twelve-Factor app
• Patterns in microservices
http://bit.ly/outline-containers
4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Application environment components
Runtime Engine Code
Dependencies Configuration
5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Local Laptop Staging / QA UAT Production
Different environments
6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Local Laptop Staging / QA Production On-Prem
It worked on my machine, why not in
prod?
v6.0.0 v7.0.0 v4.0.0 v7.0.0
7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Docker to the rescue
Runtime Engine
Code
Dependencies
8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
What Are Containers?
OS virtualization
Process isolation
Images
Automation
Server
Guest OS
Bins/Libs Bins/Libs
App2App1 Portable
Flexible
Fast
Efficient
9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Docker container image
bootfs
kernel
Base image
Image
Image
W
ritable
Container
add
ngix
add
nodejs
U
buntu
References
parent
image
Read only image that is used as a
template to launch a container.
Start from base images that have
your dependencies, add your
custom code.
Docker file for easy, reproducable
builds.
10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Local Laptop Staging / QA UAT Production
Four environments, same container
11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Virtual machine versus Docker
Server (Host)
Host OS
Hypervisor
App 2
Guest OS Guest OS Guest OS
Bins/Libs Bins/Libs Bins/Libs
App 1
App 2
App 3
VM
Server (Host)
Host OS
Docker
Bins/Libs Bins/Libs Bins/Libs
App 1 App 2 App 3
Container
12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Container & Docker Benefits
• Portable application artifact that runs reliably everywhere
• Run different applications or application versions with different
dependencies simultaneously
• Better resource utilization by running multiple lightweight containers
per host
13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WHY DO WE LOVE CONTAINERS?
Packaging Distribution Immutable
infrastructure
14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BUILDING AN ECOSYSTEM
15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
PRODUCTION WORKLOADS ON AWS
AWS VPC
networking mode
Advanced task
placement
Deep integration
with AWS platform
ECS CLI…{ }
Global footprint
Powerful scheduling
engines
Auto scaling
CloudWatch metrics
Load balancers
Linux & Windows
16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
HELPING CUSTOMERS SCALE CONTAINERS
450+%
growth
Hundreds of millions
of containers started each week
millions
of container instances
17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS - Cluster
EC2 INSTANCES
LOAD
BALANCER ECS
AGENT
TASK
Container
TASK
Container
ECS
AGENT
TASK
Container
TASK
Container
AGENT COMMUNICATION
SERVICE
Amazon ECS
API
CLUSTER MANAGEMENT
ENGINE
KEY/VALUE STORE
ECS
AGENT
TASK
Container
TASK
Container
LOAD
BALANCER
19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS - Task
EC2 INSTANCES
LOAD
BALANCER ECS
AGENT
TASK
Container
TASK
Container
ECS
AGENT
TASK
Container
TASK
Container
AGENT COMMUNICATION
SERVICE
Amazon ECS
API
CLUSTER MANAGEMENT
ENGINE
KEY/VALUE STORE
ECS
AGENT
TASK
Container
TASK
Container
LOAD
BALANCER
20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ECS - Service
EC2 INSTANCES
LOAD
BALANCER ECS
AGENT
TASK
Container
TASK
Container
ECS
AGENT
TASK
Container
TASK
Container
AGENT COMMUNICATION
SERVICE
API
CLUSTER MANAGEMENT
ENGINE
KEY/VALUE STORE
ECS
AGENT
TASK
Container
TASK
Container
LOAD
BALANCER
Amazon ECS
21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Make
containers
tasks a
fundamental
compute
primitive
22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ENABLE FOCUS ON APPLICATIONS
23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
INTRODUCING AWS FARGATE!
24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
No instances
to manage
Task
native API
Resource
based pricing
Simple, easy to use,
powerful – and new
consumption model
=
CHANGING COMPUTE CONSUMPTION MODEL
25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Scheduling and Orchestration
Cluster Manager Placement Engine
RUNNING CONTAINERS AT SCALE WITH ECS
Availability Zone #1 Availability Zone #2 Availability Zone #3
26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Scheduling and Orchestration
Cluster Manager Placement Engine
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
ECS
AMI
Docker
agent
ECS
agent
EC2 Instance
27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Is Microservices?
28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
What Is Microservices?
An approach to developing a single application as a suite of
small services, each running in its own process and
communicating with lightweight mechanisms, often an HTTP
resource API
- Martin Fowler & James Lewis
https://martinfowler.com
29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Monolithic vs. Microservices
webserver
.package
Order UI
Order service
Inventory
service
Shipping
service
Order
UI
Inventory
service
Order
service
Shipping
service
30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Tenets of Microservices Architectures
Do one
thing wellIndependent
Decentralized
Black box
Polyglot
You build it, you run it
31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
Benefits of Microservices Architecture
Agility
Flexible
scaling
Easy
deployment
Technology
freedom
Reusable code
Resilience
32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or Its Affiliates. All rights reserved.
What Are Our Options?
Amazon EC2 Amazon ECS AWS Lambda
INSTANCES CONTAINERS SERVERLESS
33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Advanced Patterns in
Microservices
34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Twelve-Factor App
1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, Release Run
6. Processes
7. Port Binding
8. Concurrency
9. Disposability
10. Dev/Prod parity
11. Logs
12. Admin Processes
https://12factor.net/
35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Secrets Manager
Rotate secrets safely Secure and audit
secrets centrally
Manage access with
fine-grained policies
Easily rotate, manage, and retrieve database credentials, API keys, and
other secrets through their lifecycle
36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Continuous Deployment
37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Continuous Deployment
AWS
CodeCommit AWS
CodePipeline
AWS
CodeBuild
Amazon
ECR
Amazon
ECS
AWS
CloudFormation
1. Commit
Code
2. Trigger
Pipeline
5.Update
Stack
6. Update Service
4. Push Image
3.Build
Artifact
38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Managed Service Discovery
39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Decision Criteria
Service Registry
Discovery Mechanism
Registration Mechanism
Self-registration
Server-side Discovery
Third-party Registration
Client-side Discovery
40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Can We Make It Simpler?
Predictable
Names
for services
Auto updated
with latest,
healthy IP, port
Managed: No
overhead of
installation or
monitoring
High availability,
high scale
Extensible:
Flexible
boundaries for
auto discovery
41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Introducing Service Discovery for
Amazon ECS
42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
You build apps where
services are invoked by
name & name resolves
to IP/port dynamically
You turn on service
discovery during
deployment —
service creation
DEV OPS
43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Service Discovery Components
Service
CNAME: A / SRV record
Namespace
44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route 53 provides Service Registry
Route 53 provides APIs to create
• Namespace
• CNAME per service autoname
• A records per task IP
• SRV records per task IP + portService
CNAME: A / SRV record
Namespace
45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECS schedules & places service endpoints
ECS Scheduler updates on:
• Service scaling
• Task registrations
• Task de-registrations
• Task health
• Scheduling / Placement changes
• ECS instance changes
ECS maintains latest state of the
dynamic environment in Service
Registry
Cluster: myapp
app
IP
web
IP
app
IP
web
IP
AZ 1 AZ 2
46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ECS updates service endpoints in Route 53
Cluster: myapp
AZ 1 AZ 2
app
10.0.6.5:8080
web
10.0.8.6:8080
app
10.0.4.5:8080
web
10.0.3.6:8080
Namespace: myapp.local
Service
web.myapp.local CNAME
10.0.4.5:8080
10.0.3.6:8080
Service
app.myapp.local CNAME
10.0.6.5:8080
10.0.8.6:8080
47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Services connect to latest endpoints via DNS
Service
web.myapp.local CNAME
10.0.4.5:8080
10.0.3.6:8080
app
>dig web.myapp.local
> 10.0.4.5:8080
>
app web
web
Cluster: myapp DNS Server:
AZ 1 AZ 2
48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Enables these use cases
1
Blue green deployments
• myapp.staging.local
• myapp.prod.local
• Private IP
• abstract cluster details
2
Internal micro services
• web.myapp.local
• Expose Private IP
3
External micro services
• web.myapp.mycompany.com
• Expose public IP or ELB EIP
• network + container health
check
4
Across ECS & EKS
• Service1.myapp.ecs
• Service2.myapp.eks
5
Across ECS &
AWS & onPrem
• Service1.myapp.ecs
• Service2.myapp.ec2
• Service3.myapp.onprem
6
Expose to service mesh
• Service1.myapp.local
• Service2.myapp.local
49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Coordinate Microservices with
Visual Workflows
50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Step Functions
Easily coordinate multiple Lambda functions using visual
workflows
Visualize in the
console
Define in JSON Monitor
executions
51. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Build On!
Donnie Prakoso
@donnieprakoso