Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Docker, Ansible and Symfony micro-kernel

268 views

Published on

From Dmytro Danylevskyi for DrupalCamp Kyiv 2017

Published in: Internet
  • Be the first to comment

Docker, Ansible and Symfony micro-kernel

  1. 1. WITH DOCKER, ANSIBLE AND SYMFONY MICRO-KERNEL BUILDING SOLID MICRO-SERVICE ARCHITECTURE
  2. 2. 9 YEARS WITH DRUPAL DMYTRO DANYLEVSKYI Distributed Team 80% Local Community 20%
  3. 3. PHP DEVELOPER ADDICTED TO DEVOPS DMYTRO DANYLEVSKYI Back-End 80% DevOps 20%
  4. 4. LET’S DECOUPLE IT POTENTIAL MICRO-SERVICES FOR DRUPAL SITE ▸ Third party data synchronization tasks ▸ Data analysis and reports building ▸ Data scraping ▸ Heavy calculations performing ▸ Drush command
  5. 5. THAT PAIN… REMEMBER IT? ▸ Performing hook_updates (shared database) ▸ Mismatching of environment requirements ▸ Management of bloated composer.json file ▸ Your story?
  6. 6. MONOLITHIC Image by kanbansolutions.com
  7. 7. MODULAR Image by kanbansolutions.com
  8. 8. MICRO-SERVICES Image by kanbansolutions.com
  9. 9. SOLUTION OVERVIEW
  10. 10. SOLUTION WHAT ARE YOU TALKING ABOUT? APP APPAPP APP APPAPP APP APPAPP
  11. 11. SOLUTION IS IT VERTICALLY SCALABLE? APP APPAPP APP APPAPP APP APPAPP APP APPAPP APP APPAPP APP APPAPP APP APPAPP
  12. 12. SOLUTION IS IT HORIZONTALLY SCALABLE? APP APPAPP APP APPAPP APP APPAPP APP
  13. 13. SOLUTION EXAMPLE APPLICATION DB / FILES SYMFONY MICRO KERNEL Docker container Volume
  14. 14. INFRASTRUCTURE ARCHITECTURE ANSIBLE ROLE “PROVISION” LINUX + DOCKER DATA VOLUMES BACKUP ANSIBLE ROLE “DEPLOYMENT” APP APP APP
  15. 15. LET’S BUILD IT!
  16. 16. DEVELOPMENT FILE STRUCTURE FOR PARTICULAR SERVICE . !"" Makefile !"" ansible #   %"" deployment #   %"" playbook.yml !"" docker #   !"" conf #   %"" dockerfiles #   %"" php #   !"" dockerfile__dev #   %"" dockerfile__prod !"" docker-compose.dev.yml !"" docker-compose.prod.yml !"" docker-compose.yml !"" hosts !"" requirements.yml %"" volumes
  17. 17. DEVELOPMENT MAKEFILE IS UNIVERSAL INTERFACE include .env
 
 APP_ENV ?= dev
 DC = docker-compose -f dc.yml -f dc.$(APP_ENV).yml
 ANSIBLE = ansible-playbook -i hosts
 
 build:
 $(DOCKER_COMPOSE) build
 
 up:
 $(DOCKER_COMPOSE) up -d deploy:
 $(ANSIBLE) ansible/deployment/playbook.yml
  18. 18. DEVELOPMENT EACH SERVICE SHOULD BUILD IT’S OWN DOCKER IMAGE version: '2'
 
 services:
 php:
 build:
 args:
 dockerfile: docker/dockerfiles/php/Dockerfile__dev
 environment:
 - PHP_IDE_CONFIG=serverName=app
 - SYMFONY_DEBUG=1
  19. 19. DEVELOPMENT MICROKERNELTRAIT $ composer require symfony/symfony
  20. 20. DEVELOPMENT APP FILE STRUCTURE . !"" app #   !"" MicroKernel.php #   !"" autoload.php #   %"" config #   !"" common #   #   !"" config.yml #   #   %"" services.yml #   !"" dev #   #   !"" config.yml #   #   %"" parameters.yml #   %"" prod #   !"" config.yml #   %"" parameters.yml !"" bin #   %"" console !"" composer.json !"" composer.lock %"" src
  21. 21. DEBUGGING CONFIGURE YOUR HOST MACHINE # Mac OS sudo ifconfig lo0 alias 10.254.254.254 # Linux sudo ifconfig lo:1 10.254.254.254 up # PhpStorm: # 1. Create PHP server # 2. Give it unique name. Example “my_app” # 3. Configure path mappings.
  22. 22. DEBUGGING CONFIGURE PHP IMAGE # Configure XDebug xdebug.remote_host=10.254.254.254
 xdebug.remote_enable=on
 xdebug.remote_autostart=on version: '2'
 
 services:
 php:
 build:
 dockerfile: docker/dockerfiles/php/Dockerfile__dev
 environment:
 - PHP_IDE_CONFIG=serverName=my_app
 - SYMFONY_DEBUG=1
  23. 23. DEPLOYMENT ANSISTRANO DIRECTORY STRUCTURE /var/www/apps/example !"" current -> /var/www/apps/example/releases/20100512131539 !"" releases | !"" 20100512131539 | !"" 20100509150741 | !"" 20100509145325 !"" shared 23
  24. 24. DEPLOYMENT GOODBYE CAPISTRANO! HELLO ANSISTRANO! 1. SETUP 2. CODE CHECKOUT 3. SHARED DATA SYMLINK 4. RELEASE SYMLINK 5. CLEANUP BEFORE HOOK AFTER HOOK BEFORE HOOK BEFORE HOOK BEFORE HOOK BEFORE HOOK AFTER HOOK AFTER HOOK AFTER HOOK AFTER HOOK
  25. 25. DEPLOYMENT THE PROCESS 1. Make backup of DB 2. Container shutdown 3. Code checkout 4. Build docker image 5. Start container
  26. 26. SERVER PROVISIONING ANSIBLE PLAYBOOK ✓ Install Docker ✓ Configure Backup (backupninja + duplicity) ✓ Configure stale data cleaning (docker images)
  27. 27. INFRASTRUCTURE ARCHITECTURE ANSIBLE ROLE “PROVISION” LINUX + DOCKER DATA VOLUMES BACKUP ANSIBLE ROLE “DEPLOYMENT” APP APP APP
  28. 28. JEFF GEERLING ANSIBLE FOR DEVOPS Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server — or thousands. https://leanpub.com/ansible- for-devops
  29. 29. THANK YOU FOR THE LISTENING DMYTRO DANYLEVSKYI dmytro@danylevskyi.com

×