Skip to Content
Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition
book

Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

by Benjamin Muschko
January 2026
Intermediate to advanced
392 pages
4h 44m
Chinese
O'Reilly Media, Inc.
Content preview from Kubernetes 认证管理员 (CKA) 学习指南 (Chinese Edition), 2nd Edition

第7章 操作符与 自定义资源定义(CRDs)

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

Kubernetes 提供核心功能集,通过标准原语满足运行应用程序堆栈的基本需求。针对定制化场景,Kubernetes 允许安装平台扩展 ,即操作器

自定义资源定义(CRD) 是 Kubernetes 的扩展机制(通常与操作符捆绑),用于引入自定义 API 原语以满足内置原语无法覆盖的需求。

本章将重点介绍操作器的安装配置,以及与提供的CRD的交互方式。

操作符使用指南

操作员可在不修改Kubernetes核心代码的前提下扩展集群行为,可视为平台的插件组件。其通常自动化执行原本需人工操作的任务,如应用程序的部署、配置、扩展、升级及管理。

操作符模式

操作器( )通常由多个组件构成:一个或多个CRD、控制器,以及权限控制所需的RBAC规则等附加组件。CRD可视为定义自定义对象蓝图的模式,通过该模式实例化的新类型对象即称为自定义资源(CR)。

CRD 要发挥作用,必须由控制器提供支持。控制器通过与 Kubernetes API 交互,实现与 CRD 对象交互的协调逻辑。

CRD与控制器的组合通常称为操作模式operator pattern)。考试不要求考生理解控制器,因此本章不会涉及控制器的实现细节。

图7-1展示了包含所有动态组件的操作模式。

Diagram illustrating the Kubernetes operator pattern, showing the interaction between user-defined schema, CRD-typed objects, controllers, and the Kubernetes API.
图 7-1. Kubernetes 操作员模式

探索操作器

Kubernetes 社区已在OperatorHub.ioArtifact Hub 上实现了众多实用操作器( )。

其中外部密钥管理器 是知名操作程序,可协助集成Amazon Web Services (AWS) Secrets Manager和HashiCorp Vault等外部密钥管理工具与Kubernetes。另一款 是Crossplane操作程序,支持通过声明式语法创建和管理云资源。

为演示OperatorHub.io的功能,我们将搜索并安装广受欢迎的Argo CD操作员 。该操作员是面向Kubernetes的声明式GitOps持续交付工具,通过持续监控应用程序并将其与Git仓库中定义的预期状态同步,实现部署自动化。

在浏览器中打开OperatorHub.io网址,在名为"Search OperatorHub"的搜索框中输入"argo cd"。您将获得如图7-2所示的搜索结果。

Search results for "Argo CD" on OperatorHub.io, showing options for Argo CD and Argo CD Operator (Helm).
图 7-2. OperatorHub.io 上的搜索结果

点击ArgoCD面板将跳转至Argo CD Operator详情页如图7-3所示)。

该页面描述了该操作员的功能,包括对所提供 CRD 的概述。要能够从 CRD 创建 CR,我们首先需要安装该操作员。

图 7-3. OperatorHub.io 上的 Argo CD 操作员

操作员安装

多数操作员可通过单条kubectl命令或Helm可执行程序安装。有关Helm的使用详情,请参阅 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Kubernetes 上的生成式人工智能 (Chinese Edition)

Kubernetes 上的生成式人工智能 (Chinese Edition)

Roland Huß, Daniele Zonca
游戏化头脑风暴

游戏化头脑风暴

Dave Gray, Sunni Brown, James Macanufo

Publisher Resources

ISBN: 0642572314712