Skip to content
This repository has been archived by the owner on May 8, 2022. It is now read-only.

Feature psql direct #5

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
images: bedag/kubernetes-dbaas
images: ${{ secrets.DOCKERHUB_USERNAME }}/kubernetes-dbaas
flavor: latest=false
tags: |
latest
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ config_testing.yaml
.project

# values used for local deployment
myvalues.yaml
myvalues.yaml

# Sensible files
*sensible*

# Binary
kubernetes-dbaas
.env
.secrets
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.16 as builder
FROM docker.io/golang:1.16 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
1 change: 1 addition & 0 deletions apis/config/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion apis/database/v1/database_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ limitations under the License.
package v1

import (
"reflect"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation/field"
"reflect"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -64,6 +65,9 @@ func (r *Database) ValidateUpdate(old runtime.Object) error {

rOld := old.(*Database)

databaselog.Info("validate update", "oldSpec", rOld.Spec)
databaselog.Info("validate update", "newSpec", r.Spec)

if !reflect.DeepEqual(r.Spec, rOld.Spec) {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec"), r.Spec, "update operations not allowed, please explicitly "+
"delete the resource in order to recreate it."))
Expand Down
1 change: 1 addition & 0 deletions apis/database/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/databaseclass/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion charts/kubernetes-dbaas/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
.project
.idea/
*.tmproj
.vscode/
.vscode/
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
controller-gen.kubebuilder.io/version: v0.6.1
creationTimestamp: null
name: databaseclasses.databaseclass.dbaas.bedag.ch
spec:
Expand All @@ -14,56 +14,60 @@ spec:
listKind: DatabaseClassList
plural: databaseclasses
shortNames:
- dbc
- dbc
singular: databaseclass
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: DatabaseClass is the Schema for the databaseclasses API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
- name: v1
schema:
openAPIV3Schema:
description: DatabaseClass is the Schema for the databaseclasses API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: DatabaseClassSpec defines the desired state of DatabaseClass
properties:
driver:
type: string
operations:
additionalProperties:
description: Operation represents an operation performed on a DBMS
identified by name and containing a map of inputs and a map of
outputs.
properties:
inputs:
additionalProperties:
type: string
type: object
name:
type: string
metadata:
type: object
spec:
description: DatabaseClassSpec defines the desired state of DatabaseClass
properties:
driver:
type: string
operations:
additionalProperties:
description: Operation represents an operation performed on a DBMS
identified by name and containing a map of inputs and a map of
outputs.
properties:
dsn:
type: string
inputs:
additionalProperties:
type: string
type: object
type: object
secretFormat:
additionalProperties:
type: string
type: object
name:
type: string
sqlTemplate:
type: string
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
type: object
secretFormat:
additionalProperties:
type: string
type: object
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: databaseclass.dbaas.bedag.ch/v1
kind: DatabaseClass
metadata:
name: databaseclass-sample-psql
spec:
driver: "postgres-direct"
operations:
create:
sqlTemplate: |-
{{- .Files.Get "files/create.sql" | nindent 8}}
inputs:
{{- .Files.Get "files/inputs.yaml" | nindent 8}}
delete:
sqlTemplate: |-
{{- .Files.Get "files/delete.sql" | nindent 8}}
inputs:
{{- .Files.Get "files/inputs.yaml" | nindent 8}}
rotate:
sqlTemplate: |-
{{- .Files.Get "files/rotate.sql" | nindent 8}}
inputs:
{{- .Files.Get "files/inputs.yaml" | nindent 8}}
secretFormat:
{{- .Files.Get "files/secretFormat.yaml" | nindent 4}}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
{{- end }}
labels:
{{- include "kubernetes-dbaas.selectorLabels" . | nindent 8 }}
control-plane: controller-manager
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
12 changes: 8 additions & 4 deletions charts/kubernetes-dbaas/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ replicaCount: 1

image:
# -- Repository of the operator manager image.
repository: bedag/kubernetes-dbaas
pullPolicy: IfNotPresent
repository: basolur/kubernetes-dbaas
pullPolicy: Always
# -- Overrides the image tag whose default is the chart appVersion.
tag: ""
tag: "debug"

imagePullSecrets: []
nameOverride: ""
Expand Down Expand Up @@ -67,7 +67,7 @@ readinessProbe:
periodSeconds: 10

# -- If set to true, enabled the deployment of the RBAC needed to protect the /metrics endpoint.
enableMetricsRbac: true
enableMetricsRbac: false
# -- Namespaces of where Prometheus is deployed. It is required for discovering the ServiceMonitor used to scrape the metrics.
prometheusNamespace: prometheus
# -- Name of the Service Account allowed to scrape the metrics endpoint.
Expand Down Expand Up @@ -100,3 +100,7 @@ operatorConfig:
# specifying the "name" of endpoint to be made available to end-users as well as its connection string (DSN).
# To learn more about the supported DSN formats, see: https://github.com/xo/dburl.
dbms:
- databaseClassName: "databaseclass-sample-psql"
endpoints:
- name: "us-postgres-test"
dsn: "postgres://postgres:Password&1@localhost:5432/postgres"
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@ spec:
identified by name and containing a map of inputs and a map of
outputs.
properties:
dsn:
type: string
inputs:
additionalProperties:
type: string
type: object
name:
type: string
secrets:
additionalProperties:
type: string
type: object
sqlTemplate:
type: string
type: object
type: object
secretFormat:
Expand Down
Loading