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

Painless Microservice Development

Painless Microservice Development

How to develop microservices with a Vagrant, Ansible and Nginx

https://github.com/Vorago/painless-microservice-development

Andrew Naydyonock

May 26, 2016
Tweet

Other Decks in Programming

Transcript

  1. Possible resolutions • Buy more RAM • Don’t run selenium

    on a local machine • Infrastructure maintenance on Friday morning • Give up
  2. Nginx Service A Service B Front end Service A Service

    B Front end VM One service running from IDE Local
  3. Nginx Service A Service B Mock Front end Service A

    Service B Front end VM How about a mock? Local
  4. Nginx Service A Mock Service B Front end Service A

    Service B Front end VM Developing Service B Local
  5. Nginx Service A Mock Service B Mock Front end Service

    A Service B Front end VM Front end Local
  6. For both production and local environments ---
 - hosts: vagrant


    become: true
 become_user: root
 tasks: 
 - name: Install nginx
 apt:
 name: nginx
 state: present 
 - name: Autostart nginx
 service:
 name: nginx
 enabled: yes
 state: started
  7. Build production-like VMs for development • Easy to use •

    Light configuration • Works seamlessly with Ansible Vagrant
  8. ansible-provision.sh Vagrantfile Vagrant.configure('2') do |config|
 config.vm.box = 'ubuntu/trusty64'
 config.vm.synced_folder '.',

    '/vagrant'
 config.vm.network 'forwarded_port', guest: 80, host: 8080 config.vm.provision :shell, path: 'bootstrap.sh'
 config.vm.provision :shell, path: 'ansible-provision.sh'
 end
 cd /vagrant/ansible
 ansible-playbook setup.yml -i inventory/local
  9. • Fluent API • Lightweight WireMock Java framework for HTTP

    stubbing new WireMockServer(8888).start();
 WireMock.configureFor("localhost", 8888);
 
 stubFor(get(urlEqualTo("/hello"))
 .willReturn(aResponse()
 .withHeader("Content-Type", "text/plain")
 .withBody("Hello world!")));
  10. Databases & Vagrant Vagrant.configure('2') do |config|
 config.vm.box = 'ubuntu/xenial64'
 config.vm.synced_folder

    '.', '/vagrant'
 config.vm.provision 'shell', path: 'bootstrap.sh'
 config.vm.network 'forwarded_port', guest: 80, host: 8080
 config.vm.network 'forwarded_port', guest: 5432, host: 5432
 config.vm.provision :shell, path: 'ansible-provision.sh'
 end
 
 Don’t forget to forward your ports