Skip to Content
Kubernetes编程
book

Kubernetes编程

by Michael Hausenblas, Stefan Schimanski
June 2021
Intermediate to advanced
335 pages
5h 50m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes编程
100
4
注意,其中的有些字段在
CRD
创建后很久仍可能会发生变化。比如你可以
为这个资源添加一个短名或者一个新的字段。在这种情况下,
API
服务器仍
可以通过原来的名字为这个
CRD
提供服务,即使新旧名字间存在冲突。这
NamesAccepted
条件字段的状态为变成
False
,并且
spec
字段中的名字和
NamesAccepted
中体现的名字可能会是不同的。
4.3
自定义资源的高级功能
在这一节中,我们讨论自定义资源的一些高级功能,包括合法性验证和子资源。
4.3.1
自定义资源合法性验证
在创建和更新
CR
时,会由
API
服务器进行合法性验证,该验证基于
CRD
义中的
validation
字段所指定的
OpenAPI v3 Schema
进行。
当一个请求要创建或修改
CR
时,会基于这个资源定义对
JSON
格式的对象进
行合法性验证,如果有问题,会给用户返回
HTTP
400
,结果中包含发生冲突
的字段。从图
4-2
中可知,验证过程是由
apiextensions-apiserver
中的请
求处理器进行的。
如果需要更复杂的验证,可以通过实现准入
Webhook
来做到,
Webhook
以用图灵完备的编程语言来完成。从图
4-2
中可见,这些
Webhook
会在基于
OpenAPI
的验证逻辑完成后被立即调用。在“
9.2
准入
Webhook
”中,我们将
学习如何实现和部署准入
Webhook
。届时我们会看到如何去基于其他资源进
行验证,从而实现远远超越
OpenAPI v3
所能提供的验证功能。幸运的是,大
部分情况下,使用
OpenAPI ...
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

解密金融数据

解密金融数据

Justin Pauley
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu
软件开发实践:项目驱动式的Java开发指南

软件开发实践:项目驱动式的Java开发指南

Raoul-Gabriel Urma, Richard Warburton

Publisher Resources

ISBN: 9787519854799