
Kubernetes Programming with Go: Programming Kubernetes Clients and Operators Using Go and the Kubernetes API
- Length: 336 pages
- Edition: 1
- Language: English
- Publisher: Apress
- Publication Date: 2022-12-25
- ISBN-10: 1484290259
- ISBN-13: 9781484290255
- Sales Rank: #623217 (See Top 100 Books)
https://www.psychiccowgirl.com/3ca0axkl This book begins by introducing the structure of the Kubernetes API and which operations it serves. Following chapters demonstrate how to write native Kubernetes resources definitions using Go structures defined in the API and API Machinery libraries. Miscellaneous utilities are described to help you work with different resource fields and to convert your resource definitions to or from YAML or JSON. Next, you will learn how to interact with the Kubernetes API server to create, delete, update, and monitor resources in a cluster using the client-go library. A complete chapter is devoted to tools provided to test your programs using the client-go library. An example follows to wrap up the first part of the book, describing how to write a kubectl plugin. Next, you will learn how to extend the Kubernetes API using Custom Resource Definitions, and how to write Kubernetes resources in a generic way as well as how to create your own resources using the unstructured concept. The next chapters delve into the controller-runtime library, useful for extending Kubernetes by writing operators, and the kubebuilder framework, which leverages this library, to help you start writing operators in minutes.
source After reading this book, you will have a deep understanding of the Kubernetes API’s structure and how Kubernetes resources are organized within it, and have at your disposal a complete toolbox to help you write Kubernetes clients and operators.
follow site What You Will Learn
- Understand how the Kubernetes API and its resources are organized
- Write Kubernetes resources in Go
- Create resources in a cluster
- Leverage your newly-gained knowledge to write Kubernetes clients and operators
go Who is this Book for:
https://lavozdelascostureras.com/pvnpt1051n Software engineers and (Site Reliability Engineers) SREs wishing to write Kubernetes clients and operators using the Go language.
https://audiopronews.com/headlines/trif36q Table of Contents About the Author About the Technical Reviewers Acknowledgments Introduction Chapter 1: Kubernetes API Introduction Kubernetes Platform at a Glance OpenAPI Specification Verbs and Kinds Group-Version-Resource Sub-resources Official API Reference Documentation The Deployment Documentation Operations Documentation The Pod Documentation One-Page Version of the Documentation Conclusion Chapter 2: Kubernetes API Operations Examining Requests Making Requests Using kubectl as a Proxy Creating a Resource Getting Information About a Resource Getting the List of Resources Cluster-wide In a Specific namespace Filtering the Result of a List Using Label Selectors Using Field Selectors Deleting a Resource Deleting a Collection of Resources Updating a Resource Managing Conflicts When Updating a Resource Using a Strategic Merge Patch to Update a Resource Patching Array Fields Special Directives replace Directive delete Directive deleteFromPrimitiveList Directive setElementOrder Directive Applying Resources Server-side Watching Resources Filtering During a Watch Session Watching After Listing Resources Restarting a watch Request Allowing Bookmarks to Efficiently Restart a watch Request Paginating Results Consistency of the Full List Detecting the Last Chunk Getting Results in Various Formats Getting Results as a Table Column Definitions Row Data Using the YAML Format Using the Protobuf Format Conclusion Chapter 3: Working with API Resources in Go API Library Sources and Import Content of a Package types.go register.go doc.go generated.pb.go and generated.proto types_swagger_doc_generated.go zz_generated.deepcopy.go Specific Content in core/v1 ObjectReference ResourceList Taint Toleration Well-Known Labels Writing Kubernetes Resources in Go Importing the Package The TypeMeta Fields The ObjectMeta Fields Name Namespace UID, ResourceVersion, and Generation Labels and Annotations OwnerReferences Setting APIVersion and Kind Setting Controller Setting BlockOwnerDeletion Spec and Status Comparison with Writing YAML Manifests A Complete Example Conclusion Chapter 4: Using Common Types Pointers Getting the Reference of a Value Dereferencing a Pointer Comparing Two Referenced Values Quantities Parsing a String as Quantity Using an inf.Dec as a Quantity Using a Scaled Integer as a Quantity Operations on Quantities IntOrString Time Factory Methods Operations on Time Conclusion Chapter 5: The API Machinery The Schema Package Scheme Initialization Mapping Conversion Adding Conversion Functions Converting Serialization JSON and YAML Serializer Protobuf Serializer Encoding and Decoding RESTMapper Kind to Resource Resource to Kind Finding Resources The DefaultRESTMapper Implementation Conclusion Chapter 6: The Client-go Library Connecting to the Cluster In-cluster Configuration Out-of-Cluster Configuration From kubeconfig in Memory From a kubeconfig on Disk From a Personalized kubeconfig From Several kubeconfig Files Overriding kubeconfig with CLI Flags Getting a Clientset Using the Clientset Examining the Requests Creating a Resource Getting Information About a Resource Getting List of Resources Filtering the Result of a List Setting LabelSelector Using the Labels Package Using Requirements Parsing a LabelSelector String Using a Set of Key-value Pairs Setting Fieldselector Using the Fields Package Assembling One Term Selectors Parsing a FieldSelector String Using a Set of Key-Value Pairs Deleting a Resource Deleting a Collection of Resources Updating a Resource Using a Strategic Merge Patch to Update a Resource Applying Resources Server-side with Patch Server-side Apply Using Apply Configurations Building an ApplyConfiguration from Scratch Building an ApplyConfiguration from an Existing Resource Watching Resources Errors and Statuses Definition of the metav1.Status Structure Error Returned by Clientset Operations RESTClient Building the Request Executing the Request Exploiting the Result Getting Result as a Table Discovery Client RESTMapper PriorityRESTMapper DeferredDiscoveryRESTMapper Conclusion Chapter 7: Testing Applications Using Client-go Fake Clientset Checking the Result of the Function Reacting to Actions Checking the Actions Fake REST Client FakeDiscovery Client Stubbing the ServerVersion Actions Mocking Resources Conclusion Chapter 8: Extending Kubernetes API with Custom Resources Definitions Performing Operations in Go The CustomResourceDefinition in Detail Naming the Resource Definition of the Resource Versions Converting Between Versions Schema of the Resource Deploying a Custom Resource Definition Additional Printer Columns Conclusion Chapter 9: Working with Custom Resources Generating a Clientset Using deepcopy-gen Installing deepcopy-gen Adding Annotations Running deepcopy-gen Using client-gen Installing client-go Adding Annotations Adding AddToScheme Function Running client-go Using the Generated Clientset Using the Generated fake Clientset Using the Unstructured Package and Dynamic Client The Unstructured Type Getters and Setters to Access TypeMeta Fields Getters and Setters to Access ObjectMeta Fields Methods for Creating and Converting Helpers to Access Non-meta Fields Example The UnstructuredList Type Getters and Setters to Access TypeMeta Fields Getters and Setters to Access ListMeta Fields Methods for Creating and Converting Converting Between Typed and Unstructured Objects The Dynamic Client Getting the dynamic Client Working with the dynamic Client Example The fake dynamic Client Conclusion Chapter 10: Writing Operators with the Controller-Runtime Library The Manager The Controller Creating a Controller Watching Resources A First Example Using the Controller Builder A Second Example Using the ControllerBuilder Injecting Manager Resources into the Reconciler Passing the Values When Creating the Reconciler Structure Using Injectors Using the Client Getting Information About a Resource Listing Resources Creating a Resource Deleting a Resource Deleting a Collection of Resources Updating a Resource Patching a Resource Server-side Apply Strategic Merge Patch Merge Patch Updating the Status of a Resource Patching the Status of a Resource Logging Verbosity Predefined Values Logger Name Getting the Logger from Context Events Conclusion Chapter 11: Writing the Reconcile Loop Writing the Reconcile Function Checking Whether the Resource Exists Implementing the Reconciled Resource Simple Implementation Example Conclusion Chapter 12: Testing the Reconcile Loop The envtest Package Installing envtest Binaries Using envtest Defining a ginkgo Suite Writing the Tests Test Test Test Test Conclusion Chapter 13: Creating an Operator with Kubebuilder Installing Kubebuilder Creating a Project Adding a Custom Resource to the Project Building and Deploying Manifests Running the Manager Locally Personalizing the Custom Resource Editing the Go Structures Enabling the Status Subresource Defining Printer Columns Regenerating the Files Implementing the Reconcile Function Adding RBAC Annotations Deploying the Operator on the Cluster Creating a New Version of the Resource Defining a New Version Implementing Hub and Convertible Setting Up the webhook Updating kustomization Files Using Various Versions Conclusion Index
How to download source code?
https://www.masiesdelpenedes.com/miymg471dd 1. Go to: https://github.com/Apress
source site 2. In the Find a repository… box, search the book title: Kubernetes Programming with Go: Programming Kubernetes Clients and Operators Using Go and the Kubernetes API
, sometime you may not get the results, please search the main title.
https://colvetmiranda.org/ityr5nd29c4 3. Click the book title in the search results.
3. Click Code to download.
1. Disable the source link AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.