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编程
20
1
有关各种检测状态变化并对其进行响应的模式的讨论先到这里。图
1-2
中控
制循环的下一步是按照规格改变集群对象或改变外部系统的状态。我们一起
来了解一下。
1.4.4
改变集群对象或外部系统状态
在这个阶段中,控制器会改变它所管理的对象的状态。比如,控制器管理器
中的
ReplicaSet
控制器会管理一些
Pod
。当事件发生(边沿触发),它会获
取所管理的
Pod
对象的状态
,并把这些状态与期望的状态进行比较(水平驱
动)。
由于修改资源的状态是一个领域或任务相关的工作,我们很难给出通用的指
导意见。不过我们继续以
ReplicaSet
控制器作为例子来了解其相关的细节。
Deployment
中会使用
ReplicaSet
,其控制器的核心逻辑是:按用户指定的数
量,维护一组相同的
Pod
副本。也就是说,当前运行的
Pod
副本数小于用户
指定值时(比如由于
Pod
运行出错或用户增加了期望的副本数),控制器就
会启动新的
Pod
。如果当前运行中的
Pod
数太多了,它需要终止其中的一部分。
这个控制器的所有逻辑都在
replicat_set.go
包中。下面是处理状态相关的
逻辑的代码片段(进行了一些修改以确保清晰可读):
// manageReplicas checks and updates replicas for the given ReplicaSet.
// It does NOT modify <filteredPods>.
// It will requeue the replica set in case of
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