#vim mongodb-sharded-cluster-Secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: mongodb-sharded-cluster
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: mongodb
type: Opaque
data:
# root密码S95W8OF7rf
mongodb-root-password: "Uzk1VzhPRjdyZg=="
mongodb-replica-set-key: "MkRkQlFRenI4TA=="
---
#vim mongodb-sharded-cluster-ConfigMap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: mongodb-sharded-cluster-replicaset-entrypoint
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
data:
replicaset-entrypoint.sh: |-
#!/bin/bash
sleep 5
. /liblog.sh
# Perform adaptations depending on the host name
if [[ $HOSTNAME =~ (.*)-0$ ]]; then
info "Setting node as primary"
export MONGODB_REPLICA_SET_MODE=primary
else
info "Setting node as secondary"
export MONGODB_REPLICA_SET_MODE=secondary
export MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD="$MONGODB_ROOT_PASSWORD"
unset MONGODB_ROOT_PASSWORD
fi
exec /entrypoint.sh /run.sh
---
# vim mongodb-sharded-cluster-headless.yaml
apiVersion: v1
kind: Service
metadata:
name: mongodb-sharded-cluster-headless
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
annotations:
{}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: mongodb
port: 27017
selector:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
---
# vim mongodb-sharded-cluster-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: mongodb-sharded-cluster
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: mongos
annotations:
{}
spec:
type: ClusterIP
ports:
- name: mongodb
port: 27017
targetPort: mongodb
nodePort: null
selector:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: mongos
sessionAffinity: None
---
# vim mongos-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb-sharded-cluster-mongos
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: mongos
spec:
strategy:
type: RollingUpdate
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: mongos
template:
metadata:
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: mongos
spec:
serviceAccountName: "default"
affinity:
podAffinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: mongos
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity:
securityContext:
fsGroup: 1001
containers:
- name: mongos
image: hub.kce.ksyun.com/leoxinyuan/mongodb-sharded:6.0.1-debian-11-r0
imagePullPolicy: "IfNotPresent"
securityContext:
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
env:
- name: MONGODB_ENABLE_NUMACTL
value: "no"
- name: BITNAMI_DEBUG
value: "false"
- name: MONGODB_SHARDING_MODE
value: "mongos"
- name: MONGODB_MAX_TIMEOUT
value: "120"
- name: MONGODB_ROOT_USER
value: "root"
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-replica-set-key
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_ADVERTISED_HOSTNAME
value: "$(MONGODB_POD_NAME)"
- name: MONGODB_PORT_NUMBER
value: "27017"
- name: MONGODB_CFG_PRIMARY_HOST
value: mongodb-sharded-cluster-configsvr-0.mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_CFG_REPLICA_SET_NAME
value: mongodb-sharded-cluster-configsvr
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: "0"
- name: MONGODB_DISABLE_SYSTEM_LOG
value: "no"
- name: MONGODB_ENABLE_IPV6
value: "no"
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
value: "no"
ports:
- name: mongodb
containerPort: 27017
livenessProbe:
failureThreshold: 2
initialDelaySeconds: 60
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
---
# vim config-server-statefulset.yaml
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb-sharded-cluster-configsvr
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: configsvr
spec:
selector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: configsvr
serviceName: mongodb-sharded-cluster-headless
replicas: 3
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: configsvr
spec:
serviceAccountName: "default"
affinity:
podAffinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: configsvr
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity:
securityContext:
fsGroup: 1001
initContainers:
containers:
- name: mongodb
image: hub.kce.ksyun.com/leoxinyuan/mongodb-sharded:6.0.1-debian-11-r0
imagePullPolicy: IfNotPresent
securityContext:
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
ports:
- containerPort: 27017
name: mongodb
env:
- name: MONGODB_ENABLE_NUMACTL
value: "no"
- name: BITNAMI_DEBUG
value: "false"
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: "0"
- name: MONGODB_DISABLE_SYSTEM_LOG
value: "no"
- name: MONGODB_MAX_TIMEOUT
value: "120"
- name: MONGODB_SHARDING_MODE
value: "configsvr"
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_PORT_NUMBER
value: "27017"
- name: MONGODB_INITIAL_PRIMARY_HOST
value: mongodb-sharded-cluster-configsvr-0.mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_REPLICA_SET_NAME
value: mongodb-sharded-cluster-configsvr
- name: MONGODB_ADVERTISED_HOSTNAME
value: $(MONGODB_POD_NAME).mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_ROOT_USER
value: "root"
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-replica-set-key
- name: MONGODB_ENABLE_IPV6
value: "no"
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
value: "no"
command:
- /bin/bash
- /entrypoint/replicaset-entrypoint.sh
livenessProbe:
failureThreshold: 2
initialDelaySeconds: 60
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- pgrep
- mongod
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
startupProbe:
failureThreshold: 30
initialDelaySeconds: 0
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
tcpSocket:
port: mongodb
volumeMounts:
- name: replicaset-entrypoint-configmap
mountPath: /entrypoint
- name: datadir
mountPath: /bitnami/mongodb
resources:
{}
volumes:
- name: replicaset-entrypoint-configmap
configMap:
name: mongodb-sharded-cluster-replicaset-entrypoint
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "8Gi"
storageClassName: gluster-storageclass
---
# vim shard-data-statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb-sharded-cluster-shard0-data
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: shardsvr
spec:
selector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: shardsvr
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
serviceName: mongodb-sharded-cluster-headless
replicas: 2
template:
metadata:
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: shardsvr
shard: "0"
spec:
affinity:
podAffinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: shardsvr
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity:
serviceAccountName: "default"
securityContext:
fsGroup: 1001
initContainers:
containers:
- name: mongodb
image: hub.kce.ksyun.com/leoxinyuan/mongodb-sharded:6.0.1-debian-11-r0
imagePullPolicy: IfNotPresent
securityContext:
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
ports:
- containerPort: 27017
name: mongodb
env:
- name: MONGODB_ENABLE_NUMACTL
value: "no"
- name: BITNAMI_DEBUG
value: "false"
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: "0"
- name: MONGODB_MAX_TIMEOUT
value: "120"
- name: MONGODB_DISABLE_SYSTEM_LOG
value: "no"
- name: MONGODB_PORT_NUMBER
value: "27017"
- name: MONGODB_SHARDING_MODE
value: "shardsvr"
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_MONGOS_HOST
value: mongodb-sharded-cluster
- name: MONGODB_MONGOS_PORT_NUMBER
value: "27017"
- name: MONGODB_INITIAL_PRIMARY_HOST
value: mongodb-sharded-cluster-shard0-data-0.mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_REPLICA_SET_NAME
value: mongodb-sharded-cluster-shard-0
- name: MONGODB_ADVERTISED_HOSTNAME
value: $(MONGODB_POD_NAME).mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_ROOT_USER
value: "root"
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-replica-set-key
- name: MONGODB_ENABLE_IPV6
value: "no"
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
value: "no"
command:
- /bin/bash
- /entrypoint/replicaset-entrypoint.sh
livenessProbe:
failureThreshold: 2
initialDelaySeconds: 60
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- pgrep
- mongod
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
volumeMounts:
- name: replicaset-entrypoint-configmap
mountPath: /entrypoint
- name: datadir
mountPath: /bitnami/mongodb
resources:
{}
volumes:
- name: replicaset-entrypoint-configmap
configMap:
name: mongodb-sharded-cluster-replicaset-entrypoint
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "8Gi"
storageClassName: gluster-storageclass
---
#
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb-sharded-cluster-shard1-data
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: shardsvr
spec:
selector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: shardsvr
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
serviceName: mongodb-sharded-cluster-headless
replicas: 2
template:
metadata:
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: shardsvr
shard: "1"
spec:
affinity:
podAffinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: shardsvr
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity:
serviceAccountName: "default"
securityContext:
fsGroup: 1001
initContainers:
containers:
- name: mongodb
image: hub.kce.ksyun.com/leoxinyuan/mongodb-sharded:6.0.1-debian-11-r0
imagePullPolicy: IfNotPresent
securityContext:
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
ports:
- containerPort: 27017
name: mongodb
env:
- name: MONGODB_ENABLE_NUMACTL
value: "no"
- name: BITNAMI_DEBUG
value: "false"
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: "0"
- name: MONGODB_MAX_TIMEOUT
value: "120"
- name: MONGODB_DISABLE_SYSTEM_LOG
value: "no"
- name: MONGODB_PORT_NUMBER
value: "27017"
- name: MONGODB_SHARDING_MODE
value: "shardsvr"
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_MONGOS_HOST
value: mongodb-sharded-cluster
- name: MONGODB_MONGOS_PORT_NUMBER
value: "27017"
- name: MONGODB_INITIAL_PRIMARY_HOST
value: mongodb-sharded-cluster-shard1-data-0.mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_REPLICA_SET_NAME
value: mongodb-sharded-cluster-shard-1
- name: MONGODB_ADVERTISED_HOSTNAME
value: $(MONGODB_POD_NAME).mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_ROOT_USER
value: "root"
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-replica-set-key
- name: MONGODB_ENABLE_IPV6
value: "no"
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
value: "no"
command:
- /bin/bash
- /entrypoint/replicaset-entrypoint.sh
livenessProbe:
failureThreshold: 2
initialDelaySeconds: 60
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- pgrep
- mongod
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
volumeMounts:
- name: replicaset-entrypoint-configmap
mountPath: /entrypoint
- name: datadir
mountPath: /bitnami/mongodb
resources:
{}
volumes:
- name: replicaset-entrypoint-configmap
configMap:
name: mongodb-sharded-cluster-replicaset-entrypoint
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "8Gi"
storageClassName: gluster-storageclass
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb-sharded-cluster-shard2-data
namespace: "default"
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: shardsvr
spec:
selector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: shardsvr
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
serviceName: mongodb-sharded-cluster-headless
replicas: 2
template:
metadata:
labels:
app.kubernetes.io/name: mongodb-sharded
helm.sh/chart: mongodb-sharded-6.0.3
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: shardsvr
shard: "2"
spec:
affinity:
podAffinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchLabels:
app.kubernetes.io/name: mongodb-sharded
app.kubernetes.io/instance: mongodb-sharded-cluster
app.kubernetes.io/component: shardsvr
namespaces:
- "default"
topologyKey: kubernetes.io/hostname
weight: 1
nodeAffinity:
serviceAccountName: "default"
securityContext:
fsGroup: 1001
initContainers:
containers:
- name: mongodb
image: hub.kce.ksyun.com/leoxinyuan/mongodb-sharded:6.0.1-debian-11-r0
imagePullPolicy: IfNotPresent
securityContext:
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1001
ports:
- containerPort: 27017
name: mongodb
env:
- name: MONGODB_ENABLE_NUMACTL
value: "no"
- name: BITNAMI_DEBUG
value: "false"
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: "0"
- name: MONGODB_MAX_TIMEOUT
value: "120"
- name: MONGODB_DISABLE_SYSTEM_LOG
value: "no"
- name: MONGODB_PORT_NUMBER
value: "27017"
- name: MONGODB_SHARDING_MODE
value: "shardsvr"
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MONGODB_MONGOS_HOST
value: mongodb-sharded-cluster
- name: MONGODB_MONGOS_PORT_NUMBER
value: "27017"
- name: MONGODB_INITIAL_PRIMARY_HOST
value: mongodb-sharded-cluster-shard2-data-0.mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_REPLICA_SET_NAME
value: mongodb-sharded-cluster-shard-2
- name: MONGODB_ADVERTISED_HOSTNAME
value: $(MONGODB_POD_NAME).mongodb-sharded-cluster-headless.default.svc.cluster.local
- name: MONGODB_ROOT_USER
value: "root"
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: mongodb-sharded-cluster
key: mongodb-replica-set-key
- name: MONGODB_ENABLE_IPV6
value: "no"
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
value: "no"
command:
- /bin/bash
- /entrypoint/replicaset-entrypoint.sh
livenessProbe:
failureThreshold: 2
initialDelaySeconds: 60
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- pgrep
- mongod
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 20
exec:
command:
- /bin/sh
- -c
- mongosh --port $MONGODB_PORT_NUMBER --eval "db.adminCommand('ping')"
volumeMounts:
- name: replicaset-entrypoint-configmap
mountPath: /entrypoint
- name: datadir
mountPath: /bitnami/mongodb
resources:
{}
volumes:
- name: replicaset-entrypoint-configmap
configMap:
name: mongodb-sharded-cluster-replicaset-entrypoint
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: "8Gi"
storageClassName: gluster-storageclass
---
原文链接:K8s-K8S部署MongoDB6.0分片集群
搜集用于学习