DevOps

Summarized using AI

Zero Downtime Deployments with Docker

Vamsee Kanakala • January 03, 2014 • Earth

In the video titled "Zero Downtime Deployments with Docker," Vamsee Kanakala discusses the importance of understanding DevOps practices for developers, particularly focusing on zero downtime deployments using Docker. The presentation takes attendees through the concepts of Linux containers and how Docker commoditizes them to enable efficient software deployment. Key points include:

  • Introduction to Docker: Docker allows developers to deploy applications in isolated environments called containers, providing flexibility and efficiency without the overhead of hardware virtualization.
  • Understanding Containers: Containers serve as a lightweight way to package applications and their dependencies, ensuring consistency across different environments.
  • Image Management: Docker images can be created from a base image, modified, and then pushed to public or private repositories. This process enhances the reuse of software components.
  • Dockerfile: The use of a Dockerfile simplifies the image creation process, where directives (FROM, RUN, CMD) define how an image is built and configured.
  • Zero Downtime Deployments: Discussing the necessity for seamless deployments, Vamsee highlights strategies to manage software updates with minimal service interruptions, utilizing tools like HAProxy for load balancing and database synchronization tools like Zookeeper.
  • Deployment Workflow: The deployment process is facilitated using Docker, where running new services concurrently with old services helps ensure availability during transitions.
  • Resources and Tools: Vamsee provides useful links for further learning, including documentation and recommended reading, notably a book by James Turnbull.

In conclusion, Vamsee emphasizes the efficiency and simplicity Docker provides in handling deployments, urging developers to adopt such practices for enhanced productivity and reduced downtime. His message is clear: embracing modern deployment strategies is crucial for developers in today’s agile workflow environment.

Zero Downtime Deployments with Docker
Vamsee Kanakala • January 03, 2014 • Earth

By Vamsee Kanakala

Increasingly developers are being pushed to understand the operations world of web application deployments as continuous delivery gains importance in the "new normal" world of agile developer workflows. Configuration management tools like Puppet and Chef are gaining popularity for precisely the same reason, as they allow developers to deal with "infrastructure as code". However, there is also a growing understanding that servers are better off being treated as immutable, to avoid the various complications that arise from constantly evolving/changing configurations. Docker is a tool that allows us to deploy various parts of a server into separate containers and let us save a container state so this can either be published or improved upon. This talk will allow us to understand all these concepts in order to achieve immutable servers and zero-downtime deployments.

Help us caption & translate this video!

http://amara.org/v/FG4X/

Garden City Ruby 2014

