📄 Page
1
Sameer Naik, Sébastien Goasguen & Jonathan Michaux Second Edition Kubernetes Cookbook Building Cloud Native Applications N a ik, G oa sg uen & M icha ux 2E
📄 Page
2
SYSTEM ADMINISTR ATION Kubernetes Cookbook Twitter: @oreillymedia linkedin.com/company/oreilly-media youtube.com/oreillymedia Kubernetes is the de facto standard for container orchestration and distributed applications management, embraced by those who value extensibility, portability, automation, and declarative configuration style. With this practical cookbook, you’ll learn hands-on Kubernetes recipes for automating the deployment, scaling, and operations of application containers across clusters of hosts. In this fully updated second edition, Sameer Naik, Sébastien Goasguen, and Jonathan Michaux provide a problem-solution- discussion format with easy lookups to help you find the detailed answers you need—fast. Kubernetes lets you deploy your applications quickly and predictably, so you can efficiently respond to customer demand. This cookbook delivers the essential knowledge that developers and system administrators need to get there. Recipes in this cookbook focus on: • Creating a Kubernetes cluster • Using the Kubernetes command-line interface • Managing fundamental workload types • Working with services • Exploring the Kubernetes API • Managing stateful and non-cloud-native apps • Working with volumes and configuration data • Cluster-level and application-level scaling • Securing your applications • Monitoring and logging • Maintenance and troubleshooting Sameer Naik, a cloud native engineer with a background in embedded systems, is an early adopter of the Docker project. Sébastien Goasguen, cofounder of TriggerMesh, is also the founder of Kubernetes startup Skippbox. He’s the author of Docker Cookbook and 60 Recipes for Apache CloudStack. Jonathan Michaux is a product manager with an engineering background and a PhD in CS. He has built developers tools for API management, integration, microservices, and EDA. 9 7 8 1 0 9 8 1 4 2 2 4 7 5 6 5 9 9 US $65.99 CAN $82.99 ISBN: 978-1-098-14224-7 2E
📄 Page
3
Sameer Naik, Sébastien Goasguen, and Jonathan Michaux Kubernetes Cookbook Building Cloud Native Applications SECOND EDITION
📄 Page
4
978-1-098-14224-7 [LSI] Kubernetes Cookbook by Sameer Naik, Sébastien Goasguen, and Jonathan Michaux Copyright © 2024 CloudTank SARL, Sameer Naik, and Jonathan Michaux. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly 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. Acquisitions Editor: John Devins Development Editor: Jeff Bleiel Production Editor: Elizabeth Faerm Copyeditor: Kim Wimpsett Proofreader: Rachel Head Indexer: Ellen Troutman-Zaig Interior Designer: David Futato Cover Designer: Karen Montgomery Illustrator: Kate Dullea March 2018: First Edition November 2023: Second Edition Revision History for the Second Edition 2023-11-13: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781098142247 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Kubernetes Cookbook, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the authors, and do not represent the publisher’s 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. This work is part of a collaboration between O’Reilly and DoiT International. See our statement of editorial independence.
📄 Page
5
For my wife, Navita, and our cherished son, Niall. —Sameer For my boys, whose smiles, hugs, and spirits make me a better person. —Sébastien For Mathilde, and for our wonderful children, Mélie and Anouk. —Jonathan
📄 Page
6
(This page has no text content)
📄 Page
7
Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix 1. Getting Started with Kubernetes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Installing the Kubernetes CLI, kubectl 1 1.2 Installing Minikube to Run a Local Kubernetes Instance 2 1.3 Using Minikube Locally for Development 4 1.4 Starting Your First Application on Minikube 5 1.5 Using kind to Run Kubernetes Locally 6 1.6 Using Kubernetes in Docker Desktop 7 1.7 Switching kubectl Contexts 9 1.8 Switching Contexts and Namespaces Using kubectx and kubens 10 2. Creating a Kubernetes Cluster. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.1 Preparing a New Node for a Kubernetes Cluster 13 2.2 Bootstrapping a Kubernetes Control-Plane Node 15 2.3 Installing a Container Network Add-on for Cluster Networking 17 2.4 Adding Worker Nodes to a Kubernetes Cluster 17 2.5 Deploying the Kubernetes Dashboard 18 2.6 Accessing the Kubernetes Dashboard 19 2.7 Deploying the Kubernetes Metrics Server 22 2.8 Downloading a Kubernetes Release from GitHub 24 2.9 Downloading Client and Server Binaries 24 2.10 Using systemd Unit Files for Running Kubernetes Components 26 2.11 Creating a Kubernetes Cluster on Google Kubernetes Engine 29 2.12 Creating a Kubernetes Cluster on Azure Kubernetes Service 30 2.13 Creating a Kubernetes Cluster on Amazon Elastic Kubernetes Service 33 v
📄 Page
8
3. Learning to Use the Kubernetes Client. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.1 Listing Resources 35 3.2 Deleting Resources 36 3.3 Watching Resource Changes with kubectl 38 3.4 Editing Objects with kubectl 38 3.5 Asking kubectl to Explain Resources and Fields 39 4. Creating and Modifying Fundamental Workloads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.1 Creating a Pod Using kubectl run 41 4.2 Creating a Deployment Using kubectl create 42 4.3 Creating Objects from File Manifests 43 4.4 Writing a Pod Manifest from Scratch 44 4.5 Launching a Deployment Using a Manifest 45 4.6 Updating a Deployment 48 4.7 Running a Batch Job 51 4.8 Running a Task on a Schedule Within a Pod 53 4.9 Running Infrastructure Daemons per Node 54 5. Working with Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 5.1 Creating a Service to Expose Your Application 58 5.2 Verifying the DNS Entry of a Service 60 5.3 Changing the Type of a Service 61 5.4 Deploying an Ingress Controller 63 5.5 Making Services Accessible from Outside the Cluster 64 6. Managing Application Manifests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 6.1 Installing Helm, the Kubernetes Package Manager 69 6.2 Adding Chart Repositories to Helm 70 6.3 Using Helm to Install Applications 72 6.4 Inspecting the Customizable Parameters of a Chart 73 6.5 Overriding Chart Parameters 74 6.6 Getting the User-Supplied Parameters of a Helm Release 75 6.7 Uninstalling Applications with Helm 75 6.8 Creating Your Own Chart to Package Your Application with Helm 76 6.9 Installing Kompose 77 6.10 Converting Your Docker Compose Files to Kubernetes Manifests 78 6.11 Converting Your Docker Compose File to a Helm Chart 79 6.12 Installing kapp 79 6.13 Deploying YAML Manifests Using kapp 80 vi | Table of Contents
📄 Page
9
7. Exploring the Kubernetes API and Key Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 7.1 Discovering the Kubernetes API Server’s Endpoints 83 7.2 Understanding the Structure of a Kubernetes Manifest 85 7.3 Creating Namespaces to Avoid Name Collisions 86 7.4 Setting Quotas Within a Namespace 88 7.5 Labeling an Object 89 7.6 Using Labels for Queries 89 7.7 Annotating a Resource with One Command 91 8. Volumes and Configuration Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 8.1 Exchanging Data Between Containers via a Local Volume 93 8.2 Passing an API Access Key to a Pod Using a Secret 95 8.3 Providing Configuration Data to an Application 98 8.4 Using a Persistent Volume with Minikube 100 8.5 Understanding Data Persistency on Minikube 103 8.6 Storing Encrypted Secrets in Version Control 106 9. Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 9.1 Scaling a Deployment 112 9.2 Using Horizontal Pod Autoscaling 112 9.3 Automatically Resizing a Cluster in GKE 115 9.4 Automatically Resizing an Amazon EKS Cluster 118 10. Security. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 10.1 Providing a Unique Identity for an Application 121 10.2 Listing and Viewing Access Control Information 123 10.3 Controlling Access to Resources 127 10.4 Securing Pods 129 11. Monitoring and Logging. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 11.1 Accessing the Logs of a Container 132 11.2 Recovering from a Broken State with a Liveness Probe 133 11.3 Controlling Traffic Flow to a Pod Using a Readiness Probe 133 11.4 Protecting Slow-Starting Containers Using a Start-up Probe 134 11.5 Adding Liveness and Readiness Probes to Your Deployments 136 11.6 Accessing Kubernetes Metrics in the CLI 138 11.7 Using Prometheus and Grafana on Minikube 139 12. Maintenance and Troubleshooting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 12.1 Enabling Autocomplete for kubectl 143 12.2 Removing a Pod from a Service 144 Table of Contents | vii
📄 Page
10
12.3 Accessing a ClusterIP Service Outside the Cluster 146 12.4 Understanding and Parsing Resource Statuses 147 12.5 Debugging Pods 150 12.6 Influencing a Pod’s Start-up Behavior 154 12.7 Getting a Detailed Snapshot of the Cluster State 156 12.8 Adding Kubernetes Worker Nodes 158 12.9 Draining Kubernetes Nodes for Maintenance 159 13. Service Meshes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 13.1 Installing the Istio Service Mesh 161 13.2 Deploying a Microservice with an Istio Sidecar 163 13.3 Routing Traffic Using an Istio Virtual Service 165 13.4 Rewriting a URL Using an Istio Virtual Service 167 13.5 Installing the Linkerd Service Mesh 169 13.6 Deploying a Service into the Linkerd Mesh 170 13.7 Routing Traffic to a Service in Linkerd 172 13.8 Authorizing Traffic to the Server in Linkerd 174 14. Serverless and Event-Driven Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 14.1 Installing the Knative Operator 177 14.2 Installing the Knative Serving Component 178 14.3 Installing the Knative CLI 180 14.4 Creating a Knative Service 181 14.5 Installing the Knative Eventing Component 183 14.6 Deploying a Knative Eventing Source 184 14.7 Enabling Knative Eventing Sources 187 14.8 Installing Event Sources from TriggerMesh 188 15. Extending Kubernetes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 15.1 Compiling from Source 191 15.2 Compiling a Specific Component 192 15.3 Using a Python Client to Interact with the Kubernetes API 193 15.4 Extending the API Using Custom Resource Definitions 194 Appendix: Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 viii | Table of Contents
📄 Page
11
Preface Welcome to Kubernetes Cookbook, and thanks for choosing it! With this book, we want to help you solve concrete problems around Kubernetes. We’ve compiled more than 100 recipes covering topics such as setting up a cluster, managing containerized workloads using Kubernetes API objects, using storage primitives, configuring secu‐ rity, and plenty more. Whether you are new to Kubernetes or have been using it for a while, we hope you’ll find something useful here to improve your experience and use of Kubernetes. Who Should Read This Book This book was written for anyone who belongs somewhere in the DevOps spectrum. You might be an application developer who is required to occasionally interact with Kubernetes, or a platform engineer creating reusable solutions for other engineers in your organization, or anywhere in between. This book will help you navigate your way successfully through the Kubernetes jungle, from development to production. It covers core Kubernetes concepts as well as solutions from the broader ecosystem that have almost become de facto standards in the industry. Why We Wrote This Book Collectively, we have been part of the Kubernetes community for many years and have seen the many issues beginners and even more advanced users run into. We wanted to share the knowledge we’ve gathered running Kubernetes in production, as well as developing on and in Kubernetes—i.e., contributing to the core codebase or the ecosystem and writing applications that run on Kubernetes. It made perfect sense to work on the second edition of this book, considering that Kubernetes adoption has continued to grow in the years since the first edition of the book was published. ix
📄 Page
12
Navigating This Book This cookbook contains 15 chapters. Each chapter is composed of recipes written in the standard O’Reilly recipe format (Problem, Solution, Discussion). You can read this book from front to back or skip to a specific chapter or recipe. Each recipe is independent of the others, and when an understanding of concepts from other recipes is needed, appropriate references are provided. The index is also an extremely powerful resource because sometimes a recipe is also showcasing a specific command, and the index highlights these connections. A Note on Kubernetes Releases At the time of writing, Kubernetes 1.27 was the latest stable version, released at the end of April 2023, and this is the version we’re using throughout the book as the baseline. However, the solutions presented here should, in general, work for older releases; we will call it out explicitly if this is not the case, mentioning the minimum required version. Kubernetes follows a three-releases-per-year cadence. A release cycle has a length of approximately 15 weeks; for example, 1.26 was released in December 2022, 1.27 in April 2023, and 1.28 in August 2023, as this book was entering production. The Kubernetes release versioning guidelines indicate that you can expect support for a feature for the most recent three minor releases. Kubernetes Community supports active patch release series for a period of roughly 14 months. This means the stable API objects in the 1.27 release will be supported until at least June 2024. However, because the recipes in this book most often use only stable APIs, if you use a newer Kubernetes release, the recipes should still work. Technology You Need to Understand This intermediate-level book requires a minimal understanding of a few development and system administration concepts. Before diving into the book, you might want to review the following: bash (Unix shell) This is the default Unix shell on Linux and macOS. Familiarity with the Unix shell, such as for editing files, setting file permissions and user privileges, moving files around the filesystem, and doing some basic shell programming, will be beneficial. For a general introduction, consult books such as Cameron Newham’s Learning the bash Shell, Third Edition, or Carl Albing and JP Vossen’s bash Cookbook, Second Edition, both from O’Reilly. x | Preface
📄 Page
13
Package management The tools in this book often have multiple dependencies that need to be met 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 Homebrew 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 not already familiar with Git, we recommend Version Control with Git, Third Edition, by Prem Kumar Ponuthorai and Jon Loeliger (O’Reilly) as a good place to start. Together with Git, the GitHub website is a great resource to get started with a hosted repository of your own. To learn about GitHub, check out the GitHub Training Kit site. Go Kubernetes is written in Go. Go has established itself as a popular programming language more broadly in the Kubernetes community and beyond. This cook‐ book is not about Go programming, but it shows how to compile a few Go projects. Some minimal understanding of how to set up a Go workspace will be handy. If you want to know more, a good place to start is the O’Reilly video training course Introduction to Go Programming. 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. 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. Preface | xi
📄 Page
14
This element signifies a tip or suggestion. This element signifies a general note. This element indicates a warning or caution. Using Code Examples Supplemental material (Kubernetes manifests, code examples, exercises, etc.) is avail‐ able for download at https://github.com/k8s-cookbook/recipes. You can clone this repository, go to the relevant chapter and recipe, and use the code as is: $ git clone https://github.com/k8s-cookbook/recipes The examples in this repo are not meant to represent optimized setups to be used in production. They give you the basic minimum required to run the examples in the recipes. If you have a technical question or a problem using the code examples, please send email to support@oreilly.com. 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 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 signifi‐ cant amount of example code from this book into your product’s documentation does require permission. xii | Preface
📄 Page
15
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Kubernetes Cookbook, by Sameer Naik, Sébastien Goasguen, and Jonathan Michaux (O’Reilly). Copyright 2024 Cloud‐ Tank SARL, Sameer Naik, and Jonathan Michaux, 978-1-098-14224-7.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. O’Reilly Online Learning For more than 40 years, O’Reilly Media has provided technol‐ ogy 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, 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, visit https://oreilly.com. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-889-8969 (in the United States or Canada) 707-829-7019 (international or local) 707-829-0104 (fax) support@oreilly.com https://www.oreilly.com/about/contact.html 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/kubernetes-cookbook-2e. For news and information about our books and courses, visit https://oreilly.com. Find us on LinkedIn: https://linkedin.com/company/oreilly-media. Follow us on Twitter: https://twitter.com/oreillymedia. Watch us on YouTube: https://youtube.com/oreillymedia. Preface | xiii
📄 Page
16
Acknowledgments Thank you to the entire Kubernetes community for developing such amazing soft‐ ware and for being a great bunch of people—open, kind, and always ready to help. Sameer and Jonathan were honored to work with Sébastien on the second edition of this book. We are all thankful for the reviews provided by Roland Huß, Jonathan Johnson, and Benjamin Muschko, who were invaluable in improving the finished product. We are also grateful to John Devins, Jeff Bleiel, and Ashley Stussy, our editors at O’Reilly, who were a pleasure to work with. xiv | Preface
📄 Page
17
CHAPTER 1 Getting Started with Kubernetes In this first chapter we present recipes that will help you get started with Kubernetes. We show you how to use Kubernetes without installing it and introduce components such as the command-line interface (CLI) and the dashboard, which allow you to interact with a cluster, as well as Minikube, an all-in-one solution you can run on your laptop. 1.1 Installing the Kubernetes CLI, kubectl Problem You want to install the Kubernetes command-line interface so you can interact with your Kubernetes cluster. Solution The easiest option is to download the latest official release. For example, on a Linux system, to get the latest stable version, enter the following: $ wget https://dl.k8s.io/release/$(wget -qO - https://dl.k8s.io/release/ stable.txt)/bin/linux/amd64/kubectl $ sudo install -m 755 kubectl /usr/local/bin/kubectl Using the Homebrew package manager, Linux and macOS users can also install kubectl: $ brew install kubectl 1
📄 Page
18
After installation, make sure you have a working kubectl by listing its version: $ kubectl version --client Client Version: v1.28.0 Kustomize Version: v5.0.4-0.20230... Discussion kubectl is the official Kubernetes CLI and is available as open source software, which means you could build the kubectl binary yourself if you needed. See Recipe 15.1 to learn about compiling the Kubernetes source code locally. It’s useful to note that Google Kubernetes Engine users (see Recipe 2.11) can install kubectl using gcloud: $ gcloud components install kubectl Also note that in the latest versions of Minikube (see Recipe 1.2), you can invoke kubectl as a subcommand of minikube to run a kubectl binary that matches the cluster version: $ minikube kubectl -- version --client Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.4", ...} Kustomize Version: v5.0.1 See Also • Documentation on installing kubectl 1.2 Installing Minikube to Run a Local Kubernetes Instance Problem You want to use Kubernetes for testing or development or for training purposes on your local machine. Solution Minikube is a tool that lets you easily use Kubernetes on your local machine. To install the Minikube CLI locally, you can get the latest prebuilt release or build from source. To install the latest release of minikube on a Linux-based machine, do this: 2 | Chapter 1: Getting Started with Kubernetes
📄 Page
19
$ wget https://storage.googleapis.com/minikube/releases/latest/ minikube-linux-amd64 -O minikube $ sudo install -m 755 minikube /usr/local/bin/minikube This will put the minikube binary in your path and make it accessible from everywhere. Once it’s installed, you can verify the Minikube version with the following command: $ minikube version minikube version: v1.31.2 commit: fd7ecd... Discussion Minikube can be deployed as a virtual machine, a container, or bare metal. This is configured using the --driver flag while creating a cluster on Minikube. When this flag is not specified, Minikube will automatically select the best available runtime environment. A hypervisor is a software or hardware component that creates and manages virtual machines. It is responsible for allocating and managing the physical resources (CPU, memory, storage, network) of a host system and allowing multiple virtual machines (VMs) to run concurrently on the same physical hardware. Minikube supports a range of hypervisors, such as VirtualBox, Hyperkit, Docker Desktop, Hyper-V, and so on. The drivers page gives an overview of the supported runtimes. Minikube can also use a container runtime to create a cluster on a host machine. This driver is available only on a Linux-based host, where it’s possible to run Linux containers natively without having to use a VM. While a container-based runtime does not offer the same level of isolation as a virtual machine, it does offer the best performance and resource utilization. At the time of writing, Minikube has support for Docker Engine and Podman (experimental). Other tools that can be used for running local Kubernetes clusters using Linux containers are as follows: • Kubernetes in Docker Desktop (see Recipe 1.6) • kind (see Recipe 1.5) • k3d 1.2 Installing Minikube to Run a Local Kubernetes Instance | 3
📄 Page
20
See Also • Minikube Get Started! guide • Minikube drivers • minikube source on GitHub 1.3 Using Minikube Locally for Development Problem You want to use Minikube locally for testing and development of your Kubernetes application. You have installed and started minikube (see Recipe 1.2) and want to know a few extra commands to simplify your development experience. Solution Use the minikube start command to create a Kubernetes cluster locally: $ minikube start By default the cluster will be allocated 2 GB of RAM. If you don’t like the defaults, you can override parameters such as the memory and number of CPUs, as well as picking a certain Kubernetes version for the Minikube VM—for example: $ minikube start --cpus=4 --memory=4096 --kubernetes-version=v1.27.0 Additionally, you can specify the number of cluster nodes by overriding the default value of one node: $ minikube start --cpus=2 --memory=4096 --nodes=2 To inspect the status of the Minikube cluster, do this: $ minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured minikube-m02 type: Worker host: Running kubelet: Running 4 | Chapter 1: Getting Started with Kubernetes