# This container initializes the mongodb server, then sleeps.
- name: init-mongo
image: mongo:3.4.1
command:
- bash
- /config/init.sh
volumeMounts:
- name: config
mountPath: /config
volumes:
- name: config
configMap:
name: "mongo-init"
有了所有这些文件后,我们就可以使用以下命令创建一个
Mongo
集群:
$
kubectl apply -f mongo-config-map.yaml
$
kubectl apply -f mongo-service.yaml
$
kubectl apply -f mongo.yaml
如有需要,你也可以将它们合并到一个
YAML
文件中,不要忘记利用
---
来
分隔各个对象。确保各个对象之间的顺序保持不变,因为状态集的定义要求
ConfigMap
定义必须存在。
15.3.4
持久卷与状态集
对于持久性存储,你需要将持久卷挂载到
/data/db
目录中。你需要修改 ...
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.