Kubernetes: Up and Running Dive into the Future of Infrastructure Kelsey Hightower, Brendan Burns, and Joe Beda Kubernetes: Up and Running by Kelsey Hightower, Brendan Burns, and Joe Beda Copyright 2017 Kelsey Hightower, Brendan Burns, and Joe Beda. 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/safari ). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com .
- Editor: Angela Rufino
- Production Editor: Melanie Yarbrough
- Copyeditor: Christina Edwards
- Proofreader: Rachel Head
- Indexer: Kevin Broccoli
- Interior Designer: David Futato
- Cover Designer: Karen Montgomery
- Illustrator: Rebecca Demarest
- September 2017: First Edition
Revision History for the First Edition
- 2017-09-05: First Release
- 2018-02-02: Second Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491935675 for release details. The OReilly logo is a registered trademark of OReilly Media, Inc. Kubernetes: Up and Running , the cover image, and related trade dress are trademarks of OReilly Media, Inc. 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-491-93567-5 [LSI] For Klarissa and Kelis, who keep me sane. And for my Mom, who taught me a strong work ethic and how to rise above all odds. Kelsey Hightower For my Dad, who helped me fall in love with computers by bringing home punch cards and dot matrix banners. Joe Beda For Robin, Julia, Ethan, and everyone who bought cookies to pay for that Commodore 64 in my third-grade class. Brendan Burns Preface Kubernetes: A Dedication Kubernetes would like to thank every sysadmin who has woken up at 3 a.m. to restart a process. Every developer who pushed code to production only to find that it didnt run like it did on their laptop. Every systems architect who mistakenly pointed a load test at the production service because of a leftover hostname that they hadnt updated. It was the pain, the weird hours, and the weird errors that inspired the development of Kubernetes. In a single sentence: Kubernetes intends to radically simplify the task of building, deploying, and maintaining distributed systems. It has been inspired by decades of real-world experience building reliable systems and it has been designed from the ground up to make that experience, if not euphoric, at least pleasant. We hope you enjoy the book! Who Should Read This Book Whether you are new to distributed systems or have been deploying cloud-native systems for years, containers and Kubernetes can help you achieve new levels of velocity, agility, reliability, and efficiency. This book describes the Kubernetes cluster orchestrator and how its tools and APIs can be used to improve the development, delivery, and maintenance of distributed applications. Though no previous experience with Kubernetes is assumed, to make maximal use of the book you should be comfortable building and deploying server-based applications. Familiarity with concepts like load balancers and network storage will be useful, though not required. Likewise, experience with Linux, Linux containers, and Docker, though not essential, will help you make the most of this book. Why We Wrote This Book We have been involved with Kubernetes since its very beginnings. It has been truly remarkable to watch it transform from a curiosity largely used in experiments to a crucial production-grade infrastructure that powers large-scale production applications in varied fields, from machine learning to online services. As this transition occurred, it became increasingly clear that a book that captured both how to use the core concepts in Kubernetes and the motivations behind the development of those concepts would be an important contribution to the state of cloud-native application development. We hope that in reading this book, you not only learn how to build reliable, scalable applications on top of Kubernetes, but also that you receive insight into the core challenges of distributed systems that led to its development. A Word on Cloud-Native Applications Today From the first programming languages, to object-oriented programming, to the development of virtualization and cloud infrastructure, the history of computer science is a history of the development of abstractions that hide complexity and empower you to build ever more sophisticated applications. Despite this, the development of reliable, scalable applications is still dramatically more challenging than it ought to be. In recent years, containers and container orchestration APIs like Kubernetes have become an important abstraction that radically simplifies the development of reliable, scalable distributed systems. Though containers and orchestrators are still in the process of entering the mainstream, they are already enabling developers to build and deploy applications with a speed, agility, and reliability that would have seemed like science fiction only a few years ago. Navigating This Book This book is organized as follows. The first chapter outlines the high-level benefits of Kubernetes without diving too deeply into the details. If you are new to Kubernetes, this is a great place to start to understand why you should read the rest of the book. The following chapter provides a detailed introduction to containers and containerized application development. If youve never really played around with Docker before, this chapter will be a useful introduction. If you are already a Docker expert, it will likely be mostly review. covers how to deploy Kubernetes. While most of this book focuses on how to use Kubernetes, you need to get a cluster up and running before you start using it. While running a cluster for production is out of the scope of this book, this chapter presents a couple of easy ways to create a cluster so that you can understand how to use Kubernetes. Starting with ). These form the core basics of what you need to deploy your service in Kubernetes. After those chapters, we cover some more specialized objects in Kubernetes: DaemonSet s ( ). While these chapters are essential for many production applications, if you are just learning Kubernetes they can be skipped and returned to later, after you gain more experience and expertise. We then cover deployments ( ). Finally, we conclude with some examples of how to develop and deploy real-world applications in Kubernetes. Online Resources You will want to install Docker . You likely will also want to familiarize yourself with the Docker documentation if you have not already done so. Likewise, you will want to install the kubectl command-line tool . You may also want to join the Kubernetes slack channel , where you will find a large community of users who are willing to talk and answer questions at nearly any hour of the day. Finally, as you grow more advanced, you may want to engage with the open source Kubernetes repository on GitHub . Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates 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. 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. NOTE This icon signifies a tip, suggestion, or general note. WARNING This icon indicates a warning or caution. Using Code Examples Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/kubernetes-up-and-running/examples . This book is here to help you get your job done. 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 youre 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 OReilly 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 products documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Kubernetes: Up and Running by Kelsey Hightower, Brendan Burns, and Joe Beda (OReilly). Copyright 2017 Kelsey Hightower, Brendan Burns, and Joe Beda, 978-1-491-93567-5. If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at . OReilly Safari Safari (formerly Safari Books Online) is a membership-based training and reference platform for enterprise, government, educators, and individuals. Members have access to thousands of books, training videos, Learning Paths, interactive tutorials, and curated playlists from over 250 publishers, including OReilly Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and Course Technology, among others. For more information, please visit http://oreilly.com/safari . How to Contact Us Please address comments and questions concerning this book to the publisher:
Next page