Skip to content

Commit 44b5bdd

Browse files
committed
WIP: A lot of changes
Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
1 parent 2cb9034 commit 44b5bdd

36 files changed

Lines changed: 689 additions & 761 deletions

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ gen-docs: ## Generate helm documentation
2121
./bin/helm-docs --template-files=./charts/db-operator/README.md.gotmpl \
2222
--sort-values-order file --chart-to-generate=charts/db-operator
2323
./bin/helm-docs --template-files=./charts/db-isntances/README.md.gotmpl --sort-values-order file --chart-to-generate=charts/db-instances
24+
25+
gen-schema: ## Generate the json schema, not there yet
26+
test -s $(LOCALBIN)/helm-schema || GOBIN=$(LOCALBIN_DIR) go install github.com/dadav/helm-schema/cmd/helm-schema@latest

charts/db-operator/Chart.yaml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1+
---
12
apiVersion: v2
23
type: application
34
name: db-operator
4-
version: 2.5.2
5+
version: 3.0.0
6+
description: This operator lets you manage databases in a Kubernetes native way, even if they are not deployed to Kubernetes
57

6-
# ---------------------------------------------------------------------------------
7-
# -- All supported k8s versions are in the test:
8-
# -- https://github.com/db-operator/charts/blob/main/.github/workflows/test.yaml
9-
# ---------------------------------------------------------------------------------
10-
kubeVersion: ">= 1.30-prerelease"
11-
appVersion: "2.21.0"
12-
description: The DB Operator creates databases and make them available in the cluster via Custom Resource.
13-
home: https://github.com/db-operator/db-operator
8+
# All supported k8s versions are in the test:
9+
# https://github.com/db-operator/charts/blob/main/.github/workflows/integration-test.yaml
10+
kubeVersion: ">= 1.32-prerelease"
11+
appVersion: "986af02fe9ff1ddcc3321bd624385f1d9c8b9a3a"
12+
13+
home: https://github.com/db-operator
1414
maintainers:
1515
- name: Nikolai Rodionov
16-
email: allanger@zohomail.com
16+
email: iam@allanger.xyz
1717
url: https://badhouseplants.net
1818
sources:
1919
- https://github.com/db-operator/db-operator
20-
- https://github.com/db-operator/cloudish-sql
21-
- https://github.com/db-operator/pgdump-gcs
22-
- https://github.com/db-operator/mydump-gcs
2320
keywords:
2421
- database
25-
- Operator
2622
- mysql
2723
- postgres

charts/db-operator/README.md

Lines changed: 21 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,50 @@
11
# db-operator
22

