Skip to content

Commit

Permalink
Druid DB Connection (#71)
Browse files Browse the repository at this point in the history
## Description

This PR refactors the init process and adds a new custom resource for druid connections.

The Init resource is now called SupersetDB and also tracks a status. it is first `Provisioned`. If possible (secret also deployed) a kubernetes `Job` is started and the status of the CR becomes `Initializing`. The job is watched, and depending on whether it successfully completes or not, the SupersetDB also becomes `Ready` or `Failed` respectively.

This change allows us to also depend on the DB being ready (or not). This is necessary for writing the druid connection information into the DB.

A new CRD is introduced: `DruidConnection`. It holds information about the superset DB it should write to, and the Druid cluster that should be connected. A new controller watches the discovery config map as well as the superset DB resources. Once all the dependencies are there (and `Ready`) a job is started, and the status is updated, just like it is done for the `SupersetDB`.

This is in line with the declarative philosophy of k8s; the spec reflects the desired state and the status tracks the actual underlying cluster. Also, with multiple controllers watching object states, control flow is delegated a bit to the API server. Before we were watching the job state manually, now we react to status changes which are given to us by the API server. The controllers only react to object changes.

This PR also relies on the Druid Discovery PR stackabletech/druid-operator#102

What wasn't done: If the DruidConnection resource is deleted, the actual connection is not deleted. The issue doesn't say that this is necessary, and there is no obvious, documented way to delete data sources from the commandline, we'd have to go into the database and delete stuff there. On the controller side we can use a [finalizer](https://github.com/kube-rs/kube-rs/blob/d90ee9706923ceddf94c3d50928bc390543af2fc/examples/secret_syncer.rs#L92-L102).



Co-authored-by: Felix Hennig <[email protected]>
  • Loading branch information
fhennig and fhennig committed Feb 1, 2022
1 parent cd9823b commit a2169f8
Show file tree
Hide file tree
Showing 29 changed files with 1,313 additions and 531 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

## [Unreleased]

### Added

- Druid DB connections can now be configured in a custom resource ([#71]).

### Changed

- Shut down gracefully ([#70]).
- All dependencies upgraded. The upgrade to operator-rs 0.8.0 does not
force the credentials secret to be set anymore in the custom resource
but it is still required ([#82]).
- - `operator-rs` `0.8.0``0.9.0` ([#71])

[#70]: https://github.com/stackabletech/superset-operator/pull/70
[#71]: https://github.com/stackabletech/superset-operator/pull/71
[#82]: https://github.com/stackabletech/superset-operator/pull/82

## [0.2.0] - 2021-12-17
Expand Down
33 changes: 17 additions & 16 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ["rust/crd", "rust/operator-binary"]

73 changes: 73 additions & 0 deletions deploy/crd/druidconnection.crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: druidconnections.superset.stackable.tech
spec:
group: superset.stackable.tech
names:
categories: []
kind: DruidConnection
plural: druidconnections
shortNames: []
singular: druidconnection
scope: Namespaced
versions:
- additionalPrinterColumns: []
name: v1alpha1
schema:
openAPIV3Schema:
description: "Auto-generated derived type for DruidConnectionSpec via `CustomResource`"
properties:
spec:
properties:
druid:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
superset:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
required:
- druid
- superset
type: object
status:
nullable: true
properties:
condition:
enum:
- Pending
- Importing
- Ready
- Failed
type: string
startedAt:
description: Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.
format: date-time
nullable: true
type: string
required:
- condition
type: object
required:
- spec
title: DruidConnection
type: object
served: true
storage: true
subresources:
status: {}
15 changes: 7 additions & 8 deletions deploy/crd/supersetcluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ spec:
properties:
spec:
properties:
credentialsSecret:
type: string
loadExamplesOnInit:
nullable: true
type: boolean
nodes:
nullable: true
properties:
Expand All @@ -32,10 +37,6 @@ spec:
type: object
config:
default: {}
properties:
credentialsSecret:
default: ""
type: string
type: object
configOverrides:
additionalProperties:
Expand All @@ -59,10 +60,6 @@ spec:
type: object
config:
default: {}
properties:
credentialsSecret:
default: ""
type: string
type: object
configOverrides:
additionalProperties:
Expand Down Expand Up @@ -125,6 +122,8 @@ spec:
description: Desired Superset version
nullable: true
type: string
required:
- credentialsSecret
type: object
status:
nullable: true
Expand Down
40 changes: 18 additions & 22 deletions deploy/crd/init.crd.yaml → deploy/crd/supersetdb.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,57 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: inits.command.superset.stackable.tech
name: supersetdbs.superset.stackable.tech
spec:
group: command.superset.stackable.tech
group: superset.stackable.tech
names:
categories: []
kind: Init
plural: inits
kind: SupersetDB
plural: supersetdbs
shortNames: []
singular: init
singular: supersetdb
scope: Namespaced
versions:
- additionalPrinterColumns: []
name: v1alpha1
schema:
openAPIV3Schema:
description: "Auto-generated derived type for InitCommandSpec via `CustomResource`"
description: "Auto-generated derived type for SupersetDBSpec via `CustomResource`"
properties:
spec:
properties:
clusterRef:
description: "A reference to a [`SupersetCluster`]"
properties:
name:
nullable: true
type: string
namespace:
nullable: true
type: string
type: object
credentialsSecret:
type: string
loadExamples:
type: boolean
supersetVersion:
type: string
required:
- clusterRef
- credentialsSecret
- loadExamples
- supersetVersion
type: object
status:
nullable: true
properties:
finishedAt:
description: Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.
format: date-time
nullable: true
condition:
enum:
- Pending
- Initializing
- Ready
- Failed
type: string
startedAt:
description: Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON. Wrappers are provided for many of the factory methods that the time package offers.
format: date-time
nullable: true
type: string
required:
- condition
type: object
required:
- spec
title: Init
title: SupersetDB
type: object
served: true
storage: true
Expand Down
Loading

0 comments on commit a2169f8

Please sign in to comment.