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

Lessons learnt trying to deploy Docker in produ...

Jose Armesto
November 18, 2016

Lessons learnt trying to deploy Docker in production

Jose Armesto

November 18, 2016
Tweet

More Decks by Jose Armesto

Other Decks in Technology

Transcript

  1. You take the red pill, you stay in Wonderland, and

    I show you how deep the rabbit hole goes.
  2. ❏ Disk images .iso ❏ VMware .vdmk ❏ Vagrant .box

    ❏ Amazon Machine Images AMI Systems Packaging
  3. The difference between how you think something works and how

    it actually works risks hard-to-debug production issues. Gareth Rushgrove @garethr
  4. ❏ Which OS is it based on? ❏ Which packages

    are installed? ❏ What application is running inside? Giving a running container
  5. ❏ Which OS is it based on? ❏ Which packages

    are installed? ❏ What application is running inside? Giving a running container
  6. Operating System Tags can be overwritten! 3.4 won’t be the

    same in two weeks, probably FROM  alpine:3.4 CMD  [“echo”,  “Knock”,  ”Knock”,  “Neo”]
  7. Operating System Always the same version… but please kill me

    now FROM  alpine@sha256:e4c425e28a3cfe41efdfceda7ccce6… CMD  [“echo”,  “Knock”,  ”Knock”,  “Neo”]
  8. ❏ Which OS is it based on? ❏ Which packages

    are installed? ❏ What application is running inside? Giving a running container
  9. Packages Which pip? FROM  alpine:3.4 RUN  apk  add  -­‐-­‐update  py-­‐pip

    CMD  [“echo”,  “Knock”,  ”Knock”,  “Neo”]
  10. Versions Specify the version… and let’s hope developers respect versioning

    FROM  alpine:3.4 RUN  apk  add  -­‐-­‐update  py-­‐pip=8.1.2-­‐r0 CMD  [“echo”,  “Knock”,  ”Knock”,  “Neo”]
  11. ❏ Which OS is it based on? ❏ Which packages

    are installed? ❏ What application is running inside? Giving a running container
  12. Application Which version of our application? FROM  alpine:3.4 RUN  apk

     add  -­‐-­‐update  py-­‐pip=8.1.2-­‐r0 COPY  app.py  /app.py CMD  [“python”,  “/app.py”]
  13. Metadata Use Docker Labels for application metadata FROM  alpine:3.4 ARG

     vcs_ref="Unknown" ARG  build_date="Unknown" RUN  apk  add  -­‐-­‐update  py-­‐pip=8.1.2-­‐r0 LABEL  org.label-­‐schema.vcs-­‐ref=$vcs_ref  \ org.label-­‐schema.build-­‐date=$build_date COPY  app.py  /app.py CMD  [“python”,  “/app.py”]
  14. Metadata Use Docker Labels for application metadata FROM  alpine:3.4 ARG

     vcs_ref="Unknown" ARG  build_date="Unknown" RUN  apk add  -­‐-­‐update  py-­‐pip=8.1.2-­‐r0 LABEL  org.label-­‐schema.vcs-­‐ref=$vcs_ref \ org.label-­‐schema.build-­‐date=$build_date COPY  app.py /app.py CMD  [“python”,  “/app.py”]
  15. Metadata Use Docker Labels for application metadata FROM  alpine:3.4 ARG

     vcs_ref="Unknown" ARG  build_date="Unknown" RUN  apk  add  -­‐-­‐update  py-­‐pip=8.1.2-­‐r0 LABEL  org.label-­‐schema.vcs-­‐ref=$vcs_ref  \ org.label-­‐schema.build-­‐date=$build_date COPY  app.py  /app.py CMD  [“python”,  “/app.py”]
  16. Metadata Calculate the values for the labels $  docker  build

     \ -­‐-­‐build-­‐arg  vcs_ref=`git  rev-­‐parse  HEAD`  \ -­‐-­‐build-­‐arg  date=`date  -­‐u  +  "%Y-­‐%m-­‐%dT%H:%MZ"`  \ -­‐t  your_image_name  .
  17. Jenkins Workflow 1. Detect merge to repository 2. If tests

    pass, build image and push it to pre production registry
  18. Jenkins Workflow 1. Detect merge to repository 2. If tests

    pass, build image and push it to pre production registry 3. Deploy to pre environment
  19. Jenkins Workflow 1. Detect merge to repository 2. If tests

    pass, build image and push it to pre production registry 3. Deploy to pre environment 4. If tests pass, push image to pro registry
  20. Jenkins Workflow 1. Detect merge to repository 2. If tests

    pass, build image and push it to pre production registry 3. Deploy to pre environment 4. If tests pass, push image to pro registry 5. Deploy to production
  21. Keep In Mind ❏ Be clear on which versions of

    docker/docker-compose you allow ❏ Use Jenkins build number or timestamp as image tag ❏ Seek a Generic Build process ❏ Clean old images/containers
  22. ❏ Harder to test before production ❏ Harder to build/deploy

    different languages ❏ More and more servers needed Microservices architecture
  23. ❏ Harder to test before production ❏ Harder to build/deploy

    different languages ❏ More and more servers needed Microservices architecture
  24. ❏ Start adding Dockerfile to your projects ❏ Easier testing

    using project’s images ❏ Deploying and building projects gets simpler ❏ Get used to Docker (logs/signals/…) Forget about orchestration for now
  25. ❏ Builds and pushes docker image to registry ❏ Auto

    Scaling Group with CoreOS instances ❏ ELB in front of instances accessible through DNS ❏ Hooks to execute your own Ansible tasks ❏ Cloud Formation contains all the resources Deployment using Wimpy
  26. ❏ Services used by other internal services ❏ Services exposed

    to the internet Two types of services / deploys
  27. ❏ Services used by other internal services ❏ Services exposed

    to the internet Two types of services / deploys
  28. ❏ Services used by other internal services ❏ Services exposed

    to the internet Two types of services / deploys