Skip to content

Commit 6a324f1

Browse files
committed
WIP: Start writing the 'getting started' page
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
1 parent 40cdf9c commit 6a324f1

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

docs/development/contribution.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How to contribute
2+
3+
## Workflow
4+
5+
## How to become a maintainer

docs/development/helm-charts.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ yq -i '.appVersion = "${GIT_SHA}"' ./charts/db-operator/Chart.yaml
2525
```
2626

2727
After that, CRDs will be up-to-date with the operator repo and you can test your changes.
28-
##

docs/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Getting Started
22

3+
DB Operator is a Kubernetes operator for managing **MySQL** and **PostgreSQL** databases through **CRDs**.
4+
5+
This operator doesn't launch databases, instead it should be connected to running servers, that's why it doesn't nececeraly require that the database is running in Kubernetes, and can be used with any server that can be accessed from inside the cluster.
6+
7+
After it is connected to a server, you can start managing databases and users through CRDs. When a user or a database is created, db-operator will add a `Secret` and a `ConfigMap` to the namespace where CR is deployed, they can be used by a pod to establish a connection with a database.
8+
9+
### Example
10+
11+
Let's imagine, you have an application that requires a connection to a Postgres DB, it receives credentials from the environment variable `POSTGRES_DATASOURCE`, and it needs to be in a following format: `postgresql://${USER}:${PASSWORD}@${HOSTNAME}:${PORT}/${DATABASE}?search_path=myapp`
12+
13+
We will talk about how to install the operator and connect it to a server later, now let's focus on the main logic. We need to create a `Database` resource:
14+
```yaml
15+
apiVersion: kinda.rocks/v1beta1
16+
kind: Database
17+
metadata:
18+
name: my-app
19+
namespace: my-namespace
20+
spec:
21+
backup:
22+
enable: false
23+
credentials:
24+
templates:
25+
# - This template will be used by the operator to add POSTGRES_DATASOURCE to the secret.
26+
# - TODO(@allanger): Add a link to the templates docs
27+
- name: POSTGRES_DATASOURCE
28+
secret: true
29+
template: '{{ .Protocol }}://{{ .Username }}:{{ .Password }}@{{ .Hostname }}:{{ .Port }}/{{ .Database }}?search_path=my-app'
30+
deletionProtected: true
31+
instance: some-postgres
32+
postgres:
33+
dropPublicSchema: true
34+
schemas:
35+
- my-app
36+
secretName: my-app-db-creds
37+
```
38+
39+
> (@allanger): This logic might be changed when the `Database` resource will be upgrade to the version `v1`
40+
After the reconciliation you should be able to find a `ConfigMap` and a `Secret` in the namespace `my-namespace`. They both will be called `my-app-db-creds`
341

442

543
## Install db-operator

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ site_name: DB Operator
22
theme:
33
name: material
44
language: en
5+
features:
6+
- navigation.tabs

0 commit comments

Comments
 (0)