O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Kubernetes Operators

Book Description

Operators are a way of packaging, deploying, and managing Kubernetes applications. A Kubernetes application doesn’t just run on Kubernetes; it’s composed and managed in Kubernetes terms. Operators add application-specific operational knowledge to a Kubernetes cluster, making it easier to automate complex, stateful applications and to augment the platform. Operators can coordinate application upgrades seamlessly, react to failures automatically, and streamline repetitive maintenance like backups.

Think of Operators as site reliability engineers in software. They work by extending the Kubernetes control plane and API, helping systems integrators, cluster administrators, and application developers reliably deploy and manage key services and components. Using real-world examples, authors Jason Dobies and Joshua Wood demonstrate how to use Operators today and how to create Operators for your applications with the Operator Framework and SDK.

  • Learn how to establish a Kubernetes cluster and deploy an Operator
  • Examine a range of Operators from usage to implementation
  • Explore the three pillars of the Operator Framework: the Operator SDK, the Operator Lifecycle Manager, and Operator Metering
  • Build Operators from the ground up using the Operator SDK
  • Build, package, and run an Operator in development, testing, and production phases
  • Learn how to distribute your Operator for installation on Kubernetes clusters

Table of Contents

  1. Preface
    1. Who This Book Is For
    2. What You Will Learn
      1. Operator Framework and SDK
      2. Other Operator Tools
    3. Conventions Used in This Book
    4. Using Code Examples
    5. O’Reilly Online Learning
    6. How to Contact Us
    7. Acknowledgments
  2. 1. Operators Teach Kubernetes New Tricks
    1. How Kubernetes Works
    2. Example: Stateless Web Server
    3. Stateful is Hard
    4. Operators are Software SREs
    5. How Operators Work
      1. Kubernetes Custom Resources
    6. How Operators are Made
    7. Example: The etcd Operator
      1. The Case of the Missing Member
    8. Who are Operators for?
    9. Operator Adoption
    10. Let’s Get Going
  3. 2. Running Operators
    1. Setting Up an Operator Lab
      1. Cluster Version Requirements
      2. Authorization Requirements
      3. Standard Tools and Techniques
      4. Suggested Cluster Configurations
      5. Check Cluster Version
      6. Ready to Run Operators
    2. Running a Simple Operator
      1. A Common Starting Point
      2. Fetch etcd Operator Manifests
      3. Custom Resources: Custom API Endpoints
      4. Who Am I: Defining an Operator Service Account
      5. Etcd Operator Deployment
      6. Declare an etcd Cluster
      7. Exercise etcd
      8. Scale etcd cluster
      9. Failure and Automated Recovery
      10. Upgrading Etcd Clusters
      11. Cleaning Up
    3. Summary
  4. 3. Operators at the Kubernetes Interface
    1. Standard Scaling: The ReplicaSet Resource
    2. Custom Resources
      1. Custom Resource or ConfigMap?
    3. Custom Controllers
    4. Operator Scopes
      1. Namespace Scope
      2. Cluster-Scoped Operators
    5. Authorization
      1. Service Accounts
      2. Roles
      3. RoleBinding
      4. ClusterRole and ClusterRoleBinding
    6. Summary
  5. 4. The Operator Framework
    1. Operator Framework Origins
    2. Operator Maturity Model
    3. Operator SDK
      1. Installing the Operator SDK tool
    4. Operator Lifecycle Manager
    5. Operator Metering
    6. Summary
  6. 5. Sample Application: Visitors Site
    1. Application Overview
    2. Installation with Manifests
      1. Deploying MySQL
      2. Backend
      3. Frontend
    3. Deploying the Manifests
    4. Accessing the Visitors Site
    5. Clean Up
    6. Summary
  7. 6. Adapter Operators
    1. Helm Operator
      1. Building the Operator
      2. Flush Out the Custom Resource Definition
      3. Review Operator Permissions
      4. Running the Helm Operator
    2. Ansible Operator
      1. Building the Operator
      2. Flush Out the Custom Resource Definition
      3. Review Operator Permissions
      4. Running the Ansible Operator
    3. Testing an Operator
    4. Summary
    5. Resources
  8. 7. Operators in Go with the Operator SDK
    1. Initializing the Operator
    2. Operator Scope
    3. Custom Resource Definitions
      1. Define the Go Types
      2. Custom Resource Definition Manifest
    4. Operator Permissions
    5. Controller
      1. The Reconcile Function
    6. Operator Writing Tips
      1. Retrieving the Resource
      2. Child Resource Creation
      3. Child Resource Deletion
      4. Child Resource Naming
      5. Idempotency
      6. Operator Impact
    7. Running an Operator Locally
    8. Visitors Site Example
    9. Summary
    10. Resources
  9. 8. Operator Lifecycle Manager
    1. OLM Custom Resources
      1. ClusterServiceVersion
      2. CatalogSource
      3. Subscription
      4. InstallPlan
      5. OperatorGroup
    2. Installing OLM
    3. Using OLM
      1. Exploring the Operator
      2. Deleting the Operator
    4. OLM Bundle Metadata Files
    5. Writing a Cluster Service Version File
      1. Generate a File Skeleton
      2. Metadata
      3. Owned CRDs
      4. Required CRDs
      5. Install Modes
      6. Versioning and Updating
    6. Writing a Package Manifest File
    7. Running Locally
      1. Prerequisites
      2. Building the OLM Bundle
      3. Installing the Operator through OLM
      4. Testing the Running Operator
    8. Visitors Site Operator Example
    9. Summary
    10. Resources
  10. 9. Operator Philosophy
    1. SRE for Every Application
    2. Toil Not, Neither Spin
      1. Automatable: Work Your Computer Would Like
      2. Running in Place: Work of No Enduring Value
      3. Growing Pains: Work That Expands with the System
    3. Operators: Kubernetes Application Reliability Engineering
      1. Managing Application State
      2. Golden Signals Sent to Software
    4. Seven Habits of Highly Successful Operators
    5. Summary
  11. 10. Getting Involved
    1. Feature Requests & Reporting Bugs
    2. Contributing
    3. Sharing Operators
    4. Summary
  12. A. Running an Operator as a Deployment Inside a Cluster
  13. B. Custom Resource Validation
  14. C. Role-based Access Control (RBAC)
    1. Fine-Tuning the Role