Docker and Kubernetes for Java Developers Scale, deploy, and monitor multi-container applications Jaroslaw Krochmalski BIRMINGHAM - MUMBAI Docker and Kubernetes for Java Developers Copyright © 2017 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author(s), nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: August 2017 Production reference: 1240817 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78646-839-0 www.packtpub.com Credits Author Copy Editor Jaroslaw Krochmalski Safis Editing Reviewer Project Coordinator Pierre Mavro Kinjal Bari Commissioning Editor Proofreader Vijin Boricha Safis Editing Acquisition Editor Indexer Prachi Bisht Mariammal Chettiyar Content Development Editor Graphics Trusha Shriyan Kirk D'Penha Technical Editor Production Coordinator Varsha Shivhare Shantanu Zagade About the Author Jaroslaw Krochmalski is a passionate software designer and developer who specializes in the financial domain He has over 12 years of experience in software development He is a clean-code and software craftsmanship enthusiast He is a certified scrum master and a fan of Agile His professional interests include new technologies in web application development, design patterns, enterprise architectures, and integration patterns He has been designing and developing software professionally since 2000 and has been using Java as his primary programming language since 2002 In the past, he has worked for companies such as Kredyt Bank (KBC) and Bank BPS on many large-scale projects, such as international money orders, express payments, and collection systems He currently works as a consultant at Danish company 7N as an infrastructure architect for the Nykredit bank You can reach him via Twitter at @jkroch or by email at jarek@finsys.pl About the Reviewer Pierre Mavro lives in a suburb of Paris He's an open source software lover and has been working with Linux for more than 10 years now Currently, he is working as a lead SRE at Criteo, where he manages distributed systems and NoSQL technologies During the last few years, he has been designing high-availability infrastructures, public and private cloud infrastructures, and worked for a high-frequency trading company He also wrote a book on MariaDB named MariaDB High Performance He’s also one of the cofounders of Nousmotards, an application for riders Docker The first one on our list will be the awesome Docker list Awesome Docker Awesome Docker available on GitHub at http://veggiemonk.github.io/awesome-docker/ The author updates the list often, so you can clone the Git repository locally and periodical updates to see what's new Awesome Docker contains sections such as an introduction to Docker, tools (with the groups such as developer tools, testing, or utilities) The Videos section can be especially useful when learning Docker, you can find tutorials and trainings here Apart from this list, it's really hard to find some more that could be useful Blogs The first blog I would recommend to continue learning about Docker will be Arun Gupta's blog, available at http://blog.arungupta.me Arun, who first started blogging about Docker in July 2014, is the VP of developer advocacy at Couchbase, a Java champion, a JUG leader, and a Docker captain He writes about many things on his blog; you can filter the content to only related to Docker using the #docker tag, using the link: http://blog.arungupta.me/tag/docker/ You will find a lot of useful stuff here, related to Java development and Docker He also authored a great Docker tutorial, available on GitHub: https://g ithub.com/arun-gupta/docker-tutorial Next comes the official Docker blog, available at https://blog.docker.com You will not find many tutorials on how to use Docker, but there will be announcements about new releases and their features, more advanced Docker usage tips, and community news such as Docker events The Red Hat developer program, under the category containers, available at ht tps://developers.redhat.com/blog/category/containers/ also contains a lot of useful articles around Docker and container technology in general Interactive tutorials There are many Docker tutorials available on the web, but I find one of them especially interesting It's Katakoda's interactive Docker learning course, available at https://www.katacoda.com/courses/docker You will find the complete feature set of Docker here, starting with deployment of a single container and going through subjects such as adding labels, inspecting containers, and optimizing your image builds It's interactive; all you need is a modern browser, you not even need to install Docker on your local machine It's very complete and fun to learn with The other one is http://training.play-with-docker com It comes with three sections: beginner, which covers the basics such as running single containers, intermediate, covering networking for example, and advanced, covering Docker security Some of the course tasks are interactive, you can execute them straight in your browser Kubernetes When Docker started to gain more popularity the need for containers management platform started to gain attention Thus, more resources regarding Kubernetes started to pop up on the internet Awesome Kubernetes Similar to its Docker counterpart, the awesome Kubernetes list, available at GitHub https://github.com/ramitsurana/awesome-kubernetes contains a lot of useful resources regarding Kubernetes You will find a lot here; staring from the introduction to Kubernetes, through the list of useful tools and developer platforms, up to the enterprise Kubernetes products There's even a link to the tutorial on how to install Kubernetes cluster using Raspberry Pi devices! Tutorials The official Kubernetes site contains a lot of interesting tutorials, starting from the basics and going through the whole Kubernetes feature lists The list of tutorials is available at https://kubernetes.io/docs/tutorials/ If you haven't followed our Minikube install guide, I highly recommend doing so, using Kubernetes official Bootcamp, it's an interactive web based tutorial and its goal is to deploy a local development Kubernetes cluster using Minikube It's available at https://kubernetes.io/docs/tutorials/kubernetes-basics/cluster-interactive/ Blogs The official Kubernetes blog is available at http://blog.kubernetes.io/ You will find announcements about new releases, useful technical articles, and interesting case studies here The Red Hat enterprise Linux blog also contains a lot of interesting articles regarding Kubernetes They are tagged with the Kubernetes tag, so you can easily filter them out by using the link http://rhelblog.redhat.com/tag/kubernetes/ Extensions As you know, Kubernetes supports extensions There is a nice resource tracking a number of Kubernetes, available at https://github.com/coreos/awesome-kuber netes-extensions If you need, for example, to integrate some cert manager into your architecture, you will probably find a proper extension there Tools Apart from useful articles and tutorials, there are also a couple of useful tools or platforms that make using Kubernetes more enjoyable Let's briefly present them now Rancher Rancher, available at http://rancher.com, is a platform that deserves a separate section in our book It's open source software that makes it easy to deploy and manage Docker containers and Kubernetes in production on any infrastructure You can easily deploy and run containers in production on any infrastructure with the most complete container management platform Helm and charts Kubernetes Helm (available on GitHub at https://github.com/kubernetes/helm) introduces the concept of charts, which are packages of pre-configured Kubernetes resources, curated application definitions for Kubernetes Helm is a tool for managing charts; it streamlines installing and managing Kubernetes applications Think of it as an apt/yum/homebrew package manager for Kubernetes You can use it to find and use popular software packaged as Kubernetes charts, share your own applications as Kubernetes charts, and create reproducible builds of your Kubernetes applications There's a separate repository for charts, of course, on GitHub: https://github.com/kubernetes/charts Currently, the chart binary repository is available on Google Cloud at https://co nsole.cloud.google.com/storage/browser/kubernetes-charts/ and contains a lot of useful prepackaged tools such as Ghost (node.js blogging platform), Jenkins, Joomla, MongoDb, MySQL, Redis, Minecraft, and just to name a few Kompose Kompose (https://github.com/kubernetes/kompose) is a tool to help move Compose configuration files into Kubernetes Kompose is a tool for defining and running multi-container Docker applications If you are a Kompose user, you can use it to move your multi-containers configuration straight into Kubernetes setup by translating a Docker Compose file into Kubernetes objects Note that the transformation of the Docker Compose format to Kubernetes resources manifest may not be exactly precise, but it helps tremendously when first deploying an application on Kubernetes Kubetop Kubetop, again available on GitHub https://github.com/LeastAuthority/kubetop, is the same as the top command for Kubernetes cluster It's extremely useful; it lists all your cluster's running nodes, all pods on them and all containers in those pods The tool gives you information about the CPU and memory utilization for each node, similar to the Unix/Linux top command If you need to know quickly what's consuming the most resources on your cluster, the quick command-line tool is a very handy option Kube-applier Available on GitHub at https://github.com/box/kube-applier, kube-applier enables automated deployment and declarative configuration for your Kubernetes cluster It runs as a Kubernetes service, takes a set of declarative configuration files hosted in a Git repository, and applies them for a Kubernetes cluster The kube-applier runs itself as a Pod in your cluster and continuously watches the Git repository to ensure that the cluster objects are up to date with their associated spec files (JSON or YAML) in the repository The tool also contains a status page and provides metrics for monitoring I find it extremely useful in the daily development, where your deployment, services, or pod definition change often As you can see, there are a lot of useful resources for Docker and Kubernetes around the web After reading this book, you will probably want to skip most of the beginnings and go straight to more advanced topics The best thing about all of those resources is that they are free of charge, so basically nothing stops you from exploring the wonderful world of managed containers Try and learn, and if the time comes, go ahead and use Docker and Kubernetes to deploy your production ready Java software, either on your own infrastructure or on the cloud It will be amazing to see how your Java application scales itself and becomes fail proof Docker and Kubernetes enable it and you now have the knowledge to use it Docker, together with Kubernetes, has radically changed the face of the technology landscape and I hope it will also change your development and release flow for the better .. .Docker and Kubernetes for Java Developers Scale, deploy, and monitor multi-container applications Jaroslaw Krochmalski BIRMINGHAM - MUMBAI Docker and Kubernetes for Java Developers. .. is for This book is for Java developers, who would like to get into the world of containerization The reader will learn how Docker and Kubernetes can help with deployment and management of Java. .. 7-Zip for Windows Zipeg / iZip / UnRarX for Mac 7-Zip / PeaZip for Linux The code bundle for the book is also hosted on GitHub at https://github.com/PacktP ublishing /Docker- and- Kubernetes- for- Java- Developers