00:00:26.489 Hello everyone, a very good afternoon! I really enjoyed the lightning talks. Thanks, everyone! I hope you guys are slightly awake.
00:00:32.199 This talk is slightly off the central topic; it's more about DevOps rather than Ruby on Rails per se.
00:00:39.489 I'd like to know who here is already familiar with Docker, who has tried it out, or who at least knows what it does.
00:00:50.710 Okay, not too many. Sorry about that! I've been a web developer for quite some time, and a good part of that has been with Ruby on Rails.
00:01:06.159 I actually remember the days when the 15-minute video came out.
00:01:12.220 Over the years, I've also been involved in setting up servers for the Ruby teams that I’ve worked with, and I’ve been a Linux guy for as long as I can remember.
00:01:24.100 Lately, I’ve been observing what’s happening on the production side of things.
00:01:33.490 So, how many of you have set up your own Linux servers and maintained them?
00:01:39.670 Oh, quite a few! Okay, then this should be relevant to what you're doing.
00:01:50.320 We're going to talk about zero downtime deployments with Docker.
00:02:04.600 So, what is Docker? The first thing that Docker does is it commoditizes Linux containers.
00:02:18.580 You can think of containers as something like a chroot jail that you have in Linux.
00:02:30.430 It basically gives you a separate folder as a root directory from where you can run your processes.
00:02:38.260 All the child processes are only allowed to access that part of the directory as a root directory.
00:02:52.030 A container extends this concept by providing network-level isolation and disk-level isolation.
00:03:09.099 Linux containers are a fairly old technology, but they have been primarily understood by those who are deeply familiar with Linux and production.
00:03:33.490 Docker makes this technology accessible to all of us, allowing for portable deployments across different machines.
00:03:44.379 You have a Vagrant box that runs a specific version, but you can also run production systems from another version.
00:03:50.099 You get a lot of flexibility for moving your production images around.
00:04:02.169 This also enables efficient and quick provisioning while saving disk space through copy-on-write installations.
00:04:16.479 Docker achieves near-native performance; it's essentially process virtualization, so you don’t have the overhead of hardware virtualization.
00:04:30.610 You have a base image, say Ubuntu, and you can install applications like Emacs and make it into another image.
00:04:47.499 This process allows for a lot of reusability. You can push these images to a public repository that Docker maintains at index.docker.io.
00:05:01.720 If they're public and open for sharing, others can use your custom image as needed.
00:05:15.010 The major difference between how Linux containers work and how Docker encourages the use of containers is as an application.
00:05:28.700 Instead of treating a container like a lightweight server where you install everything, Docker promotes the idea of having a specific application in each container.
00:05:42.030 For instance, you could have your database MySQL in one container, your app server in another, and so on.
00:05:51.200 At the most basic level, Docker provides OS-level virtualization for Linux.
00:06:01.300 This is much faster and lighter compared to hardware virtualization methods.
00:06:13.750 Docker sets up its own process space, network interface, and init system within the container.
00:06:22.270 Isolation is achieved through control groups (cgroups). Cgroups allow you to put limits on resource usage like network, disk, and processing power.
00:06:38.270 The catch is that it shares the kernel with the host, so you cannot run incompatible images.
00:06:52.170 A typical Docker image consists of a kernel, cgroups, namespaces, and device mappers. Docker achieves image versioning through a union file system.
00:07:09.990 Debian-based installations utilize AUFS, which has limitations in its integration with the Debian kernel.
00:07:22.690 However, alternatives like device mapper have been integrated to overcome these challenges.
00:07:31.540 The base image is shipped from Docker registry, and any additions you make will lead to new read-only images.
00:07:46.940 The basic workflow involves pulling Docker images from the public registry, running them, adding your changes, and then pushing them back.
00:08:04.200 Docker also provides a Dockerfile which allows you to build your own images. You can also set up private repositories for workgroups.
00:08:26.050 A private registry is useful when you want to share images within your company and not publicly.
00:08:39.140 I'll now show you a simple deployment workflow using a Dockerfile to explain the process further.
00:08:54.360 At the most basic level, when you pull from Docker, it checks for layers available on your system and adjusts accordingly.
00:09:06.300 This eliminates redundant downloads, which saves time and resources.
00:09:19.470 Kicking off a container is simple: you have to specify an entry point and it will drop you into a root prompt where you can start installing applications.
00:09:35.720 The basic idea is to have a very minimalistic Docker image, where you can add your software on top and then commit it.
00:09:51.960 So, let's say I install the nano editor; this process should be pretty quick.
00:10:07.720 If I switch to another window, I can check the running containers.
00:10:14.450 You can see each container has its own name and status. You can rename them, which is a relatively new feature.
00:10:26.800 Each container also provides insights into what's happening inside it.
00:10:41.480 You can commit changes made inside a container to create a new image.
00:10:53.290 So after making my edits, let’s say I want to commit the changes and give it a name.
00:11:13.090 Now, you can see the newly created images, and you can push them to the public registry to share them.
00:11:29.160 The public repository is a central place where you can search for images necessary for your deployments.
00:11:43.060 You can also install Docker on your private servers to ensure that your images are secure.
00:11:54.930 Next, I’ll discuss the Dockerfile, which is similar to a Rakefile or Makefile you may use in your projects.
00:12:19.890 The Dockerfile is essentially a glorified shell script that provides a straightforward way to build images.
00:12:39.940 You can use directives like FROM, RUN, and CMD to define the behavior of your Docker images.
00:12:53.380 The FROM directive specifies the base image, and RUN allows you to execute commands like installing packages.
00:13:07.210 The CMD specifies what command to run, and ENTRYPOINT sets the executable that runs inside the container.
00:13:20.010 In summary, you can mount directories as volumes and configure your containers with a variety of commands.
00:13:39.740 Docker is designed to be simple and straightforward, making it easy to start using and learn without a lot of overhead.
00:13:55.490 Now, let’s shift our focus to zero downtime deployments. Why do we need them?
00:14:12.580 The most important aspect involves continuous delivery and continuous deployments. While similar, they differ subtly.
00:14:25.990 Continuous delivery involves regularly delivering software updates, maintaining tight communication with clients.
00:14:40.120 On the other hand, continuous deployment takes this one step further, aiming to make deployments as seamless as possible with minimal disruptions.
00:15:02.810 As developers, we are all familiar with long deployments, particularly during schema migrations.
00:15:17.850 During heavy migrations or other processes, it’s common to put up maintenance pages to avoid errors.
00:15:31.490 However, these problems extend beyond Rails and can also occur in Django or other frameworks.
00:15:47.290 To address this, Docker is a framework-agnostic solution that allows different applications to coexist.
00:16:07.300 When considering zero downtime deployments, one of the tasks to tackle is database synchronization.
00:16:22.250 In scenarios with databases, it's essential to ensure that master and slave databases are in sync.
00:16:35.790 Tools like Zookeeper help manage the master/slave relationships.
00:16:49.920 A simpler case can be illustrated by using HAProxy.
00:17:08.220 HAProxy is essentially a robust load balancer, acting like a reverse proxy.
00:17:20.770 You can set up multiple active and backup servers, where the backup servers remain idle until all the active servers are down.
00:17:34.400 During deployment, you can build the new Docker image while still serving from the active servers, maintaining availability.
00:17:49.240 Once the new services are up and running, you take down the old active servers and switch to the new backup servers.
00:18:07.550 This ensures that at least during the switch, requests are routed correctly with minimal interruptions.
00:18:26.490 While this setup won’t allow for migrations seamlessly, it greatly reduces compile times and downtime.
00:18:43.970 Let’s quickly recap the workflow; open up your HAProxy and observe how it balances requests among the different servers.
00:19:01.920 Also, review your deployment scripts and ensure you have configured the versions correctly.
00:19:15.980 Later, I will show a simple Dockerfile representing the setup process.
00:19:28.660 You can start from an Ubuntu image and perform package installations as needed.
00:19:39.410 Let’s proceed with the deployment and I will explain the steps involved.
00:19:55.820 This deployment process runs in the background while I explain further.
00:20:08.780 What I'm effectively doing is automating tasks that would otherwise be manual.
00:20:22.700 In this Dockerfile, I'm installing some basic dependencies and setting configurations.
00:20:36.610 Using Docker simplifies the deployment process while also allowing easier maintenance.”},{
00:20:48.890 By exposing ports, containers can communicate easily with each other and the host system.
00:21:01.000 Next, I will show you the HAProxy configuration for managing the traffic.
00:21:14.000 The setup allows for different active and backup configurations within the deployment strategy.
00:21:27.000 You configure HAProxy to balance requests accordingly, ensuring availability.
00:21:39.000 I’ll revisit the deployment summary soon, and we will review how to ensure smooth transitions.
00:21:53.000 At the conclusion, I'll provide important links where you can find more resources on Docker.
00:22:06.000 These resources include documentation, tutorials, and further reading to enhance your understanding.
00:22:20.000 One key resource is the Docker book by James Turnbull; it is an excellent read for beginners and experienced users alike.
00:22:34.000 Lastly, there are several tools available that build on Docker's systems, which can help streamline development and deployment.
00:22:48.000 If you have any questions, feel free to reach out to me after the session.
00:23:02.000 Thank you very much for your attention!
Explore all talks recorded at Garden City Ruby 2014
+20