|
1 | 1 | # Database controller
|
2 | 2 |
|
3 |
| -[](https://bestpractices.coreinfrastructure.org/projects/4787) |
| 3 | +[](https://bestpractices.coreinfrastructure.org/projects/5643) |
4 | 4 | [](https://github.com/DoodleScheduling/k8sdb-controller/actions)
|
5 | 5 | [](https://goreportcard.com/report/github.com/DoodleScheduling/k8sdb-controller)
|
6 |
| -[](https://github.com/DoodleScheduling/k8sdb-controller/blob/main/LICENSE) |
| 6 | +[](https://github.com/DoodleScheduling/k8sdb-controller/blob/master/LICENSE) |
7 | 7 | [](https://github.com/DoodleScheduling/k8sdb-controller/releases)
|
8 | 8 |
|
9 | 9 | Kubernetes Controller for database and user provisioning.
|
10 |
| - |
11 |
| -**Note**: This controller does not deploy database servers. It is meant for managing existing ones either deployed by other controllers or manually. |
| 10 | +Currently the controller supports Postgres and MongoDB (as well as MongoDB Atlas). |
| 11 | +Using the controller you can deploy databases and users defined as code on top of kubernetes. |
| 12 | +How to deploy database servers is out of scope of this project. |
12 | 13 |
|
13 | 14 | ## Example for PostgreSQL
|
14 | 15 |
|
| 16 | +Example of how to deploy a Postgres database called my-app as well as a user to the server localhost:5432. |
| 17 | + |
15 | 18 | ```yaml
|
16 | 19 | apiVersion: v1
|
17 | 20 | kind: Secret
|
|
54 | 57 | ```
|
55 | 58 |
|
56 | 59 | ## Example for MongoDB
|
| 60 | +
|
| 61 | +Example of how to deploy a MongoDB database called my-app as well as a user to the server localhost:5432. |
| 62 | +
|
57 | 63 | ```yaml
|
58 | 64 | apiVersion: v1
|
59 | 65 | kind: Secret
|
@@ -97,29 +103,40 @@ data:
|
97 | 103 | username: MTIzNA==
|
98 | 104 | ```
|
99 | 105 |
|
100 |
| -## Helm chart |
| 106 | +## Installation |
| 107 | +
|
| 108 | +### Helm |
| 109 | +
|
| 110 | +Please see [chart/k8sdb-controller](https://github.com/DoodleScheduling/k8sdb-controller/tree/master/chart/k8stcpmap-controller) for the helm chart docs. |
| 111 | +
|
| 112 | +### Manifests/kustomize |
101 | 113 |
|
102 |
| -Please see [chart/k8sdb-controller](https://github.com/DoodleScheduling/k8sdb-controller) for the helm chart docs. |
| 114 | +Alternatively you may get the bundled manifests in each release to deploy it using kustomize or use them directly. |
| 115 | +
|
| 116 | +## Limitations |
| 117 | +
|
| 118 | +By design there is no garbage collection implemented for databases. Meaning a database does not get dropped if the kubernetes resources is removed. |
| 119 | +However this is not the case for users. Users will be removed from the corresponding databases if the referenced kubernetes resource gets removed. |
| 120 | +We might reconsider this in the future. |
103 | 121 |
|
104 | 122 | ## Profiling
|
105 |
| -To profile controller, access web server on #profilerPort (default 6060). |
| 123 | +To profile controller, access web server on #profilerPort (default 6060). |
106 | 124 |
|
107 | 125 | In Kubernetes, port-forward to this port, and open the `/debug/pprof` URL in browser. For example, if you port-forward 6060 from container to 6060 on your machine, access:
|
108 | 126 | ```
|
109 | 127 | http://localhost:6060/debug/pprof/
|
110 | 128 | ```
|
111 | 129 |
|
112 |
| -## Limitations |
113 |
| -
|
114 |
| -Currently there is no garbage collection implemented, meaning all the things created are not removed. |
115 |
| -This will be at least implemented for user provisioning. Discussion will stay open for databases. |
116 |
| -
|
117 | 130 | ## Configure the controller
|
118 | 131 |
|
119 |
| -ENV Variable | Argument | Default value | Example | Purpose | |
120 |
| --------------|----------|---------------|---------|---------| |
121 |
| -METRICS_ADDR | --metrics-addr | :8080 | :8080 | Metrics port | |
122 |
| -ENABLE_LEADER_ELECTION | --enable-leader-election | false | true | Enable leader election | |
123 |
| -LEADER_ELECTION_NAMESPACE | --leader-election-namespace | "" | devops | Leader election namespace. Default is the same as controller. |
124 |
| -NAMESPACES | --namespaces | "" | devops,default | Namespaces to watch. Default: watch all namespaces | |
125 |
| -MAX_CONCURRENT_RECONCILES | --max-concurrent-reconciles | 1 | 5 | Maximum concurrent reconciles per controller. This config covers all controllers. | |
| 132 | +You may change base settings for the controller using env variables (or alternatively command line arguments). |
| 133 | +Available env variables: |
| 134 | +
|
| 135 | +| Name | Description | Default | |
| 136 | +|-------|-------------| --------| |
| 137 | +| `METRICS_ADDR` | The address of the metric endpoint binds to. | `:9556` | |
| 138 | +| `PROBE_ADDR` | The address of the probe endpoints binds to. | `:9557` | |
| 139 | +| `ENABLE_LEADER_ELECTION` | Enable leader election for controller manager. | `false` | |
| 140 | +| `LEADER_ELECTION_NAMESPACE` | Change the leader election namespace. This is by default the same where the controller is deployed. | `` | |
| 141 | +| `NAMESPACES` | The controller listens by default for all namespaces. This may be limited to a comma delimited list of dedicated namespaces. | `` | |
| 142 | +| `CONCURRENT` | The number of concurrent reconcile workers. | `1` | |
0 commit comments