Skip to Content
Kubernetes即学即用(第二版)
book

Kubernetes即学即用(第二版)

by Brendan Burns, Joe Beda, Kelsey Hightower
June 2021
Intermediate to advanced
300 pages
5h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes即学即用(第二版)
存储解决方案与
Kubernetes
的集成
223
尽管这种方法类似于我们前面介绍的可靠单例,但由于状态集复制了多个
Pod
,因此你不能简单地引用持久卷声明。你需要添加一个持久卷声明模板。
你可以认为这个模板与
Pod
模板相同,只不过它创建的不是
Pod
,而是持久
卷声明。你需要在状态集末尾添加以下内容:
volumeClaimTemplates:
- metadata:
name: database
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 100Gi
将卷声明模板添加到状态集的定义中后,每次状态集控制器创建一个属于状
态集的
Pod
时,就会根据这个模板创建一个持久卷声明(作为该
Pod
的一部分)。
为了让这些复制的的持久卷正常工作,你需要为持久卷设置自动供应,或者
也可以预先填充好一组持久卷对象供状态集控制器提取。如果没有声明如何
创建这些持久卷,则状态集控制器无法创建相应的
Pod
15.3.5
最后一步:存活探针
MongoDB
集群推入生产的最后一步是在
Mongo
服务的容器中添加存活探
针。
5.6
节曾介绍过,我们可以通过存活探针确认容器是否正常运行。为了执
行存活检查,我们可以在状态集对象的
Pod
模板中添加以下内容:
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.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
Python数据分析

Python数据分析

Posts & Telecom Press, Ivan Idris
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé

Publisher Resources

ISBN: 9787519856762