Welcome to Programming Kubernetes, and thanks for choosing to spend some time with us. Before we jump into the deep end, let’s quickly get a few administrative and organizational things out of the way. We’ll also share our motivation for writing this book.
You’re a developer going cloud-native, or an AppOps or namespace admin wanting to get the maximum out of Kubernetes. Vanilla settings don’t do it for you anymore, and you may have learned about extension points. Good. You’re in the right place.
Both of us have been contributing to, writing about, teaching, and using Kubernetes since early 2015. We have developed tooling and apps for Kubernetes and given workshops about developing on and with Kubernetes a couple of times. At some point we said, “Why don’t we write a book?” This would allow even more people, asynchronously and at their own pace, to learn how to program Kubernetes. And here we are. We hope you have as much fun reading the book as we did writing it.
In the grand scheme of things, it’s still early days for the Kubernetes ecosystem. While Kubernetes has, as of early 2018, established itself as the industry standard for managing containers (and their lifecycles), there is still a need for good practices on how to write native applications. The basic building blocks, such as
client-go, custom resources, and cloud-native programming languages, are in place. However, much of the knowledge is tribal, spread across people’s minds and scattered over thousands of Slack channels and StackOverflow answers.
At the time of this writing, Kubernetes 1.15 was the latest stable version. The compiled examples should work with older versions (down to 1.12), but we are basing the code on newer versions of the libraries, corresponding to 1.14. Some of the more advanced CRD features require 1.13 or 1.14 clusters to run, CRD conversion in chapter 9 even 1.15. If you don’t have access to a recent enough cluster, using Minikube or kind on the local workstation is highly recommended.
The tools in this book often have multiple dependencies that you’ll need to meet by installing some packages. Knowledge of the package management system on your machine is therefore required. It could be apt on Ubuntu/Debian systems, yum on CentOS/RHEL systems, or port or brew on macOS. Whatever it is, make sure that you know how to install, upgrade, and remove packages.
Git has established itself as the standard for distributed version control. If you are already familiar with CVS and SVN but have not yet used Git, you should. Version Control with Git by Jon Loeliger and Matthew McCullough (O’Reilly) is a good place to start. Together with Git, the GitHub website is a great resource for getting started with a hosted repository of your own. To learn about GitHub, check out their training offerings and the associated interactive tutorial.
Kubernetes is written in Go. Over the last couple of years, Go has emerged as the new programming language of choice in many startups and for many systems-related open source projects. This book is not about teaching you Go, but it shows you how to program Kubernetes using Go. You can learn Go through a variety of different resources, from online documentation on the Go website to blog posts, talks, and a number of books.
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Also used for commands and command-line output.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
This element signifies a tip or suggestion.
This element signifies a general note.
This element indicates a warning or caution.
This book is here to help you get your job done. You can find the code samples used throughout the book in the GitHub organization for this book.
In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Programming Kubernetes by Michael Hausenblas and Stefan Schimanski (O’Reilly). Copyright 2019 Michael Hausenblas and Stefan Schimanski.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at email@example.com.
Kubernetes manifests, code examples, and other scripts used in this book are available via GitHub. You can clone those repositories, go to the relevant chapter and recipe, and use the code as is.
For almost 40 years, O’Reilly Media has provided technology and business training, knowledge, and insight to help companies succeed.
Our unique network of experts and innovators share their knowledge and expertise through books, articles, conferences, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, please visit http://oreilly.com.
We have a web page for this book where we list errata, examples, and any additional information. You can access this page at https://oreil.ly/pr-kubernetes.
Email firstname.lastname@example.org to comment or ask technical questions about this book.
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
A big “thank you!” goes out to the Kubernetes community for developing such amazing software and for being a great bunch of people—open, kind, and always ready to help. Further, we’re very grateful to our technical reviewers: Ahmed Belgana, Michael Gasch, Dimitris Gkanatsios, Mingding Han, Jess Males, Max Neunhöffer, Ewout Prangsma, and Adrien Trouillaud. You all provided super valuable and actionable feedback and made the book more readable and useful to the reader. Thank you for your time and effort!
Michael would like to express his deepest gratitude to his awesome and supportive family: my wicked smart and fun wife, Anneliese; our kids Saphira, Ranya, and Iannis; and our almost-still-puppy Snoopy.
Stefan would like to thank his wife, Clelia, for being super supportive and encouraging whenever he was again “working on the book.” Without her this book wouldn’t be here. If you find typos in the book, chances are high that they were proudly contributed by the two cats, Nino and Kira.
Last but certainly not least, both authors thank the O’Reilly team, especially Virginia Wilson, for shepherding us through the process of writing this book, making sure we’d deliver on time and with the quality expected.