Skip to content

Commit 1781f88

Browse files
committed
Merge branch 'PLAT-548-1' of github.com:amazeeio/dbaas-operator into PLAT-548-1
2 parents 8c27abe + 00a87b5 commit 1781f88

File tree

61 files changed

+2570
-1361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2570
-1361
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ jobs:
3232
- run:
3333
name: Install KinD
3434
command: |
35-
curl -sLo /tmp/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.7.0/kind-linux-amd64
35+
curl -sLo /tmp/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64
3636
chmod +x /tmp/kind
3737
sudo mv /tmp/kind /usr/local/bin/
3838
- run:
3939
name: Install kubebuilder
4040
command: |
41-
curl -sL https://go.kubebuilder.io/dl/2.2.0/linux/amd64 | tar -xz -C /tmp/
42-
sudo mv /tmp/kubebuilder_2.2.0_linux_amd64 /usr/local/kubebuilder
41+
curl -sL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz | tar -xz -C /tmp/
42+
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64 /usr/local/kubebuilder
4343
- run:
4444
name: Run Tests
4545
command: |
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Image Build and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- 'v*.*.*'
9+
pull_request:
10+
branches:
11+
- 'main'
12+
13+
jobs:
14+
docker:
15+
runs-on: ubuntu-latest
16+
steps:
17+
-
18+
name: Checkout
19+
uses: actions/checkout@v4
20+
-
21+
name: Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v5
24+
with:
25+
# list of Docker images to use as base name for tags
26+
images: |
27+
${{ github.repository_owner }}/dbaas-operator
28+
ghcr.io/${{ github.repository_owner }}/dbaas-operator
29+
-
30+
name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
32+
-
33+
name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
-
36+
name: Login to DockerHub
37+
if: github.event_name != 'pull_request'
38+
uses: docker/login-action@v3
39+
with:
40+
username: ${{ secrets.DOCKERHUB_USERNAME }}
41+
password: ${{ secrets.DOCKERHUB_TOKEN }}
42+
-
43+
name: Login to GHCR
44+
if: github.event_name != 'pull_request'
45+
uses: docker/login-action@v3
46+
with:
47+
registry: ghcr.io
48+
username: ${{ github.repository_owner }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
-
51+
name: Build and push
52+
if: github.event_name != 'pull_request'
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
platforms: linux/amd64,linux/arm64
57+
push: true
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: DBaaS Operator Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test-suite:
13+
runs-on: ubuntu-latest
14+
continue-on-error: ${{ matrix.experimental }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
kindest_node_version: [v1.21.1, v1.22.0]
19+
experimental: [false]
20+
include:
21+
- kindest_node_version: v1.23.0
22+
experimental: true
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: "0"
28+
- name: Setup correct Go version
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version: '1.16'
32+
- name: Install kustomize, kubebuilder, helm
33+
run: |
34+
#kustomize
35+
curl -sLo /tmp/kustomize_v3.5.4_linux_amd64.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.5.4/kustomize_v3.5.4_linux_amd64.tar.gz
36+
sudo tar -C /usr/local/bin -xzf /tmp/kustomize_v3.5.4_linux_amd64.tar.gz
37+
#kubebuilder
38+
curl -sL https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_linux_amd64.tar.gz | tar -xz -C /tmp/
39+
sudo mv /tmp/kubebuilder_2.3.2_linux_amd64 /usr/local/kubebuilder
40+
echo "/usr/local/kubebuilder/bin" >> $GITHUB_PATH
41+
#helm
42+
curl -sL https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz | tar -xz -C /tmp/
43+
sudo mv /tmp/linux-amd64/helm /usr/local/bin/helm
44+
chmod +x /usr/local/bin/helm
45+
- name: Check go, kustomize, kubebuilder, helm, docker compose, kind versions
46+
run: |
47+
go version
48+
kustomize version
49+
helm version
50+
kubebuilder version
51+
kind version
52+
- name: Create kind cluster
53+
uses: helm/kind-action@v1.2.0
54+
with:
55+
node_image: kindest/node:${{ matrix.kindest_node_version }}
56+
# config: test-resources/kind-config.yaml
57+
- name: Set up Docker Buildx
58+
uses: docker/setup-buildx-action@v3
59+
- name: Build
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
load: true
64+
tags: amazeeio/dbaas-operator:test-tag
65+
- name: Run Tests
66+
run: |
67+
make operator-test

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.13 as builder
2+
FROM golang:1.16-alpine3.13 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests
@@ -13,9 +13,10 @@ RUN go mod download
1313
COPY main.go main.go
1414
COPY apis/ apis/
1515
COPY controllers/ controllers/
16+
COPY handlers/ handlers/
1617

1718
# Build
18-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
19+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} GO111MODULE=on go build -a -o manager main.go
1920

2021
# Use distroless as minimal base image to package the manager binary
2122
# Refer to https://github.com/GoogleContainerTools/distroless for more details

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ifeq (, $(shell which controller-gen))
7373
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
7474
cd $$CONTROLLER_GEN_TMP_DIR ;\
7575
go mod init tmp ;\
76-
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.2.4 ;\
76+
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.2 ;\
7777
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
7878
}
7979
CONTROLLER_GEN=$(GOBIN)/controller-gen
@@ -85,7 +85,7 @@ operator-test:
8585
./operator-test.sh
8686

8787
clean:
88-
docker-compose down
88+
docker compose down
8989
kind delete cluster --name ${KIND_NAME}
9090

9191
local-circle:

