Skip to content

Commit

Permalink
Update Monitoring doc (#379)
Browse files Browse the repository at this point in the history
* added database monitoring overview
* Elasticsearch: Updated buitin Prometheus doc
* Memcached: Updated builtin Prometheus doc
* MongoDB: Updated builtin Prometheus doc
* MySQL: Updated builtin Prometheus doc
* Postgres: Updated builtin Prometheus doc
* Redis: Updated builtin Prometheus doc
* Elasticsearch: Updated coreos Prometheus operator doc
* Memcached: Updated coreos Prometheus doc
* MongoDB: Updated coreos Prometheus doc
* MySQL: Updated coreos Prometheus doc
* Postgres: Updated coreos Prometheus doc
* Redis: Updated coreos Prometheus doc
* updated Prometheus discovery job + docs + image
  • Loading branch information
hossainemruz authored and tamalsaha committed Jan 7, 2019
1 parent fac6475 commit e98d128
Show file tree
Hide file tree
Showing 99 changed files with 2,580 additions and 2,775 deletions.
6 changes: 3 additions & 3 deletions docs/concepts/catalog/memcached.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ We modify original Memcached docker image to support additional features. An ima

### spec.version

`spec.version` is a required field that specifies the original version of Memcached database that has been used to build the docker image specified in `spec.db.image` field.
`spec.version` is a required field that specifies the original version of Memcached server that has been used to build the docker image specified in `spec.db.image` field.

### spec.deprecated

Expand All @@ -61,7 +61,7 @@ The default value of this field is `false`. If `spec.depcrecated` is set `true`,

### spec.db.image

`spec.db.image` is a required field that specifies the docker image which will be used to create Statefulset by KubeDB operator to create expected Memcached database.
`spec.db.image` is a required field that specifies the docker image which will be used to create Statefulset by KubeDB operator to create expected Memcached server.

### spec.exporter.image

Expand All @@ -70,4 +70,4 @@ The default value of this field is `false`. If `spec.depcrecated` is set `true`,
## Next Steps

- Learn about Memcached crd [here](/docs/concepts/databases/memcached.md).
- Deploy your first Memcached database with KubeDB by following the guide [here](/docs/guides/memcached/quickstart/quickstart.md).
- Deploy your first Memcached server with KubeDB by following the guide [here](/docs/guides/memcached/quickstart/quickstart.md).
6 changes: 3 additions & 3 deletions docs/concepts/catalog/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ We modify original Redis docker image to support Redis clustering and re-tag the

### spec.version

`spec.version` is a required field that specifies the original version of Redis database that has been used to build the docker image specified in `spec.db.image` field.
`spec.version` is a required field that specifies the original version of Redis server that has been used to build the docker image specified in `spec.db.image` field.

### spec.deprecated

Expand All @@ -61,7 +61,7 @@ The default value of this field is `false`. If `spec.depcrecated` is set to `tru

### spec.db.image

`spec.db.image` is a required field that specifies the docker image which will be used to create Statefulset by KubeDB operator to create expected Redis database.
`spec.db.image` is a required field that specifies the docker image which will be used to create Statefulset by KubeDB operator to create expected Redis server.

### spec.exporter.image

Expand All @@ -70,4 +70,4 @@ The default value of this field is `false`. If `spec.depcrecated` is set to `tru
## Next Steps

- Learn about Redis crd [here](/docs/concepts/databases/redis.md).
- Deploy your first Redis database with KubeDB by following the guide [here](/docs/guides/redis/quickstart/quickstart.md).
- Deploy your first Redis server with KubeDB by following the guide [here](/docs/guides/redis/quickstart/quickstart.md).
11 changes: 11 additions & 0 deletions docs/concepts/database-monitoring/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Database Monitoring | KubeDB
description: Database Monitoring
menu:
docs_0.9.0:
identifier: database-monitoring
parent: concepts
name: Database Monitoring
weight: 30
menu_name: docs_0.9.0
---
105 changes: 105 additions & 0 deletions docs/concepts/database-monitoring/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: Database Monitoring Overview
description: Database Monitoring Overview
menu:
docs_0.9.0:
identifier: database-monitoring-overview
name: Overview
parent: database-monitoring
weight: 10
menu_name: docs_0.9.0
section_menu_id: concepts
---

# Monitoring Database with KubeDB

KubeDB has native support for monitoring via [Prometheus](https://prometheus.io/). You can use builtin [Prometheus](https://github.com/prometheus/prometheus) scrapper or [CoreOS Prometheus Operator](https://github.com/coreos/prometheus-operator) to monitor KubeDB managed databases. This tutorial will show you how database monitoring works with KubeDB and how to configure Database crd to enable monitoring.

## Overview

KubeDB uses Prometheus [exporter](https://prometheus.io/docs/instrumenting/exporters/#databases) images to export Prometheus metrics for respective databases. Following diagram shows the logical flow of database monitoring with KubeDB.

<p align="center">
  <img alt="Database Monitoring Flow" src="/docs/images/concepts/monitoring/database-monitoring-overview.svg">
</p>

When a user creates a database crd with `spec.monitor` section configured, KubeDB operator provisions the respective database and injects an exporter image as sidecar to the database pod. It also creates a dedicated stats service with name `{database-crd-name}-stats` for monitoring. Prometheus server can scrape metrics using this stats service.

## Configure Monitoring

In order to enable monitoring for a database, you have to configure `spec.monitor` section. KubeDB provides following options to configure `spec.monitor` section:

| Field | Type | Uses |
| ----------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `spec.monitor.agent` | `Required` | Type of the monitoring agent that will be used to monitor this database. It can be `prometheus.io/builtin` or `prometheus.io/coreos-operator`. |
| `spec.monitor.prometheus.namespace` | `Optional` | Namespace where the Prometheus server is running or will be deployed. For agent type `prometheus.io/coreos-operator`, `ServiceMonitor` crd will be created in this namespace. |
| `spec.monitor.prometheus.labels` | `Optional` | Labels for `ServiceMonitor` crd. |
| `spec.monitor.prometheus.port` | `Optional` | Port number where the exporter side car will serve metrics. |
| `spec.monitor.prometheus.interval` | `Optional` | Interval at which metrics should be scraped. |
| `spec.monitor.args` | `Optional` | Arguments to pass to the exporter sidecar. |
| `spec.monitor.env` | `Optional` | List of environment variables to set in the exporter sidecar container. |
| `spec.monitor.resources` | `Optional` | Resources required by exporter sidecar container. |
| `spec.monitor.securityContext` | `Optional` | Security options the exporter should run with. |

## Sample Configuration

A sample YAML for Redis crd with `spec.monitor` section configured to enable monitoring with CoreOS [prometheus-operator](https://github.com/coreos/prometheus-operator) is shown below.

```yaml
apiVersion: kubedb.com/v1alpha1
kind: Redis
metadata:
name: sample-redis
namespace: databases
spec:
version: "4.0-v1"
terminationPolicy: WipeOut
configSource: # configure Redis to use password for authentication
configMap:
name: redis-config
storageType: Durable
storage:
storageClassName: default
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
monitor:
agent: prometheus.io/coreos-operator
prometheus:
namespace: monitoring
labels:
k8s-app: prometheus
args:
- --redis.password=$(REDIS_PASSWORD)
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: _name_of_secret_with_redis_password
key: password # key with the password
resources:
requests:
memory: 512Mi
cpu: 200m
limits:
memory: 512Mi
cpu: 250m
securityContext:
runAsUser: 2000
allowPrivilegeEscalation: false
```
Assume that above Redis is configured to use basic authentication. So, exporter image also need to provide password to collect metrics. We have provided it through `spec.monitor.args` field.

Here, we have specified that we are going to monitor this server using CoreOS prometheus-operator through `spec.monitor.agent: prometheus.io/coreos-operator`. KubeDB will create a `ServiceMonitor` crd in `monitoring` namespace and this `ServiceMonitor` will have `k8s-app: prometheus` label.

## Next Steps

- Learn how to monitor Elasticsearch database with KubeDB using [builtin-Prometheus](/docs/guides/elasticsearch/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/elasticsearch/monitoring/using-coreos-prometheus-operator.md).
- Learn how to monitor PostgreSQL database with KubeDB using [builtin-Prometheus](/docs/guides/postgres/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/postgres/monitoring/using-coreos-prometheus-operator.md).
- Learn how to monitor MySQL database with KubeDB using [builtin-Prometheus](/docs/guides/mysql/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/mysql/monitoring/using-coreos-prometheus-operator.md).
- Learn how to monitor MongoDB database with KubeDB using [builtin-Prometheus](/docs/guides/mongodb/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/mongodb/monitoring/using-coreos-prometheus-operator.md).
- Learn how to monitor Redis server with KubeDB using [builtin-Prometheus](/docs/guides/redis/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/redis/monitoring/using-coreos-prometheus-operator.md).
- Learn how to monitor Memcached server with KubeDB using [builtin-Prometheus](/docs/guides/memcached/monitoring/using-builtin-prometheus.md) and using [CoreOS Prometheus Operator](/docs/guides/memcached/monitoring/using-coreos-prometheus-operator.md).
12 changes: 6 additions & 6 deletions docs/concepts/databases/memcached.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spec:
### spec.replicas
`spec.replicas` is an optional field that specifies the number of desired Instances/Replicas of Memcached database. If you do not specify .spec.replicas, then it defaults to 1.
`spec.replicas` is an optional field that specifies the number of desired Instances/Replicas of Memcached server. If you do not specify .spec.replicas, then it defaults to 1.

### spec.version

Expand All @@ -102,7 +102,7 @@ Memcached managed by KubeDB can be monitored with builtin-Prometheus and CoreOS-

### spec.podTemplate

KubeDB allows providing a template for database pod through `spec.podTemplate`. KubeDB operator will pass the information provided in `spec.podTemplate` to the Deployment created for Memcached database.
KubeDB allows providing a template for database pod through `spec.podTemplate`. KubeDB operator will pass the information provided in `spec.podTemplate` to the Deployment created for Memcached server.

KubeDB accept following fields to set in `spec.podTemplate:`

Expand Down Expand Up @@ -155,7 +155,7 @@ At least one of the following was changed:

#### spec.podTemplate.spec.imagePullSecrets

`KubeDB` provides the flexibility of deploying Memcached database from a private Docker registry. To learn how to deploym Memcached from a private registry, please visit [here](/docs/guides/memcached/private-registry/using-private-registry.md).
`KubeDB` provides the flexibility of deploying Memcached server from a private Docker registry. To learn how to deploym Memcached from a private registry, please visit [here](/docs/guides/memcached/private-registry/using-private-registry.md).

#### spec.podTemplate.spec.nodeSelector

Expand All @@ -167,7 +167,7 @@ At least one of the following was changed:

### spec.serviceTemplate

You can also provide a template for the services created by KubeDB operator for Memcached database through `spec.serviceTemplate`. This will allow you to set the type and other properties of the services.
You can also provide a template for the services created by KubeDB operator for Memcached server through `spec.serviceTemplate`. This will allow you to set the type and other properties of the services.

KubeDB allows following fields to set in `spec.serviceTemplate`:

Expand All @@ -185,7 +185,7 @@ KubeDB allows following fields to set in `spec.serviceTemplate`:

### spec.updateStrategy

You can specify [update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies) of Deployment created by KubeDB for Memcached database thorough `spec.updateStrategy` field. The default value of this field is `RollingUpdate`. In future, we will use this field to determine how automatic migration from old KubeDB version to new one should behave.
You can specify [update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies) of Deployment created by KubeDB for Memcached server thorough `spec.updateStrategy` field. The default value of this field is `RollingUpdate`. In future, we will use this field to determine how automatic migration from old KubeDB version to new one should behave.

### spec.terminationPolicy

Expand All @@ -211,5 +211,5 @@ If you don't specify `spec.terminationPolicy` KubeDB uses `Pause` termination po

## Next Steps

- Learn how to use KubeDB to run a Memcached database [here](/docs/guides/memcached/README.md).
- Learn how to use KubeDB to run a Memcached server [here](/docs/guides/memcached/README.md).
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
10 changes: 5 additions & 5 deletions docs/concepts/databases/redis.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Redis managed by KubeDB can be monitored with builtin-Prometheus and CoreOS-Prom

### spec.podTemplate

KubeDB allows providing a template for database pod through `spec.podTemplate`. KubeDB operator will pass the information provided in `spec.podTemplate` to the StatefulSet created for Redis database.
KubeDB allows providing a template for database pod through `spec.podTemplate`. KubeDB operator will pass the information provided in `spec.podTemplate` to the StatefulSet created for Redis server.

KubeDB accept following fields to set in `spec.podTemplate:`

Expand Down Expand Up @@ -169,7 +169,7 @@ spec.podTemplate.spec.env

#### spec.podTemplate.spec.imagePullSecret

`KubeDB` provides the flexibility of deploying Redis database from a private Docker registry. To learn how to deploy Redis from a private registry, please visit [here](/docs/guides/redis/private-registry/using-private-registry.md).
`KubeDB` provides the flexibility of deploying Redis server from a private Docker registry. To learn how to deploy Redis from a private registry, please visit [here](/docs/guides/redis/private-registry/using-private-registry.md).

#### spec.podTemplate.spec.nodeSelector

Expand All @@ -181,7 +181,7 @@ spec.podTemplate.spec.env

### spec.serviceTemplate

You can also provide a template for the services created by KubeDB operator for Redis database through `spec.serviceTemplate`. This will allow you to set the type and other properties of the services.
You can also provide a template for the services created by KubeDB operator for Redis server through `spec.serviceTemplate`. This will allow you to set the type and other properties of the services.

KubeDB allows following fields to set in `spec.serviceTemplate`:

Expand All @@ -199,7 +199,7 @@ KubeDB allows following fields to set in `spec.serviceTemplate`:

### spec.updateStrategy

You can specify [update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies) of StatefulSet created by KubeDB for Redis database thorough `spec.updateStrategy` field. The default value of this field is `RollingUpdate`. In future, we will use this field to determine how automatic migration from old KubeDB version to new one should behave.
You can specify [update strategy](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies) of StatefulSet created by KubeDB for Redis server thorough `spec.updateStrategy` field. The default value of this field is `RollingUpdate`. In future, we will use this field to determine how automatic migration from old KubeDB version to new one should behave.

### spec.terminationPolicy

Expand Down Expand Up @@ -227,5 +227,5 @@ If you don't specify `spec.terminationPolicy` KubeDB uses `Pause` termination po

## Next Steps

- Learn how to use KubeDB to run a Redis database [here](/docs/guides/redis/README.md).
- Learn how to use KubeDB to run a Redis server [here](/docs/guides/redis/README.md).
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
43 changes: 43 additions & 0 deletions docs/examples/concepts/database-monitoring/sample-redis-mon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: kubedb.com/v1alpha1
kind: Redis
metadata:
name: sample-redis
namespace: databases
spec:
version: "4.0-v1"
terminationPolicy: WipeOut
configSource: # configure Redis to use password for authentication
configMap:
name: redis-config
storageType: Durable
storage:
storageClassName: default
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
monitor:
agent: prometheus.io/coreos-operator
prometheus:
namespace: monitoring
labels:
k8s-app: prometheus
args:
- --redis.password=$(REDIS_PASSWORD)
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: _name_of_secret_with_redis_password
key: password # key with the password
resources:
requests:
memory: 512Mi
cpu: 200m
limits:
memory: 512Mi
cpu: 250m
securityContext:
runAsUser: 2000
allowPrivilegeEscalation: false
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
namespace: demo
spec:
version: "6.3-v1"
terminationPolicy: WipeOut
storage:
storageClassName: "standard"
accessModes:
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/elasticsearch/monitoring/coreos-prom-es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
namespace: demo
spec:
version: "6.3-v1"
terminationPolicy: WipeOut
storage:
storageClassName: "standard"
accessModes:
Expand All @@ -15,7 +16,7 @@ spec:
monitor:
agent: prometheus.io/coreos-operator
prometheus:
namespace: demo
namespace: monitoring
labels:
app: kubedb
k8s-app: prometheus
interval: 10s
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apiVersion: kubedb.com/v1alpha1
kind: Memcached
metadata:
name: memcd-mon-prometheus
name: builtin-prom-memcd
namespace: demo
spec:
replicas: 3
replicas: 1
version: "1.5.4-v1"
terminationPolicy: WipeOut
podTemplate:
spec:
resources:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apiVersion: kubedb.com/v1alpha1
kind: Memcached
metadata:
name: memcd-mon-coreos
name: coreos-prom-memcd
namespace: demo
spec:
replicas: 3
version: "1.5.4-v1"
terminationPolicy: WipeOut
podTemplate:
spec:
resources:
Expand All @@ -18,8 +19,7 @@ spec:
monitor:
agent: prometheus.io/coreos-operator
prometheus:
namespace: demo
namespace: monitoring
labels:
app: kubedb
k8s-app: prometheus
interval: 10s

Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
apiVersion: kubedb.com/v1alpha1
kind: MongoDB
metadata:
name: mgo-mon-prometheus
name: builtin-prom-mgo
namespace: demo
spec:
version: "3.4-v1"
terminationPolicy: WipeOut
storage:
storageClassName: "standard"
accessModes:
Expand Down
Loading

0 comments on commit e98d128

Please sign in to comment.