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编程
224
8
s.Meta().Context
它同时也允许我们通过
s.Convert
为子类型调用
Scheme
的转换函数,或者不
考虑注册的转换函数直接通过
s.DefaultConvert
进行转换。
在大部分的转换场景,都完全无须指定转换范围。简单起见,你可以完全忽
略它的存在,只有当你遇到了一个复杂的问题,必须要获取源和目标对象的
上下文时再使用它。
8.4.6
默认值处理
默认值处理是
API
生命周期里给对象(来自客户端或者
etcd
)中缺失的字段
填充默认值的步骤。例如,
Pod
有个
restartPolicy
字段。如果用户不指定该值,
该字段将默认填充
Always
假设我们在使用一个
2014
年时的旧版本
Kubernetes
restartPolicy
字段是
当时最新发布的版本引入到系统中的。在你的集群进行了一次升级后,
etcd
里有个
Pod
对象并没有
restartPolicy
字段。执行
kubectl get pod
将从
etcd
读取到老的
Pod
对象,然后默认值处理代码将会添加默认值
Always
。从
用户的视角来看,老
Pod
突然神奇地有了新的
restartPolicy
字段值。
参考图
8-6
了解现在的
Kubernetes
中,在请求处理流程中默认值处理逻辑发
生的位置。注意默认值处理只会作用于外部类型,而不会作用于内部类型。
现在让我们看一看默认值处理的代码。默认值处理是
k8s.io/apiserver
通过
Scheme
进行初始化的,类似转换。因此,我们也需要在
Scheme
中为我们的
自定义类型注册默认值处理函数。 ...
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