diff --git a/.dockerignore b/.dockerignore index 0f04682..cf72a99 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,5 @@ # Ignore build and test binaries. bin/ testbin/ +docs/ +examples/ diff --git a/.gitignore b/.gitignore index c0a7a54..7027091 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ testbin/* *.swp *.swo *~ +.hugo_build.lock diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..80da6c5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +### v0.1.0 +##### Feburary 5, 2022 + +#### :tada: Features + +- Added standalone MongoDB functionality +- Added cluster MongoDB functionality +- Helm chart installation support +- Monitoring support for MongoDB +- Documentation for setup and management + diff --git a/docs/content/en/docs/Development/_index.md b/docs/content/en/docs/Development/_index.md new file mode 100644 index 0000000..a2bc558 --- /dev/null +++ b/docs/content/en/docs/Development/_index.md @@ -0,0 +1,7 @@ +--- +title: "Development" +linkTitle: "Development" +weight: 5 +description: > + Development related information for MongoDB Operator +--- diff --git a/docs/content/en/docs/Development/dev-guide.md b/docs/content/en/docs/Development/dev-guide.md new file mode 100644 index 0000000..3076807 --- /dev/null +++ b/docs/content/en/docs/Development/dev-guide.md @@ -0,0 +1,69 @@ +--- +title: "Development Guide" +weight: 2 +linkTitle: "Development Guide" +description: > + Development guide for MongoDB Operator +--- + +## Pre-requisites + +**Access to Kubernetes cluster** + +First, you will need access to a Kubernetes cluster. The easiest way to start is minikube. + +- [Virtualbox](https://www.virtualbox.org/wiki/Downloads) +- [Minikube](https://kubernetes.io/docs/setup/minikube/) +- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) + +**Tools to build an Operator** + +Apart from kubernetes cluster, there are some tools which are needed to build and test the MongoDB Operator. + +- [Git](https://git-scm.com/downloads) +- [Go](https://golang.org/dl/) +- [Docker](https://docs.docker.com/install/) +- [Operator SDK](https://github.com/operator-framework/operator-sdk/blob/v0.8.1/doc/user/install-operator-sdk.md) +- [Make](https://www.gnu.org/software/make/manual/make.html) + +## Building Operator + +To build the operator on local system, we can use `make` command. + +```shell +$ make manager +... +go build -o bin/manager main.go +``` + +MongoDB operator gets packaged as a container image for running on the Kubernetes cluster. + +```shell +$ make docker-build +``` + +If you want to play it on Kubernetes. You can use a minikube. + +```shell +$ minikube start --vm-driver virtualbox +... +๐Ÿ˜„ minikube v1.0.1 on linux (amd64) +๐Ÿคน Downloading Kubernetes v1.14.1 images in the background ... +๐Ÿ”ฅ Creating kvm2 VM (CPUs=2, Memory=2048MB, Disk=20000MB) ... +๐Ÿ“ถ "minikube" IP address is 192.168.39.240 +๐Ÿณ Configuring Docker as the container runtime ... +๐Ÿณ Version of container runtime is 18.06.3-ce +โŒ› Waiting for image downloads to complete ... +โœจ Preparing Kubernetes environment ... +๐Ÿšœ Pulling images required by Kubernetes v1.14.1 ... +๐Ÿš€ Launching Kubernetes v1.14.1 using kubeadm ... +โŒ› Waiting for pods: apiserver proxy etcd scheduler controller dns +๐Ÿ”‘ Configuring cluster permissions ... +๐Ÿค” Verifying component health ..... +๐Ÿ’— kubectl is now configured to use "minikube" +๐Ÿ„ Done! Thank you for using minikube! +``` + +```shell +$ make test +``` \ No newline at end of file diff --git a/docs/content/en/docs/Monitoring/_index.md b/docs/content/en/docs/Monitoring/_index.md new file mode 100644 index 0000000..378993e --- /dev/null +++ b/docs/content/en/docs/Monitoring/_index.md @@ -0,0 +1,7 @@ +--- +title: "Monitoring" +linkTitle: "Monitoring" +weight: 4 +description: > + Monitoring of MongoDB standalone and cluster +--- diff --git a/docs/content/en/docs/Monitoring/grafana-dashboard.md b/docs/content/en/docs/Monitoring/grafana-dashboard.md new file mode 100644 index 0000000..8b0bfa6 --- /dev/null +++ b/docs/content/en/docs/Monitoring/grafana-dashboard.md @@ -0,0 +1,9 @@ +--- +title: "Grafana Dashboard" +weight: 3 +linkTitle: "Grafana Dashboard" +description: > + Monitoring dashboard of MongoDB database for Grafana +--- + +### Coming Soon \ No newline at end of file diff --git a/docs/content/en/docs/Monitoring/prometheus-monitoring.md b/docs/content/en/docs/Monitoring/prometheus-monitoring.md new file mode 100644 index 0000000..e17f115 --- /dev/null +++ b/docs/content/en/docs/Monitoring/prometheus-monitoring.md @@ -0,0 +1,74 @@ +--- +title: "Prometheus Monitoring" +weight: 2 +linkTitle: "Prometheus Monitoring" +description: > + Monitoring of MongoDB standalone and replicaset cluster using Prometheus +--- + +In MongoDB Operator, we are using [mongodb-exporter](https://github.com/percona/mongodb_exporter) to collect the stats, metrics for MongoDB database. This exporter is capable to capture the stats for standalone and cluster mode of MongoDB. + +If we are using the `helm` chart for installation purpose, we can simply enable this configuration inside the [values.yaml](https://github.com/OT-CONTAINER-KIT/helm-charts/blob/main/charts/mongodb-cluster/values.yaml). + +```yaml +mongoDBMonitoring: + enabled: true + image: + name: bitnami/mongodb-exporter + tag: 0.11.2-debian-10-r382 + imagePullPolicy: IfNotPresent + resources: {} +``` + +In case of `kubectl` installation, we can add a code snippet in yaml manifest like this:- + +```yaml + mongoDBMonitoring: + enableExporter: true + image: bitnami/mongodb-exporter:0.11.2-debian-10-r382 + imagePullPolicy: IfNotPresent + resources: {} +``` + +## ServiceMonitor for Prometheus Operator + +Once the exporter is configured, the next aligned task would be to ask [Prometheus](https://prometheus.io) to monitor it. For [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator), we have to create CRD object in Kubernetes called "ServiceMonitor". We can update this using the `helm` as well. + +```yaml +serviceMonitor: + enabled: false + interval: 30s + scrapeTimeout: 10s + namespace: monitoring +``` + +For kubectl related configuration, we may have to create `ServiceMonitor` definition in a yaml file and apply it using kubectl command. A `ServiceMonitor` definition looks like this:- + +```yaml +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: mongodb-prometheus-monitoring + labels: + app.kubernetes.io/name: mongodb + app.kubernetes.io/managed-by: mongodb + app.kubernetes.io/instance: mongodb + app.kubernetes.io/version: v0.1.0 + app.kubernetes.io/component: middleware +spec: + selector: + matchLabels: + app: mongodb + mongodb_setup: standalone + role: standalone + endpoints: + - port: metrics + interval: 30s + scrapeTimeout: 30s + namespaceSelector: + matchNames: + - middleware-production +``` + + diff --git a/docs/content/en/docs/Release History/_index.md b/docs/content/en/docs/Release History/_index.md new file mode 100644 index 0000000..a3db02e --- /dev/null +++ b/docs/content/en/docs/Release History/_index.md @@ -0,0 +1,7 @@ +--- +title: "Release History" +linkTitle: "Release History" +weight: 6 +description: > + Release information for MongoDB Operator +--- diff --git a/docs/content/en/docs/Release History/changelog.md b/docs/content/en/docs/Release History/changelog.md new file mode 100644 index 0000000..73b2462 --- /dev/null +++ b/docs/content/en/docs/Release History/changelog.md @@ -0,0 +1,19 @@ +--- +title: "CHANGELOG" +weight: 2 +linkTitle: "CHANGELOG" +description: > + Changelog version history for MongoDB +--- + +### v0.1.0 + +**Feburary 5, 2022** + +**๐Ÿ„ Features** + +- Added standalone MongoDB functionality +- Added cluster MongoDB functionality +- Helm chart installation support +- Monitoring support for MongoDB +- Documentation for setup and management