Skip to content

Commit

Permalink
Improve structure of MongoDB User Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
the-redback committed Feb 12, 2018
1 parent cbd6a0f commit dbbbf70
Show file tree
Hide file tree
Showing 37 changed files with 2,786 additions and 748 deletions.
30 changes: 22 additions & 8 deletions docs/concepts/databases/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
requests:
storage: 50Mi
databaseSecret:
secretName: mgo1-admin-auth
secretName: mgo1-auth
nodeSelector:
disktype: ssd
init:
Expand All @@ -59,7 +59,7 @@ spec:
cpu: "500m"
doNotPause: true
monitor:
agent: coreos-prometheus-operator
agent: prometheus.io/coreos-operator
prometheus:
namespace: demo
labels:
Expand Down Expand Up @@ -88,15 +88,26 @@ spec:
- `spec.storage.resources` can be used to request specific quantities of storage. This follows the same resource model used by PVCs.

To learn how to configure `spec.storage`, please visit the links below:

- https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims


### spec.databaseSecret
`spec.databaseSecret` is an optional field that points to a Secret used to hold credentials for `mongodb` super user. If not set, KubeDB operator creates a new Secret `{mongodb-object-name}-admin-auth` for storing the password for `mongodb` superuser for each MongoDB object. If you want to use an existing secret please specify that when creating the MongoDB object using `spec.databaseSecret.secretName`.
`spec.databaseSecret` is an optional field that points to a Secret used to hold credentials for `mongodb` super user. If not set, KubeDB operator creates a new Secret `{mongodb-object-name}-auth` for storing the password for `mongodb` superuser for each MongoDB object. If you want to use an existing secret please specify that when creating the MongoDB object using `spec.databaseSecret.secretName`.

This secret contains a `.admin` key which contains the password for `mongodb` superuser. Example:
This secret contains a `user` key and a `password` key which contains the `username` and `password` respectively for `mongodb` superuser. Example:
```ini
vPlT2PzewCaC3XZP
apiVersion: v1
data:
password: NnE4dV8yak1PVy1PT1pYaw==
user: cm9vdA==
kind: Secret
metadata:
...
name: mgo1-auth
namespace: demo
...
type: Opaque
```


Expand Down Expand Up @@ -163,17 +174,20 @@ KubeDB supports taking periodic snapshots for MongoDB database. This is an optio
### spec.doNotPause
`spec.doNotPause` is an optional field that tells KubeDB operator that if this MongoDB object is deleted, whether it should be reverted automatically. This should be set to `true` for production databases to avoid accidental deletion. If not set or set to false, deleting a MongoDB object put the database into a dormant state. THe StatefulSet for a DormantDatabase is deleted but the underlying PVCs are left intact. This allows user to resume the database later.

### spec.imagePullSecret
`KubeDB` provides the flexibility of deploying MongoDB database from a Private Docker Registry. To learn how to deploym MongoDB from a Private Registry, please visit [here](/docs/guides/mongodb/private-registry/using-private-registry.md).

### spec.monitor
To learn how to monitor MongoDB databases, please visit [here](/docs/concepts/monitoring.md).

MongoDB can be monitored with KubeDB using out-of-the-box builtin-Prometheus and out-of-the-box CoreOS-Prometheus Operator. To learn more,
- [Monitor MongoDB with builtin-Prometheus](/docs/guides/mongodb/monitoring/using-builtin-prometheus.md)
- [Monitor MongoDB with CoreOS-Prometheus Operator](/docs/guides/mongodb/monitoring/using-coreos-prometheus-operator.md)

