Praise for Programming Kubernetes
Programming Kubernetes fills a gap in the Kubernetes ecosystem. Theres a plethora of books and documentation on how to run Kubernetes clusters, but were still working to fill in the space around writing software with Kubernetes. This book is a much-needed and well-written guide to building with and on Kubernetes.
Bryan Liles, Senior Staff Engineer, VMware
This is a book I wish had existed when I started writing Kubernetes controllers. It serves the reader as a comprehensive deep dive into the Kubernetes programming interface and system behavior, and how to write robust software.
Michael Gasch, Application Platform Architect
in the Office of the CTO at VMware
A must-read if you want to extend Kubernetes.
Dimitris-Ilias Gkanatsios, Technical Evangelist,
Microsoft Greece
Extending Kubernetes is the only way to deploy and manage the lifecycle of complex applications. This book shows how to create your own Kubernetes resources and
how to extend the Kubernetes API.
Ahmed Belgana, Cloud Build Engineer, SAP
Programming Kubernetes
by Michael Hausenblas and Stefan Schimanski
Copyright 2019 Michael Hausenblas and Stefan Schimanski. All rights reserved.
Printed in the United States of America.
Published by OReilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Development Editor: Virginia Wilson
- Acquisitions Editor: John Devins
- Production Editor: Katherine Tozer
- Copyeditor: Rachel Monaghan
- Proofreader: Arthur Johnson
- Indexer: Judith McConville
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
Revision History for the First Edition
- 2019-07-18: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492047100 for release details.
The OReilly logo is a registered trademark of OReilly Media, Inc. Programming Kubernetes, the cover image, and related trade dress are trademarks of OReilly Media, Inc.
The views expressed in this work are those of the authors and do not represent the publishers views. While the publisher and the authors have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the authors disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights.
978-1-492-04710-0
[LSI]
Preface
Welcome to Programming Kubernetes, and thanks for choosing to spend some time with us. Before we jump into the deep end, lets quickly get a few administrative and organizational things out of the way. Well also share our motivation for writing this book.
Who Should Read This Book
Youre a developer going cloud-native, or an AppOps or namespace admin wanting to get the maximum out of Kubernetes. Vanilla settings dont do it for you anymore, and you may have learned about extension points. Good. Youre in the right place.
Why We Wrote This Book
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 dont 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.
Ecosystem
In the grand scheme of things, its 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 peoples minds and scattered over thousands of Slack channels and StackOverflow answers.
Note
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 dont have access to a recent enough cluster, using Minikube or kind on the local workstation is highly recommended.
Technology You Need to Understand
This intermediate-level book requires a minimal understanding of a few development and system administration concepts. Before diving in, you might want to review the following:
Package management
The tools in this book often have multiple dependencies that youll 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
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 (OReilly) 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.
Go
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.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
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.