3-
![Version: 2.5.2](https://img.shields.io/badge/Version-2.5.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.21.0](https://img.shields.io/badge/AppVersion-2.21.0-informational?style=flat-square)
3+
![Version: 2.6.0](https://img.shields.io/badge/Version-2.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: f344d402c08f96e48cfe806830f555f4ae9d65e7](https://img.shields.io/badge/AppVersion-f344d402c08f96e48cfe806830f555f4ae9d65e7-informational?style=flat-square)
44

5-
The DB Operator creates databases and make them available in the cluster via Custom Resource.
5+
This operator lets you manage databases in a Kubernetes native way, even if they are not deployed to Kubernetes
66

7-
## Source Code
8-
9-
* <https://github.com/db-operator/db-operator>
10-
* <https://github.com/db-operator/cloudish-sql>
11-
* <https://github.com/db-operator/pgdump-gcs>
12-
* <https://github.com/db-operator/mydump-gcs>
7+
**Homepage:** <https://github.com/db-operator>
138

149
## Maintainers
1510

1611
| Name | Email | Url |
1712
| ---- | ------ | --- |
18-
| Nikolai Rodionov | <allanger@zohomail.com> | <https://badhouseplants.net> |
19-
20-
## Requirements
21-
22-
Kubernetes: `>= 1.30-prerelease`
23-
24-
## Installing the Chart
25-
26-
```console
27-
$ helm repo add db-operator https://db-operator.github.io/charts
28-
$ helm repo update
29-
$ helm install db-operator/db-operator
30-
```
31-
32-
If you want to manage `CRDs` yourself, you need to set `.Values.crds.install` to `false`. In that case they won't be a part of templated manifests.
33-
34-
We don't support this way of `CRD` management officially though, so we can't promise to answer your questions if you choose to go this way. If you want to know more about it, keep reading, we'll talk about it later.
35-
36-
## Upgarding the Chart
37-
38-
If there are breaking changes, they should be described in this README's latest item and in helm-chart notes. So if you run `helm upgrade db-operator db-operator/db-operator --dry-run`, you will see if there are breaking changes there.
39-
40-
## Uninstalling the Chart
41-
42-
To uninstall the operator only, run
43-
44-
```console
45-
$ helm uninstall db-operator
46-
```
47-
48-
If you have CRDs installed by the chart, you will also have to run something like:
49-
50-
```console
51-
# !!! This command will remove all kinda.rocks CRDs from the cluster,
52-
# so please make sure that you really want to run it
53-
$ for crd in $(kubectl get crds | awk '{print $1}' | grep 'kinda.rocks'); do kubectl delete crd "${crd}"; done
54-
```
55-
56-
## Why are we packaging CRDs in templates?
57-
58-
There are several reasons for that. The main one is that we are using webhooks and they require certificates to be created. If you have a look at the `CRDs` templates, you'll see something like that:
59-
60-
```mustache
61-
annotations:
62-
controller-gen.kubebuilder.io/version: v0.12.1
63-
{{- if .Values.webhook.certificate.create }}
64-
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.name}}
65-
{{ else }}
66-
cert-manager.io/inject-ca-from-secret: {{ .Release.Namespace }}/{{ .Values.webhook.certificate.secretName}}
67-
{{- end }}
68-
{{- if .Values.crds.keep }}
69-
helm.sh/resource-policy: keep
70-
{{- end }}
71-
{{- with .Values.crds.annotations }}
72-
{{- toYaml . | nindent 4 }}
73-
{{- end }}
74-
```
75-
76-
So, as you can see they require some information about the release, so they can't be static. Since the webhook is an important part of what we're distributing, we don't want to have it disabled by default.
77-
78-
Also, we do not have `CRs` in the package, so there is no chicken-egg problem here. You don't need to have `CRDs` installed to install the chart. Since `CRDs` are a part of the operator and you can't have one without another, having them packaged and distributed together makes more sense to us.
13+
| Nikolai Rodionov | <iam@allanger.xyz> | <https://badhouseplants.net> |
7914

80-
But it's still possible for users to manage `CRDs` on their own. You need to set `.Values.crds.install` to false and go to the [db-operator rgit repository](https://github.com/db-operator/db-operator). There, in the `config/crd/bases` directory, you'll find `CRD` manifests. But if you decided to go this way and you have problems with `CRDs`, you're most probably on your own, you still can open issues though.
15+
## Source Code
8116

82-
## Why do we need cert-manager?
17+
* <https://github.com/db-operator/db-operator>
8318

84-
At the moment, `db-operator` chart requires `cert-manager` to be present in the cluster. It's because webhook related resources are using it to create certificates. It should change one day, since we would like this chart to be self-sufficient, but currently that's what we've got.
19+
## Requirements
8520

86-
## What is `.Values.tests`?
21+
Kubernetes: `>= 1.32-prerelease`
8722

88-
We use helm tests feature for testing the chart in CI. Though we know that this feature should be used by users to test their intsallations, we do not think that it can be very helpful in this particular case. Test resources are creating a powerful `ClusterRoles`, so **please make sure you don't have them enabled**, unless you really know what you're doing and why.
23+
## Values
8924

90-
## Chart Values
9125
| Key | Type | Default | Description |
9226
|-----|------|---------|-------------|
9327
| nameOverride | string | `""` | |
9428
| image.repository | string | `"ghcr.io/db-operator/db-operator"` | |
9529
| image.pullPolicy | string | `"Always"` | |
96-
| controller.logLevel | string | `"info"` | |
97-
| controller.extraArgs | list | `[]` | |
98-
| reconcileInterval | string | `"60"` | |
99-
| watchNamespace | string | `""` | |
100-
| checkForChanges | bool | `false` | ---------------------------------------------------------- |
101-
| rbac.create | bool | `true` | |
102-
| serviceAccount.create | bool | `true` | |
10330
| crds.install | bool | `true` | |
10431
| crds.keep | bool | `true` | |
10532
| crds.annotations | object | `{}` | |
106-
| webhook.extraArgs | list | `[]` | |
33+
| controller.logLevel | string | `"info"` | |
34+
| controller.extraArgs | list | `[]` | |
35+
| controller.rbac.create | bool | `true` | |
36+
| controller.rbac.serviceAccount.name | string | `""` | |
37+
| controller.rbac.serviceAccount.create | bool | `true` | |
38+
| controller.config.reconcileInterval | string | `"60"` | |
39+
| controller.config.watchNamespace | string | `""` | |
40+
| controller.config.checkForChanges | bool | `false` | |
10741
| webhook.enabled | bool | `true` | |
10842
| webhook.logLevel | string | `"info"` | |
43+
| webhook.extraArgs | list | `[]` | |
10944
| webhook.podLabels | object | `{}` | |
110-
| webhook.serviceAccount.create | bool | `true` | |
45+
| webhook.rbac.create | bool | `true` | |
46+
| webhook.rbac.serviceAccount.name | string | `""` | |
47+
| webhook.rbac.serviceAccount.create | bool | `true` | |
11148
| webhook.names.mutating | string | `"db-operator-mutating-webhook-configuration"` | |
11249
| webhook.names.validating | string | `"db-operator-validating-webhook-configuration"` | |
11350
| webhook.certificate.create | bool | `true` | ------------------------------------------ |
@@ -164,53 +101,3 @@ We use helm tests feature for testing the chart in CI. Though we know that this
164101
| service.annotations | object | `{}` | |
165102
| service.type | string | `"ClusterIP"` | |
166103
| service.port | int | `8080` | |
167-
## Dev Notes
168-
169-
After changing default `Values`, please execute `make gen_docs` to update the `README.md` file. Readme file is generated by the `helm-docs` tool, so make sure not to edit it manually.
170-
171-
## Upgrading
172-
173-
If there is an breaking change, or something that might make the upgrade complicated, it should be described here
174-
175-
<details>
176-
<summary>To <code>v2.0.0</code></summary>
177-
From `v2.0.0` onwards, the `v` prefix will not be automatically added to the image tag. If you are overriding the image tag through `.Values.image.tag` and are relying on this behaviour, please add the `v` prefix manually to the Helm value. Otherwise, no action is required from your side!
178-
</details>
179-
180-
<details>
181-
<summary>To <code>v1.11.0</code></summary>
182-
Additional selectors were added to the default templates in an attempt to follow the same labelling scheme everywhere, but since selectors are immutable, the upgrade will require removing of the db-operator deployment.
183-
184-
```bash
185-
$ kubectl get deploy
186-
NAME READY UP-TO-DATE AVAILABLE AGE
187-
db-operator 1/1 1 1 22s
188-
$ kubectl delete deploy db-operator
189-
deployment.apps "db-operator" deleted
190-
$ helm upgrade db-operator db-operator/db-operator --version 1.11.0
191-
```
192-
193-
</details>
194-
195-
<details>
196-
<summary>To <code>v1.10.0</code></summary>
197-
198-
CRDs are moved to the `templates` folder, so now they are part of the release. It means that after the upgrade, you will get errors about resource ownerships. Thow errors will contain messages about missing `labels` and `annotations`, and the easiest way to fix it, will be just to add the `metadata` that helm can't find. So you can follow those messages one by one and when all the `CRDs` are patched, you'll be able to install the release.
199-
200-
For example:
201-
202-
```BASH
203-
$ helm upgrade my-release .
204-
Error: UPGRADE FAILED: rendered manifests contain a resource that already exists. Unable to continue with update: CustomResourceDefinition "databases.kinda.rocks" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; label validation error: missing key "app.kubernetes.io/managed-by": must be set to "Helm"; annotation validation error: missing key "meta.helm.sh/release-name": must be set to "my-release"; annotation validation error: missing key "meta.helm.sh/release-namespace": must be set to "default"
205-
```
206-
207-
So you should add following metadata:
208-
```YAML
209-
metadata:
210-
labels:
211-
"app.kubernetes.io/managed-by": Helm
212-
annotations:
213-
"meta.helm.sh/release-name": my-release
214-
"meta.helm.sh/release-namespace": default
215-
```
216-
</details>

charts/db-operator/README.md.gotmpl

Lines changed: 0 additions & 133 deletions
This file was deleted.

charts/db-operator/crd/kinda.rocks_databases.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,15 @@ spec:
501501
- user
502502
type: object
503503
type: array
504+
host:
505+
type: string
504506
monitorUserSecret:
505507
type: string
506508
operatorVersion:
507509
type: string
510+
port:
511+
format: int32
512+
type: integer
508513
proxyStatus:
509514
description: |-
510515
DatabaseProxyStatus defines whether proxy for database is enabled or not

0 commit comments

Comments
 (0)