Arun Gupta, VP of Developer Advocacy at Couchbase, gave a containerization talk at JavaOne2016 that brought out aspects of both Docker and Kubernetes to instruct his audience on how containerization works. It was a crash course on the how, what, and why of containers, and a great starting point for developers looking to wrap their minds around this trend. Gupta’s detailed examples added depth in showing onlookers simple ways to use available tools for the enterprise.
According to Gupta, Docker wraps itself around many of the trends and features that are popular right now. “Everything from the Docker company itself is in the category of build, ship, and run. Distributed applications, scalability, cloud, service discovery, microservices—everything comes as a part of that.” By itself, containerization might seem like just another way of handling virtualization. But it is the ability of containers to enable and amplify the features that developers are interested in implementing that has caused it to surge in popularity. The synergistic effect of containers and microservices is a good example of how two technologies have come together to help break apart the monolith.
Sizing up the impact of containers
Gupta used his own MacBook as an example of how the use of containers can trim the fat and make a system much more lightweight. A Mac laptop can hold only about three or four VMs. A typical setup includes the infrastructure layer, host OS, hypervisor, guest OS, bins/libs, and finally the apps running on top. In contrast, a containerized setup would only have the infrastructure, the OS, a Docker engine, the bins/libs, and the apps. With so much of the VM fluff stripped away, a platform like Ubuntu 16.x can be streamlined from 960mb down to a tiny Docker image of just 123mb.
Docker and the cloud
What about using Docker for AWS or Azure in a production environment? There is already integrated tooling provided by Docker to take a development environment and seamlessly move it to either popular cloud infrastructure. Of course, it’s important not to streamline to the point of stupidity. “When you are building a distributed app, having a single host means a single point of failure and that’s a fundamental flaw. It’s the first basic rule of what to avoid in a distributed architecture.”
Proliferating the environment throughout the AWS cloud is made simple with CloudFormation Templates to ensure a robust and resilient model. To run in a multi-host environment, one might select a four node cluster of Docker and run a multi-container application with autoscale, ELB, and EBS. In short, providers on both ends are making it easy to take the containerization trend into the cloud.
Orchestrating Docker with Kubernetes
As Gupta explained, Kubernetes is an open source orchestration system for Docker containers. It provides declarative primitives for the ‘desired state’. Although Docker now has a similar feature called the Docker Swarm, Kubernetes was the original, and is still an orchestration tool that Arun uses. Its opinionated framework is designed to make a containerized system self-healing and auto-restarting and supports replication and scheduling across hosts.
The basic building blocks in Kubernetes are called Pods. A pod is a collocated group of containers that share an IP, namespace, and storage volume. Gupta admitted that this can be hard to wrap one’s head around at first because the pods are ephemeral. The point is not to have exactly the same pods running at all times, but to have the desired number running at any given time.
In a typical deployment, “You have an image, it is wrapped in a pod, the pod is wrapped in a replication controller that can scale up and down, and those are front-ended by a service. It’s all done in a very loosely coupled way. Each pod is given certain labels and the service is looking for those labels.” There’s a learning curve, but there’s a benefit to finding one’s way around Kubernetes. “It’s a lot of layers, a lot of opinions. But, once you get your head around it, the concept mostly works.” Gupta wrapped up his talk by breaking down each of the components and showing containerization used with Wildfly. Viewers can see all the details on Arun’s talk “Docker for Java Developers.”