Getting Started with Kubernetes Third Edition

Getting Started with Kubernetes Third Edition

Getting Started with Kubernetes Third Edition Extend your containerization strategy by orchestrating and managing large-scale container deployments Jonathan Baier Jesse White BIRMINGHAM - MUMBAI Getting Started with Kubernetes Third Edition Copyright © 2018 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 authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been 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. Commissioning Editor: Vijin Boricha Acquisition Editor: Rahul Nair Content Development Editor: Sharon Raj Technical Editor: Komal Karne Copy Editor: Safis Editing Project Coordinator: Drashti Panchal Proofreader: Safis Editing Indexer: Mariammal Chettiyar Graphics: Tom Scaria Production Coordinator: Shantanu Zagade First published: December 2015 Second edition: May 2017 Third edition: October 2018 Production reference: 2061118 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78899-472-9 www.packtpub.com Dedicated to my loving and talented wife, Kaitlyn. Thank you for your support while writing this book, and for all the good work you do in this world. - Jesse White mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content Packt.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. Contributors About the authors Jonathan Baier is an emerging technology leader living in Brooklyn, New York. He has had a passion for technology since an early age. When he was 14 years old, he was so interested in the family computer (an IBM PCjr) that he pored over the several hundred pages of BASIC and DOS manuals. Then, he taught himself to code a very poorly-written version of Tic-Tac-Toe. During his teenage years, he started a computer support business. Throughout his life, he has dabbled in entrepreneurship. He currently works as Senior Vice President of Cloud Engineering and Operations for Moody's corporation in New York. I'd like to thank my wonderful wife, Tomoko, and my playful son, Nikko. You both gave me incredible support and motivation during the writing process for both editions of this book. Your smiles move mountains I could not on my own. You are my True North and guiding light in the storm. I'd also like to thank my co-author, Jesse, for all the hard work in updating and adding new chapters to this edition. You not only made this edition possible, but also took the book to the next level! Jesse White is a 15-year veteran and technology leader in New York City's very own Silicon Alley, where he is a pillar of the vibrant engineering ecosystem. As founder of DockerNYC and an active participant in the open source community, you can find Jesse at a number of leading industry events, including DockerCon and VelocityConf, giving talks and workshops. About the reviewer Jakub Pavlik is a co-founder, former CTO, and chief architect of TCP Cloud (acquired by Mirantis in 2016). Jakub and his team worked for several years on the IaaS cloud platform based on the OpenStack-Salt, Kubernetes, and Open Contrail projects, which they deployed and operated for global service providers. Leveraging his skills in architecture, implementation, and operation, his TCP Cloud team was acquired by #1 pure play OpenStack company Mirantis. Currently a director of engineering, together with other skilled professionals, Jakub builds and operates a new generation of edge-computing platforms at Volterra Inc. He is also an enthusiast of Linux OS, ice hockey (with Pepa), and films, and loves his wife, Hanulka. Packt is searching for authors like you If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea. Table of Contents Preface 1 Chapter 1: Introduction to Kubernetes 7 Technical requirements 8 A brief overview of containers 8 What is a container? 9 cgroups 10 Namespaces 11 Union filesystems 13 Why are containers so cool? 15 The advantages of Continuous Integration/Continuous Deployment 17 Resource utilization 18 Microservices and orchestration 19 Future challenges 19 Our first clusters 20 Running Kubernetes on GCE 21 Kubernetes UI 32 Grafana 36 Command line 37 Services running on the master 38 Services running on the minions 41 Tearing down a cluster 44 Working with other providers 44 CLI setup 45 IAM setup 45 Cluster state storage 47 Creating your cluster 47 Other modes 53 Resetting the cluster 54 Investigating other deployment automation 54 Local alternatives 55 Starting from scratch 56 Cluster setup 56 Installing Kubernetes components (kubelet and kubeadm) 58 Setting up a master 59 Joining nodes 61 Networking 61 Joining the cluster 62 Summary 63 Questions 63 Table of Contents Further reading 64 Chapter 2: Building a Foundation with Core Kubernetes Constructs 65 Technical requirements 65 The Kubernetes system 65 Nucleus 66 Application layer 68 Governance layer 69 Interface layer 69 Ecosystem 69 The architecture 70 The Master 70 Cluster state 71 Cluster nodes 73 Master 75 Nodes (formerly minions) 76 Core constructs 79 Pods 80 Pod example 80 Labels 82 The container's afterlife 83 Services 83 Replication controllers and replica sets 86 Our first Kubernetes application 86 More on labels 93 Replica sets 96 Health checks 97 TCP checks 102 Life cycle hooks or graceful shutdown 103 Application scheduling 105 Scheduling example 105 Summary 109 Questions 109 Further reading 110 Chapter 3: Working with Networking, Load Balancers, and Ingress 111 Technical requirements 111 Container networking 112 The Docker approach 112 Docker default networks 112 Docker user-defined networks 113 The Kubernetes approach 114 Networking options 115 Networking comparisons 116 Weave 116 Flannel 117 Project Calico 117 [ ii ] Table of Contents Canal 117 Kube-router 117 Balanced design 118 Advanced services 119 External services 120 Internal services 121 Custom load balancing 123 Cross-node proxy 125 Custom ports 126 Multiple ports 127 Ingress 128 Types of ingress 129 Migrations, multicluster, and more 135 Custom addressing 137 Service discovery 138 DNS 139 Multitenancy 140 Limits 142 A note on resource usage 146 Summary 146 Questions 146 Further reading 147 Chapter 4: Implementing Reliable Container-Native Applications 148 Technical requirements 148 How Kubernetes manages state 149 Deployments 149 Deployment use cases 149 Scaling 151 Updates and rollouts 152 History and rollbacks 156 Autoscaling 158 Jobs 161 Other types of jobs 163 Parallel jobs 163 Scheduled jobs 164 DaemonSets 164 Node selection 166 Summary 169 Questions 169 Chapter 5: Exploring Kubernetes Storage Concepts 170 Technical requirements 171 Persistent storage 171 Temporary disks 172 [ iii ] Table of Contents Cloud volumes 173 GCE Persistent Disks 173 AWS Elastic Block Store 179 Other storage options 180 PersistentVolumes and Storage Classes 180 Dynamic volume provisioning 182 StatefulSets 183 A stateful example 184 Summary 190 Questions 191 Further reading 191 Chapter 6: Application Updates, Gradual Rollouts, and Autoscaling 192 Technical requirements 193 Example setup 193 Scaling up 194 Smooth updates 195 Testing, releases, and cutovers 198 Application autoscaling 202 Scaling a cluster 204 Autoscaling 204 Scaling up the cluster on GCE 205 Scaling up the cluster on AWS 209 Scaling manually 211 Managing applications 211 Getting started with Helm 212 Summary 215 Questions 216 Further reading 216 Chapter 7: Designing for Continuous Integration and Delivery 217 Technical requirements 217 Integrating Kubernetes with a continuous delivery pipeline 218 gulp.js 218 Prerequisites 218 gulp.js build example 219 The Kubernetes plugin for Jenkins 222 Prerequisites 222 Installing

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    460 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us