On Github diogok / how-i-devops
How to organize systems, in a simple maner to create and keep?
Martin Fowler puts it best:
A component is a unit of software that is independently replaceable and upgradeable. Their Primary way of componentizing (...) software is by breaking it down into services. Services are independently deployable. Services are out-of-process components who communicate with a mechanism such as a web service request.How to make this services communicate with each other and the world?
a.k.a: WEB
From Roy Fielding:
How to work with the team?
Which language to use?
Remember: Polyglot programming and use the best tool for each job.
ok, nodejs is the new-new, but really...
Where to persist data?
You know, for search!
The great SQL DB.
Default simple SQL DB
How to make sure it all works?
We all know this.
We all knwo this.
Most of us knows: behavior tests.
Feature: Open and edit profiles Scenario: create profile Given I am on "/specie/Aphelandra longiflora" Then I login as "Diogo", "diogo@cncflora.net", "admin,analyst" And I press "create-btn" Scenario: Edit a profile, changes apply and metadata Given I am on "/specie/Aphelandra longiflora" When I login as "Bruno", "bruno@cncflora.net", "analyst", "ACANTHACEAE" And I follow "Editar" Then I should see "Contribuidor(es): [Bruno] ; Diogo" Then I should see "Taxonomic Notes" Then I fill field "textarea[id*='-taxonomicNotes-notes']" with "Hello, notes." And I press "Salvar" Then I should see "Status: open" Then I should see "Notas Taxonômicas" Then I should see "Hello, notes."
My dev-env will become a mess!
or: it works on my machine
or: someone has to configure the new guy pc
Development environments made easy.
Standart and automation of dev env.
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/trusty32" config.vm.network "private_network", ip: "192.168.50.188" config.vm.provision :shell, :inline => "apt-get update && apt-get install openjdk-7-jdk curl git tmux vim htop redis-server -y" config.vm.provision :shell, :inline => "wget https://raw.github.com/technomancy/leiningen/stable/bin/lein -O /usr/bin/lein" config.vm.provision :shell, :inline => "chmod +x /usr/bin/lein" end
That is just ruby...
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/trusty64" config.vm.network "private_network", ip: "192.168.50.10" config.vm.network :forwarded_port, host: 8888, guest: 80, auto_correct: true config.vm.provider "virtualbox" do |v| v.memory = 2048 v.cpus = 2 end config.vm.provision "docker" do |d| d.run "coreos/etcd", name: "etcd", args: "-p 8001:80 -p 4001:4001" end config.vm.provision "chef_solo" do |chef| chef.add_recipe "apache" chef.add_recipe "couchdb" end end
But really, docker-compose is better for this.
My production will be a mess!
This actually is the dev env now
Build, ship and run!
You will automate, but:
# At your machine docker build -t cncflora/profiles . # Build this project image docker push cncflora/profiles # Send it to repository # On the server docker pull cncflora/profiles # pull lastest image, incrementally docker run -d -p 8080 -t cncflora/profiles # Runs it
Any server, same thing:
FROM dockerfile/java RUN wget http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.2.0.M0/jetty-runner-9.2.0.M0.jar -O /root/jetty.jar ADD target/dwc-services-0.0.4-standalone.war /root/dwc-services.war EXPOSE 8080 CMD ["java -jar","/root/jetty.jar","/root/dwc-services.war"]
FROM ubuntu:14.04 RUN apt-get update && \ apt-get upgrade -y && \ apt-get install apache2 libapache2-mod-php5 php5 php5-cli php5-curl php5-common php5-sqlite php5-mysql php5-pgsql php5-gd -y RUN apt-get install supervisor -y RUN mkdir /var/log/supervisord RUN a2enmod rewrite RUN sed -i -e 's/memory_limit.*/memory_limit=512M/g' /etc/php5/apache2/php.ini && \ sed -i -e 's/upload_max_filesize.*/upload_max_filesize=128M/g' /etc/php5/apache2/php.ini && \ sed -i -e 's/post_max_size.*/post_max_size=128M/g' /etc/php5/apache2/php.ini && \ sed -i -e 's/display_errors.*/display_erros=On/g' /etc/php5/apache2/php.ini ENV APACHE_RUN_USER www-data ENV APACHE_RUN_GROUP www-data ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 ENV APACHE_PID_FILE /var/apache2.pid ENV PHP_ENV production ADD default.conf /etc/apache2/sites-available/000-default.conf ADD supervisord.conf /etc/supervisor/conf.d/apache.conf ADD vendor /var/www/vendor RUN chown www-data.www-data /var/www/vendor -Rf ADD . /var/www RUN chown www-data.www-data /var/www -Rf EXPOSE 80 EXPOSE 9001 CMD ["supervisord"]
All that puts more pressure on Ops.
Beyond docker.
etcd: image: coreos/etcd name: etcd ports: - "4001:4001" logstash: image: diogok/logstash name: logstash ports: - 80 - 9514 proxy: image: diogok/proxy-docker name: proxy environment: ROOT_APP: "connect" ports: - "80:80" - "9001" links: - "etcd:etcd" connect: image: cncflora/connect name: connect ports: - "8080" - "9001" volumes: - "/var/floraconnect:/var/floraconnect:rw" environment: PROXY: "/connect" dwc_services: image: cncflora/dwc-services name: dwc_services ports: - "8080" - "9001" environment: PROXY: "/dwc_services" floradata: image: cncflora/floradata name: floradata ports: - "80"
Orchestrate your container.
Share configuration REST server.
Proxy to the container network
http { server { listen 80; # Proxying the connections connections, data come from ETCD <% for @app in @data.values %> location /<%= @app['name'] %>/ { rewrite /<%= @app['name'] %>/(.*) /$1 break; proxy_pass http://<%= @app['networksettings']['ipaddress'] %>:<%= @app['networksettings']['ports'].keys.first.gsub("/tcp","") %>; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } <% end %> } }
SUpervvisor the processes
Get those logs in a nice view
TODO