Skip to content

Commit f6d1307

Browse files
authored
Update CRDs to v1beta1 (#12)
Now, `CRDs` are put in the `./templates` folder. If you don't want `helm` to manage them, you can set `Values.crds.install: false`.
1 parent 74a1f9d commit f6d1307

File tree

23 files changed

+935
-223
lines changed

23 files changed

+935
-223
lines changed

.github/workflows/chart-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
1919

@@ -23,7 +23,7 @@ jobs:
2323
git config user.email "[email protected]"
2424
2525
- name: Install Helm
26-
uses: azure/setup-helm@v1
26+
uses: azure/setup-helm@v3
2727
with:
2828
version: v3.9.4
2929

.github/workflows/test.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
changed_charts: ${{ steps.get-chart.outputs.changed_charts }}
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919
with:
2020
path: charts
2121
fetch-depth: 2 # to be able to obtain files changed in the latest commit
@@ -33,16 +33,16 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- name: Checkout
36-
uses: actions/checkout@v2
36+
uses: actions/checkout@v3
3737
with:
3838
fetch-depth: 0
3939

40-
- uses: actions/setup-python@v2
40+
- uses: actions/setup-python@v3
4141
with:
4242
python-version: 3.7
4343

4444
- name: Install Helm
45-
uses: azure/setup-helm@v1
45+
uses: azure/setup-helm@v3
4646
with:
4747
version: v3.9.4
4848

@@ -61,7 +61,7 @@ jobs:
6161
k8s_version: ['v1.21.6', 'v1.22.3', 'v1.23.1', 'v1.24.3']
6262
steps:
6363
- name: Checkout
64-
uses: actions/checkout@v2
64+
uses: actions/checkout@v3
6565

6666
# The existing apparmor profile for mysql needs to be removed.
6767
# https://github.com/actions/virtual-environments/issues/181
@@ -70,6 +70,7 @@ jobs:
7070
run: |
7171
set -x
7272
sudo apt-get remove mysql-server --purge
73+
sudo apt-get update -y
7374
sudo apt-get install apparmor-profiles
7475
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
7576
@@ -78,8 +79,11 @@ jobs:
7879
K8S_VERSION: ${{ matrix.k8s_version }}
7980
run: make k3d
8081

82+
- name: Install Cert Manager
83+
run: make cert-manager
84+
8185
- name: Install Helm chart
8286
run: make db-operator
8387

8488
- name: Integration test
85-
run: ./tests/db-operator/integration.sh
89+
run: ./tests/db-operator/integration.sh

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,11 @@ lint: ## lint helm manifests
1515
@helm lint -f charts/db-operator/values.yaml -f charts/db-operator/ci/ci-1-values.yaml --strict ./charts/db-operator
1616
@helm lint -f charts/db-instances/values.yaml --strict ./charts/db-instances
1717

18+
cert-manager: ## install cert-manager chart if not exist and install local chart using helm upgrade --install command
19+
@helm repo add jetstack https://charts.jetstack.io
20+
@helm repo update
21+
@helm upgrade --install --create-namespace --namespace cert-manager cert-manager jetstack/cert-manager --set installCRDs=true
22+
1823
db-operator: ## install db-operator chart if not exist and install local chart using helm upgrade --install command
19-
@helm upgrade --install --create-namespace --namespace operator my-dboperator charts/db-operator -f charts/db-operator/values.yaml -f charts/db-operator/values-local.yaml
24+
@helm upgrade --install --create-namespace --namespace operator my-dboperator charts/db-operator -f charts/db-operator/values.yaml -f charts/db-operator/values-local.yaml
25+
@kubectl rollout status deploy/db-operator -n operator

charts/db-instances/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ apiVersion: v1
22
appVersion: "1.0"
33
description: Database Instances for db operator
44
name: db-instances
5-
version: 1.3.4
5+
version: 1.4.0

charts/db-instances/templates/dbinstance.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{- if .Values.dbinstances }}
44
{{- range $name, $value := .Values.dbinstances }}
55
---
6-
apiVersion: "kci.rocks/v1alpha1"
6+
apiVersion: "kci.rocks/v1beta1"
77
kind: "DbInstance"
88
metadata:
99
name: {{ $name }}

charts/db-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
type: application
33
## All supported k8s versions are in the test: https://github.com/kloeckner-i/db-operator/blob/master/.github/workflows/build-and-test.yaml
44
kubeVersion: ">= 1.21-prerelease"
5-
appVersion: "1.9.1"
5+
appVersion: "1.10.0"
66
description: A Database Operator
77
name: db-operator
8-
version: 1.5.1
8+
version: 1.7.0

charts/db-operator/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
# db-operator
22
DB Operator is Kubernetes operator
33

4+
## Upgrading to `v1.10.0`
5+
CRDs are moved to the `templates` folder, so now they are part of the release. It means that when migration you will get errors about resource ownership. 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.
6+
7+
For example:
8+
9+
```BASH
10+
$ helm upgrade my-release .
11+
Error: UPGRADE FAILED: rendered manifests contain a resource that already exists. Unable to continue with update: CustomResourceDefinition "databases.kci.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"
12+
```
13+
14+
So you should add following metadata:
15+
```YAML
16+
metadata:
17+
labels:
18+
"app.kubernetes.io/managed-by": Helm
19+
annotations:
20+
"meta.helm.sh/release-name": my-release
21+
"meta.helm.sh/release-namespace": default
22+
```
23+
424
## Installing Chart
525
To install the chart with the release name my-release:
626
```

charts/db-operator/crds/kci.rocks_dbinstances.yaml

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

charts/db-operator/crds/readme.md

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.webhook.certificate.create }}
2+
---
3+
apiVersion: cert-manager.io/v1
4+
kind: Certificate
5+
metadata:
6+
name: {{ .Values.webhook.certificate.name }}
7+
spec:
8+
dnsNames:
9+
- {{ .Values.webhook.serviceName }}.{{ .Release.Namespace }}.svc
10+
- {{ .Values.webhook.serviceName }}.{{ .Release.Namespace }}.svc.cluster.local
11+
issuerRef:
12+
kind: {{ .Values.webhook.certificate.issuer.kind }}
13+
name: {{ .Values.webhook.certificate.issuer.name }}
14+
secretName: {{ .Values.webhook.certificate.secretName }}
15+
{{- end }}

0 commit comments

Comments
 (0)