github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/applications/mongodb/README.md (about) 1 # Overview 2 3 This image chooses OpenEBS Jiva as its persistence storage engine. 4 5 Components included in this image: 6 7 * 1 StatefulSet with 2 replicas for mongodb which requests "50Gi" storage. 8 * 1 StatefulSet with 1 replica for mongodb arbiter. 9 10 ## How to use it 11 12 MongoDB® can be accessed on the following DNS name(s) and ports from within your cluster: 13 14 ``` 15 my-mongodb-0.my-mongodb-headless.mongodb-system.svc.cluster.local:27017 16 my-mongodb-1.my-mongodb-headless.mongodb-system.svc.cluster.local:27017 17 ``` 18 19 To get the root password run: 20 21 ``` 22 export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace mongodb-system my-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode) 23 ``` 24 25 To connect to your database, create a MongoDB® client container: 26 27 ``` 28 kubectl run --namespace mongodb-system my-mongodb-client --rm --tty -i --restart='Never' --env="MONGODB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD" --image docker.io/bitnami/mongodb:4.4.8-debian-10-r9 --command -- bash 29 ``` 30 31 Then, run the following command: 32 33 ``` 34 mongo admin --host "my-mongodb-0.my-mongodb-headless.mongodb-system.svc.cluster.local: 35 27017,my-mongodb-1.my-mongodb-headless.mongodb-system.svc.cluster.local:27017" --authenticationDatabase admin -u root -p 36 $MONGODB_ROOT_PASSWORD 37 ``` 38 39 ## How to rebuild it use helm 40 41 Kubefile: 42 43 ```shell 44 FROM registry.cn-qingdao.aliyuncs.com/sealer-apps/openebs-jiva:2.11.0 45 # add helm repo and run helm install 46 RUN helm repo add bitnami https://charts.bitnami.com/bitnami 47 # set persistence.storageClass=openebs-jiva-csi-sc, which is provided by base image openebs-jiva:2.11.0. 48 CMD helm install my-mongodb --set architecture=replication --create-namespace --namespace mongodb-system --set global.storageClass=openebs-jiva-csi-sc bitnami/mongodb --version 10.25.1 49 ``` 50 51 run below command to build it 52 53 ```shell 54 sealer build -t {Your Image Name} -f Kubefile -m cloud . 55 ``` 56 57 More parameters see [official document here](https://artifacthub.io/packages/helm/bitnami/mongodb).