Container technology, Microservices, and DevOps Digital Innovation Workshop April 2019 Henrik Bærbak Christensen
Henrik Bærbak Christensen Goal Deploy a SkyCave horizontally scaled server system using a database as storage/session cache. By writing a ‘docker stack’ file (compose file) Architecture: Docker swarm orchestration (just in your M51 vm) One dedicated network Two ‘daemon’ instances, exposed on port 4567 One database storage (memcached) Optional: docker visualizer CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Initialization But I have no swarm??? Dispair not... Just docker swarm init in your M51 And now you have a swarm of ... one node! And it should work perfectly ok... CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Hints Docker compose file version ‘3’ Remember that nodes are named on the network ! Thus a node in the compose file defined by name ‘db’ will have that name on the network – you may ‘ping db’ if on that network Remember that ‘localhost’ means just that Ie. Never use localhost in a container’s connection string! Remember that services cannot connect over port mapping You need to have named images in your compose file Bug in the daemon image? You will have to build it again! You will need to modify the CPF file ‘localhost’ is not the nodename of the storage CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Hints You need to issue another command than the default one in the docker file Because your CPF of the daemon is different Take small steps Build the compose file incrementally, test, and iterate CS@AU Henrik Bærbak Christensen
Anatomy of compose file Override CMD in dockerfile State dependency on other service CS@AU Henrik Bærbak Christensen
More microservice like... Exercise 2 More microservice like...
Henrik Bærbak Christensen Add Subscription A fully containerized subscription service is available on docker hub henrikbaerbak/subscription:1 Exposes the port ‘7654’ which is the service entry point. It has a hard coupling to its database service: mongo:3.2.5 Must be named ‘mongodb’ in the network. CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Hints You need to change the CPF for the skycave daemon to something similar to: As... Your daemon must use an implementation of the subscription interface that contacts a real serviceI Copy the above _IMPLEMENTATION verbatim! And it must contact it on the proper node on the network Use whatever name you give your container/service... CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen Additional Of course the database must be persisted between deployments. Have a look at ‘volumes’ Mongodb stores all database files in ‘/data/db’ so you have to mount a named volume in this path in the container. And you have to deploy the DB container on the same node in the swarm... CS@AU Henrik Bærbak Christensen
Henrik Bærbak Christensen More Additional Have a look at portainer.io https://www.portainer.io/overview/ Use it to get a ‘dashboard’ of your swarm… CS@AU Henrik Bærbak Christensen