At JavaLand 2015, Arun Gupta presented several ‘recipes’ for deploying Java EE applications using Docker and Kubernetes. Gupta stated that containers are beneficial for deploying and managing applications, as they provide faster deployment, isolation and portability. The use of a container cluster manager, such as Kubernetes, also allows the management of related Docker containers as a single unit, enables simplified communication across hosts, and ensures availability and scalability.
Gupta, director of developer advocacy at Red Hat Software, began the talk at JavaLand by introducing Docker, the open source project that automates the deployment of applications within LXC-based software containers. Advantages of using Docker over more traditional deployment mechanisms include faster deployments, isolation, portability, the ability to limit resource usage and the provision of a security sandbox.
Gupta continued by presenting nine Docker ‘recipes’ for packaging and deploying Java EE applications. These recipes included the use of Docker Machine to install Docker, the use of an H2 in-memory database within a single Docker container running the WildFly Java EE application server, and the deployment of two containers with a separate application server and database communicating via container linking.
Additional recipes included the use of both the Fig and Docker Compose orchestration tools for defining multi-application and multi-container environments. Gupta also demonstrated how to deploy two containers on different hosts using pre-configured IP addresses for service discovery, and how to utilise the Eclipse IDE to manage Docker-based development deployments. Gupta concluded the Docker recipes section of the talk with an overview on how to use Arquillian Cube, via the Maven build tool surefire-plugin, to control the lifecycle of Docker images as part of the test lifecycle.
Gupta continued the presentation by discussing the use of Google’s Kubernetes cluster manager for deploying and managing Java EE applications. Kubernetes is an open source orchestration system for Docker containers, and key concepts include: pods, which are collocated groups of containers that share an IP and storage volume; services, which are a single and stable name for a set of pods that also acts as a load-balancer; and replication controllers, which manage the lifecycle of pods and ensure a declared number are running at any given time.
Gupta presented several Kubernetes-based recipes, including utilising Vagrant to provision and run a local Kubernetes development cluster, the creation of WildFly application server services communicating with a MySQL service, and the use of replication controllers to ensure a specified number of application server services where running.
Gupta stated that Docker and Kubernetes are beneficial tools for deploying and managing Java EE applications. In addition to the benefits of Docker mentioned above, Kubernetes enables the management of related Docker containers as a single unit, assists with communication across hosts, and ensures availability and scalability through automated deployment and monitoring of pods and their replicas across hosts.
Potential disadvantages include no higher-level provisioning or usage tracking with Docker (although this can be achieved with additional tooling), and a potentially complex lifecycle of developing applications when using Kubernetes, including the build, deployment, management and promotion (including retrofitting existing applications to support this process).
Additional information and full details of the aforementioned recipes can be found on Gupta’s “Miles to go 2.0” blog and slideshare account. JavaLand is an annual Java conference hosted in Brühl, Germany, and details can be found on the JavaLand event website.