Programming Kubernetes: Developing Cloud-Native Applications

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

If you’re looking to develop native applications in Kubernetes, this is your guide. Developers and AppOps administrators will learn how to build Kubernetes-native applications that interact directly with the API server to query or update the state of resources. AWS developer advocate Michael Hausenblas and Red Hat principal software engineer Stefan Schimanski explain the characteristics of these apps and show you how to program Kubernetes to build them.

You’ll explore the basic building blocks of Kubernetes, including the client-go API library and custom resources. All you need to get started is a rudimentary understanding of development and system administration tools and practices, such as package management, the Go programming language, and Git.

  • Walk through Kubernetes API basics and dive into the server’s inner structure
  • Explore Kubernetes’s programming interface in Go, including Kubernetes API objects
  • Learn about custom resources―the central extension tools used in the Kubernetes ecosystem
  • Use tags to control Kubernetes code generators for custom resources
  • Write custom controllers and operators and make them production ready
  • Extend the Kubernetes API surface by implementing a custom API server

Author(s): Michael Hausenblas, Stefan Schimanski
Edition: 1
Publisher: O'Reilly Media
Year: 2019

Language: English
Commentary: Publisher PDF | Published: July 2019 | Revision History: 2019-07-18: First Release
Pages: 270
City: Sebastopol, CA
Tags: DevOps; Cloud Computing; Deployment; Application Development; Go; Kubernetes; Automation; Git; Serverless Applications; Version Control Systems; Code Generation

Copyright
Table of Contents
Preface
Who Should Read This Book
Why We Wrote This Book
Ecosystem
Technology You Need to Understand
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Chapter 1. Introduction
What Does Programming Kubernetes Mean?
A Motivational Example
Extension Patterns
Controllers and Operators
The Control Loop
Events
Edge- Versus Level-Driven Triggers
Changing Cluster Objects or the External World
Optimistic Concurrency
Operators
Summary
Chapter 2. Kubernetes API Basics
The API Server
The HTTP Interface of the API Server
API Terminology
Kubernetes API Versioning
Declarative State Management
Using the API from the Command Line
How the API Server Processes Requests
Summary
Chapter 3. Basics of client-go
The Repositories
The Client Library
Kubernetes API Types
API Machinery
Creating and Using a Client
Versioning and Compatibility
API Versions and Compatibility Guarantees
Kubernetes Objects in Go
TypeMeta
ObjectMeta
spec and status
Client Sets
Status Subresources: UpdateStatus
Listings and Deletions
Watches
Client Expansion
Client Options
Informers and Caching
Work Queue
API Machinery in Depth
Kinds
Resources
REST Mapping
Scheme
Vendoring
glide
dep
Go Modules
Summary
Chapter 4. Using Custom Resources
Discovery Information
Type Definitions
Advanced Features of Custom Resources
Validating Custom Resources
Short Names and Categories
Printer Columns
Subresources
A Developer’s View on Custom Resources
Dynamic Client
Typed Clients
controller-runtime Client of Operator SDK and Kubebuilder
Summary
Chapter 5. Automating Code Generation
Why Code Generation
Calling the Generators
Controlling the Generators with Tags
Global Tags
Local Tags
deepcopy-gen Tags
runtime.Object and DeepCopyObject
client-gen Tags
informer-gen and lister-gen
Summary
Chapter 6. Solutions for Writing Operators
Preparation
Following sample-controller
Bootstrapping
Business Logic
Kubebuilder
Bootstrapping
Business Logic
The Operator SDK
Bootstrapping
Business Logic
Other Approaches
Uptake and Future Directions
Summary
Chapter 7. Shipping Controllers and Operators
Lifecycle Management and Packaging
Packaging: The Challenge
Helm
Kustomize
Other Packaging Options
Packaging Best Practices
Lifecycle Management
Production-Ready Deployments
Getting the Permissions Right
Automated Builds and Testing
Custom Controllers and Observability
Summary
Chapter 8. Custom API Servers
Use Cases for Custom API Servers
Example: A Pizza Restaurant
The Architecture: Aggregation
API Services
Inner Structure of a Custom API Server
Delegated Authentication and Trust
Delegated Authorization
Writing Custom API Servers
Options and Config Pattern and Startup Plumbing
The First Start
Internal Types and Conversion
Writing the API Types
Conversions
Defaulting
Roundtrip Testing
Validation
Registry and Strategy
API Installation
Admission
Deploying Custom API Servers
Deployment Manifests
Setting Up RBAC
Running the Custom API Server Insecurely
Certificates and Trust
Sharing etcd
Summary
Chapter 9. Advanced Custom Resources
Custom Resource Versioning
Revising the Pizza Restaurant
Conversion Webhook Architecture
Conversion Webhook Implementation
Setting Up the HTTPS Server
Deploying the Conversion Webhook
Seeing Conversion in Action
Admission Webhooks
Admission Requirements in the Restaurant Example
Admission Webhook Architecture
Registering Admission Webhooks
Implementing an Admission Webhook
Admission Webhook in Action
Structural Schemas and the Future of CustomResourceDefinitions
Structural Schemas
Pruning Versus Preserving Unknown Fields
Controlling Pruning
IntOrString and RawExtensions
Default Values
Summary
Appendix A. Resources
General
Books
Tutorials and Examples
Articles
Repositories
Index
About the Authors
Colophon