### spec.resources
`spec.resources` is an optional field. This can be used to request compute resources required by the database pods. To learn more, visit [here](http://kubernetes.io/docs/user-guide/compute-resources/).


## Next Steps
- Learn how to use KubeDB to run a MongoDB database [here](/docs/guides/mongodb/overview.md).
- Learn how to use KubeDB to run a MongoDB database [here](/docs/guides/mongodb/README.md).
- See the list of supported storage providers for snapshots [here](/docs/concepts/snapshot.md).
- Thinking about monitoring your database? KubeDB works [out-of-the-box with Prometheus](/docs/guides/monitoring.md).
- Learn how to use KubeDB in a [RBAC](/docs/guides/rbac.md) enabled cluster.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo1
name: mgo-init-script
namespace: demo
spec:
version: 3.4
Expand Down
18 changes: 18 additions & 0 deletions docs/examples/mongodb/Initialization/demo-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo-init-snapshot
namespace: demo
spec:
version: 3.4
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
init:
snapshotSource:
name: snapshot-infant
namespace: demo
16 changes: 16 additions & 0 deletions docs/examples/mongodb/monitoring/builtin-prometheus/demo-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo-mon-prometheus
namespace: demo
spec:
version: 3.4
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
monitor:
agent: prometheus.io/builtin
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: kubedb.com/v1alpha1
kind: Postgres
kind: MongoDB
metadata:
name: pmon
name: mgo-mon-coreos
namespace: demo
spec:
version: 9.5
version: 3.4
storage:
storageClassName: "standard"
accessModes:
Expand All @@ -13,9 +13,10 @@ spec:
requests:
storage: 50Mi
monitor:
agent: coreos-prometheus-operator
agent: prometheus.io/coreos-operator
prometheus:
namespace: demo
labels:
app: kubedb
interval: 10s

8 changes: 8 additions & 0 deletions docs/examples/mongodb/private-registry/demo-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: myregistrykey
namespace: demo
data:
.dockerconfigjson: <base-64-encoded-json-here>
type: kubernetes.io/dockerconfigjson
17 changes: 17 additions & 0 deletions docs/examples/mongodb/private-registry/demo-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo-pvt-reg
namespace: demo
spec:
version: 3.4
doNotPause: true
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
imagePullSecrets:
- name: myregistrykey
15 changes: 15 additions & 0 deletions docs/examples/mongodb/quickstart/demo-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo-quickstart
namespace: demo
spec:
version: 3.4
doNotPause: true
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
15 changes: 15 additions & 0 deletions docs/examples/mongodb/snapshot/demo-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo-infant
namespace: demo
spec:
version: 3.4
doNotPause: true
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: kubedb.com/v1alpha1
kind: Snapshot
metadata:
name: mgo-xyz
name: snapshot-infant
namespace: demo
labels:
kubedb.com/kind: MongoDB
spec:
databaseName: mgo1
databaseName: mgo-infant
storageSecretName: mg-snap-secret
gcs:
bucket: restic
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: recovered
name: mgo-recovered
namespace: demo
spec:
version: 3.4
Expand All @@ -14,4 +14,5 @@ spec:
storage: 50Mi
init:
snapshotSource:
name: mgo-xyz
name: snapshot-infant
namespace: demo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo1
name: mgo-scheduled
namespace: demo
spec:
version: 3.4
Expand Down
7 changes: 7 additions & 0 deletions docs/examples/monitoring/builtin-prometheus/demo-0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: demo
spec:
finalizers:
- kubernetes
43 changes: 43 additions & 0 deletions docs/examples/monitoring/builtin-prometheus/demo-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-server-conf
labels:
name: prometheus-server-conf
namespace: demo
data:
prometheus.yml: |-
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: 'kubernetes-service-endpoints'
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: replace
target_label: __scheme__
regex: (https?)
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_service_name]
action: replace
target_label: kubernetes_name
51 changes: 51 additions & 0 deletions docs/examples/monitoring/builtin-prometheus/demo-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-server
namespace: demo
spec:
replicas: 1
selector:
matchLabels:
app: prometheus-server
template:
metadata:
labels:
app: prometheus-server
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.1.0
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
ports:
- containerPort: 9090
volumeMounts:
- name: prometheus-config-volume
mountPath: /etc/prometheus/
- name: prometheus-storage-volume
mountPath: /prometheus/
volumes:
- name: prometheus-config-volume
configMap:
defaultMode: 420
name: prometheus-server-conf
- name: prometheus-storage-volume
emptyDir: {}

---
apiVersion: v1
kind: Service
metadata:
name: prometheus-service
namespace: demo
spec:
selector:
app: prometheus-server
type: LoadBalancer
ports:
- port: 9090
targetPort: 9090
nodePort: 30901

Loading

0 comments on commit dbbbf70

Please sign in to comment.