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编程
26
1
假设控制器需要几秒钟时间来完成相关的更新动作。
7
秒后,它尝试去更新
Pod
的对象,比如,去设置一个注解。与此同时,
kubelet
发现另一个容器被重
启了,所以它修改了
Pod
对象的状态,这时
resourceVersion
增长到了
58
你的控制器所发出的更新请求中还是写着
resourceVersion: 57
API
服务器
会尝试按这个版本值去设置
etcd
中的值。
etcd
发现这个资源版本已经与自己
所保存的版本不一致,这次更新操作就失败了。
在这个例子中,所有处理逻辑的底线就是,你需要负责在你的控制器中实
现重试的策略以便处理乐观操作失败的情况。你永远也无法预知是否有人
在你之前改变对象的状态,它有可能是另一个自定义的控制器,也可能是
Kubernetes
中的某个核心控制器(比如
Deployment
控制器)。
以上逻辑的核心就是,对于控制器来说,遇到冲突的场景完全是预期之内的,
所以必须正确面对冲突的场景并正确对其进行处理
还需要指出的一点是乐观并发对于基于水平驱动的逻辑来说非常合理,因为
使用水平驱动逻辑,可以随时重新运行控制循环(参考
1.4.3
“边沿触发与水
平触发”)。重新运行控制循环时,就会把上一次因为乐观更新失效而没完
成的操作撤消,并重新按照最新的状态来更新外部状态。
下面我们来看一类特定的自定义控制器(包含自定义资源):
Operator
1.4.6 Operator
Kubernetes
中的
Operator
是一个由
CoreOS
2016
年引入的概念。在
CoreOS
CTO Brandon ...
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