dockerize me: distributed php applications with symfony, docker, consul and ansible
TRANSCRIPT
![Page 1: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/1.jpg)
Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible
Oleksii PetrovSkelia Ukraine / ETwater Systems
skype: alexhelkartwitter: @alexhelkaremail: [email protected]
![Page 2: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/2.jpg)
1. What for the goat needs an accordion?
Agenda
![Page 3: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/3.jpg)
Agenda (real)1. SOA and Microservices2. Dockerized infrastructure3. Cluster Management4. Service discovery and failure detection5. Dockerizing Symfony Applications
![Page 4: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/4.jpg)
SOA and Microservices:7 days of app creation
![Page 5: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/5.jpg)
Day 0 - In beginning was Word…
![Page 7: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/7.jpg)
Day 1. Evening
![Page 9: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/9.jpg)
Day 3
www.example.com
Database
Application
Cache
Application
Cache
Web server
![Page 10: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/10.jpg)
Day 4. Morning
DB Server Crash
![Page 11: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/11.jpg)
Day 4. Night
www.example.com
DatabaseApplication
Cache
Application
Cache
Web server Database
Database
Database Cluster
![Page 12: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/12.jpg)
Day 5
www.example.com
DatabaseApplication
Cache
Application
Cache
Database
Database
Database ClusterWeb server
Cache
Web server
Cache
Web server
Cache
![Page 13: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/13.jpg)
Day 6
Cache
Application
CRUDUsers Authentication Notifications
API calls to 3-rd parties
Background processing
![Page 14: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/14.jpg)
A HA MOMENT
![Page 15: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/15.jpg)
Day 7
www.example.com
Database
Database Cluster
Database Database
Users Service
Authenticationand
AuthorizationService
Notification Service
Crawler Service
Parser Service
Image Resizer Service
Report Generation
Service
Application Cluster
Web server
Web server
Web server
Web Servers Cluster
Cache
Cache
Cache Cluster
![Page 16: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/16.jpg)
Core Idea
Process Component Microservice
![Page 17: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/17.jpg)
Benefits1. Individual scalability2. Language/Framework independent3. Small in general
(easier for a developer to understand)4. Independent development and
deploy process per service
![Page 18: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/18.jpg)
Dockerized Infrastructure
![Page 19: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/19.jpg)
Database
Database Cluster
Database Database
Users Service
Authenticationand
AuthorizationService
Notification Service
Crawler Service
Parser Service
Image Resizer Service
Report Generation
Service
Application Cluster
Cache
Cache
Cache Cluster
MQ
MQ Cluster
MQ
ES
ElasticSearch Cluster
ES ESNginx
Web Servers Cluster
Nginx Nginx
Services - are all about Containers
![Page 20: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/20.jpg)
Software Delivery (before)
![Page 21: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/21.jpg)
Software Delivery (before)
![Page 22: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/22.jpg)
The Game Changer
![Page 23: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/23.jpg)
Software Delivery (now)
![Page 24: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/24.jpg)
Software Delivery (now)
![Page 25: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/25.jpg)
Software Delivery (now)
![Page 26: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/26.jpg)
Dockerfile(DSL)
Docker Image
DockerContainer
App
App 2
App 3
1
2
3
Uniform Processing
![Page 27: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/27.jpg)
Problems?
![Page 28: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/28.jpg)
![Page 29: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/29.jpg)
Where is my services?
Service Discovery
![Page 30: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/30.jpg)
Tomcat10.0.1.17:8080
RabbitMQ10.0.1.171:5672
MongoDB10.0.1.253:27017
API10.0.1.11:80
Service Locator
10.0.1.17:8080 tomcat10.0.1.171:5672 rabbitmq10.0.1.253:27017 mongodb10.0.1.11:3306 api
![Page 31: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/31.jpg)
Looks familiar?
Own DNS?
![Page 32: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/32.jpg)
Solution
Consul by HashiCorp(consul.io)
![Page 33: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/33.jpg)
Service Discovery
Service 4
Service 2
Service 3
Service 1
Service 1
Service 2
Service 3
Service 2
![Page 34: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/34.jpg)
Service Discovery
Service 2
Service 2
Service 2
service2.service.consul
![Page 35: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/35.jpg)
Service Discovery
DNS Masq Consul
External DNS
*.service.consul
![Page 36: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/36.jpg)
Service Discovery
![Page 37: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/37.jpg)
Cluster Management
![Page 38: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/38.jpg)
Server 14 CPU & 16GB RAM
Server 28 CPU & 32GB RAM
Server 31 CPU & 8GB RAM
Server 4 2 CPU & 2GB RAM
Notification Service
API Service
Image Resizer4xCPU
Reporting Service2xRAM
Logger Service
User Service
Resources(servers)
Services(images)
Containers(running)
2x
3x
10x
4x
1x1x
![Page 39: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/39.jpg)
Cluster Management
• ECS & ECR (Amazon)• Kubernetes (Google)• Nomad (HashiCorp)• Mesos & Marathon (Apache)
![Page 40: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/40.jpg)
Ansible
![Page 41: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/41.jpg)
hosts: webservers sudo: True tasks: - name: install nginx apt: name=nginx update_cache=yes
- name: copy nginx config file copy: src=files/nginx.conf dest=/etc/nginx/sites-available/default
- name: enable configuration file: > dest=/etc/nginx/sites-enabled/default src=/etc/nginx/sites-available/default state=link
- name: copy index.html template: > src=templates/index.html.j2 dest=/usr/share/nginx/html/index.html mode=0644
- name: restart nginx service: name=nginx state=restarted
Ansible Playbooks
![Page 42: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/42.jpg)
Symfony Appswith Docker
![Page 43: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/43.jpg)
Symfony Apps with Docker
Application Code
Webserver
Database
Cache
PHP-FPM Supervisord• PHP-FPM• Webserver• Database• Cache
![Page 44: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/44.jpg)
Pitfalls with Docker
![Page 45: Dockerize Me: Distributed PHP applications with Symfony, Docker, Consul and Ansible](https://reader034.vdocument.in/reader034/viewer/2022042507/58a6b2ab1a28ab661f8b477d/html5/thumbnails/45.jpg)
Questions?Oleksii PetrovSkelia Ukraine / ETwater Systems
skype: alexhelkartwitter: @alexhelkaremail: [email protected]
Welcome to Kiev PHP User Group