kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: default-mongo-pvc
namespace: default
labels:
dir: default-mongo
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 500Mi
storageClassName: nfs-subdir-client //需安装nfs-client插件
volumeMode: Filesystem
---
kind: ConfigMap
metadata:
name: mongodb-conf
namespace: default
apiVersion: v1
data:
mongod.conf: |-
#dbpath=/mongo/data
#logpath=/mongo/log/mongodb.log
#pidfilepath=/mongo/key/master.pid
directoryperdb=true
logappend=true
bind_ip=0.0.0.0
port=27017
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo-1
namespace: default
app: mongo-cluster
spec:
selector:
matchLabels:
name: mongo-1
serviceName: "mongo-1"
replicas: 1
podManagementPolicy: Parallel
template:
metadata:
labels:
name: mongo-1
app: mongo-cluster
spec:
terminationGracePeriodSeconds: 10
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "name"
operator: In
values:
- mongo
topologyKey: "kubernetes.io/hostname"
containers:
- name: mongo
image: mongo:4.2
imagePullPolicy: IfNotPresent
command:
- mongod
- "-f"
- "/etc/mongod.conf"
- "--bind_ip_all"
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-cnf-volume
mountPath: /etc/mongod.conf/
subPath: mongod.conf
- name: mongo-dir
mountPath: /mongo
volumes:
- name: mongo-cnf-volume #映射configMap信息
configMap:
name: mongodb-conf
items:
- key: mongod.conf
path: mongod.conf
- name: mongo-dir
persistentVolumeClaim:
claimName: default-mongo-pvc
---
kind: Service
apiVersion: v1
metadata:
name: mongo
namespace: default
spec:
ports:
- protocol: TCP
port: 37017
targetPort: 27017
selector:
name: mongo-1
type: LoadBalancer
k8s一键部署单节点mongo
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...