Simpler MongoDB Instance Configuration in K8s (#1678)

* Simpler configuration of MongoDB instance in a node

* Update docs for MDB configuration
This commit is contained in:
Krish 2017-07-17 17:57:13 +02:00 committed by GitHub
parent 9116836e4c
commit e0efc2286a
4 changed files with 24 additions and 8 deletions

View File

@ -234,6 +234,11 @@ Step 6: Start the MongoDB Kubernetes Service
``mdb-instance-name`` is ``mdb-instance-0``, set the ``mdb-instance-name`` is ``mdb-instance-0``, set the
``spec.selector.app`` to ``mdb-instance-0-ss``. ``spec.selector.app`` to ``mdb-instance-0-ss``.
* Set ``ports[0].port`` and ``ports[0].targetPort`` to the value set in the
``mongodb-backend-port`` in the ConfigMap above.
This is the ``mdb-port`` in the file which specifies where MongoDB listens
for API requests.
* Start the Kubernetes Service: * Start the Kubernetes Service:
.. code:: bash .. code:: bash
@ -491,6 +496,11 @@ Step 12: Start a Kubernetes StatefulSet for MongoDB
* As we gain more experience running MongoDB in testing and production, we * As we gain more experience running MongoDB in testing and production, we
will tweak the ``resources.limits.cpu`` and ``resources.limits.memory``. will tweak the ``resources.limits.cpu`` and ``resources.limits.memory``.
* Set the ports to be exposed from the pod in the
``spec.containers[0].ports`` section. We currently only expose the MongoDB
backend port. Set it to the value specified for ``mongodb-backend-port``
in the ConfigMap.
* Create the MongoDB StatefulSet using: * Create the MongoDB StatefulSet using:
.. code:: bash .. code:: bash

View File

@ -12,8 +12,10 @@ spec:
- port: "<bigchaindb-api-port from ConfigMap>" - port: "<bigchaindb-api-port from ConfigMap>"
targetPort: "<bigchaindb-api-port from ConfigMap>" targetPort: "<bigchaindb-api-port from ConfigMap>"
name: bdb-api-port name: bdb-api-port
protocol: TCP
- port: "<bigchaindb-ws-port from ConfigMap>" - port: "<bigchaindb-ws-port from ConfigMap>"
targetPort: "<bigchaindb-ws-port from ConfigMap>" targetPort: "<bigchaindb-ws-port from ConfigMap>"
name: bdb-ws-port name: bdb-ws-port
protocol: TCP
type: ClusterIP type: ClusterIP
clusterIP: None clusterIP: None

View File

@ -39,7 +39,10 @@ spec:
name: vars name: vars
key: mongodb-replicaset-name key: mongodb-replicaset-name
- name: MONGODB_PORT - name: MONGODB_PORT
value: "27017" valueFrom:
configMapKeyRef:
name: vars
key: mongodb-backend-port
args: args:
- --mongodb-port - --mongodb-port
- $(MONGODB_PORT) - $(MONGODB_PORT)
@ -60,10 +63,9 @@ spec:
add: add:
- FOWNER - FOWNER
ports: ports:
- containerPort: 27017 - containerPort: "<mongodb-backend-port from ConfigMap>"
hostPort: 27017
name: mdb-port
protocol: TCP protocol: TCP
name: mdb-api-port
volumeMounts: volumeMounts:
- name: mdb-db - name: mdb-db
mountPath: /data/db mountPath: /data/db
@ -78,11 +80,12 @@ spec:
memory: 3.5G memory: 3.5G
livenessProbe: livenessProbe:
tcpSocket: tcpSocket:
port: mdb-port port: mdb-api-port
initialDelaySeconds: 15
successThreshold: 1 successThreshold: 1
failureThreshold: 3 failureThreshold: 3
periodSeconds: 15 periodSeconds: 15
timeoutSeconds: 1 timeoutSeconds: 10
restartPolicy: Always restartPolicy: Always
volumes: volumes:
- name: mdb-db - name: mdb-db

View File

@ -9,8 +9,9 @@ spec:
selector: selector:
app: mdb-instance-0-ss app: mdb-instance-0-ss
ports: ports:
- port: 27017 - port: "<mongodb-backend-port from ConfigMap>"
targetPort: 27017 targetPort: "<mongodb-backend-port from ConfigMap>"
name: mdb-port name: mdb-port
protocol: TCP
type: ClusterIP type: ClusterIP
clusterIP: None clusterIP: None