README.md

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,79 @@
11
# DBaaS Operator
22

3-
This operator is meant to be used as a replacement for the ansible service broker and https://github.com/amazeeio/dbaas-mariadb-apb to run in Kubernetes.
3+
This set of controllers is meant to be used as a replacement for the ansible service broker and https://github.com/amazeeio/dbaas-mariadb-apb to run in Kubernetes.
4+
5+
It allows for provisiong and deprovisioning of shared MySQL/MariaDB, PostgreSQL, and MongoDB databases.
46

57
## Components
8+
### MariaDB/MySQL
69
* MariaDBProvider - These contain the core connection details for a specific provider (AWS RDS, Azure DB for MySQL, etc)
710
* MariaDBConsumer - These contain the specific connection details for a consumer, multiple consumers can be defined in the one namespace and each will get their own specific service endpoints created pointing to the provider.
811

9-
# Developing
10-
## Install Kubebuilder
11-
```
12-
os=$(go env GOOS)
13-
arch=$(go env GOARCH)
12+
### PostgreSQL
13+
* PostgreSQLProvider - These contain the core connection details for a specific provider (AWS RDS primarily or generic postgresql, other cloud providers currently untested)
14+
* PostgreSQLConsumer - These contain the specific connection details for a consumer, multiple consumers can be defined in the one namespace and each will get their own specific service endpoints created pointing to the provider.
1415

15-
# download kubebuilder and extract it to tmp
16-
curl -L https://go.kubebuilder.io/dl/2.2.0/${os}/${arch} | tar -xz -C /tmp/
17-
18-
# move to a long-term location and put it on your path
19-
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
20-
sudo mv /tmp/kubebuilder_2.2.0_${os}_${arch} /usr/local/kubebuilder
21-
export PATH=$PATH:/usr/local/kubebuilder/bin
22-
```
16+
### MongoDB
17+
* MongoDBProvider - These contain the core connection details for a specific provider (Works with AWS DocumentDB, or generic MongoDB with authentication)
18+
* MongoDBConsumer - These contain the specific connection details for a consumer, multiple consumers can be defined in the one namespace and each will get their own specific service endpoints created pointing to the provider.
2319

2420
## Test It Out
25-
This will spin up a local mysql provider, and then start kind and installs the operator and runs some basic tests to confirm the operation of the operator
21+
This will spin up a local mysql, postgresql, and mongodb provider. A kind cluster is started, and the operator is installed, then some basic tests are performed to confirm the providers and consumer provisioning and deprovisioning is successful.
22+
23+
### Using circleci locally
24+
Install the `circleci` tool locally and run the following
2625

27-
Using circleci locally
2826
```
27+
make local-circle
28+
# or
2929
circleci build -v $(pwd):/workdir
3030
```
3131

32+
### Running the tests directly
3233
```
3334
make operator-test
34-
3535
# if at anypoint you need to clean up
3636
make clean
3737
```
3838

39-
# Other
40-
## Dashboard
41-
```
42-
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta6/aio/deploy/recommended.yaml
43-
kubectl apply -f test-resources/dashboard-rbac.yaml
44-
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
45-
kubectl proxy
46-
```
47-
4839
## Code references
4940

50-
* Most of the logic for the operator is in `controllers/`
51-
* Spec definitions are in `api/v1/*_types.go`
41+
* Most of the logic for the controllers located in `controllers/<mariadb/postgres/mongodb>/`
42+
* Spec definitions are in `api/<mariadb/postgres/mongodb>/v*/*_types.go`
5243

5344
## Config samples
5445

5546
* located in `config/samples`
5647

57-
# Update Helm Charts
48+
# Updating Helm Charts
49+
50+
* Update Helmchart and increase version in `Chart.yaml` and `values.yaml` as required
51+
* run `helm package charts/dbaas-operator -d charts/`
52+
* run `helm package charts/mariadbprovider -d charts/`
53+
* run `helm package charts/postgresqlprovider -d charts/`
54+
* run `helm package charts/mongodbprovider -d charts/`
55+
* run `helm repo index charts`
56+
57+
# Developing
58+
## Install Kubebuilder
59+
```
60+
os=$(go env GOOS)
61+
arch=$(go env GOARCH)
62+
63+
# download kubebuilder and extract it to tmp
64+
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.2.0/kubebuilder_2.2.0_${os}_${arch}.tar.gz | tar -xz -C /tmp/
5865
59-
* Update Helmchart and increase version in `Chart.yaml`
60-
* run `helm package charts/dbaas-operator -d charts/` and `helm package charts/mariadbprovider -d charts/`
61-
* run `helm repo index charts`
66+
# move to a long-term location and put it on your path
67+
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
68+
sudo mv /tmp/kubebuilder_2.2.0_${os}_${arch} /usr/local/kubebuilder
69+
export PATH=$PATH:/usr/local/kubebuilder/bin
70+
```
71+
72+
# Other
73+
## Dashboard
74+
```
75+
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta6/aio/deploy/recommended.yaml
76+
kubectl apply -f test-resources/dashboard-rbac.yaml
77+
kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
78+
kubectl proxy
79+
```

charts/dbaas-operator-0.1.10.tgz

4.45 KB
Binary file not shown.

charts/dbaas-operator-0.1.9.tgz

4.46 KB
Binary file not shown.

charts/dbaas-operator-0.2.1.tgz

4.62 KB
Binary file not shown.

charts/dbaas-operator-0.2.2.tgz

4.67 KB
Binary file not shown.

0 commit comments

Comments
 (0)