Skip to content

feat: implement ConnectorTemplate and Connector#59

Merged
g1eny0ung merged 31 commits intohstreamdb:mainfrom
g1eny0ung:feat/impl-connector
Oct 30, 2023
Merged

feat: implement ConnectorTemplate and Connector#59
g1eny0ung merged 31 commits intohstreamdb:mainfrom
g1eny0ung:feat/impl-connector

Conversation

@g1eny0ung
Copy link
Contributor

Close #57. The following is an informal RFC:

This RR creates two kinds to support deploying hstream io connectors into clusters. One is ConnectorTemplate, and another is Connector (Hereafter referred to as CT and C). CT is used to store shared configurations, and C is used to deploy connectors by streams. Typically, you should first create a CT and then create a C that references the CT by name.

After creating a CT, a ConfigMap is automatically generated to store the shared configuration. If a C references this CT (via the templateName field), it will clone a ConfigMap and apply some specific parameters (if have). After the cloned ConfigMap is created, the C will create a Deployment to deploy the connector into the cluster.

The overall process is straightforward. Currently, you can think of this PR as an MVP (Minimum viable product), so only the sink-elasticsearch connector is supported for now.

Examples:

sink-es-template.yaml

apiVersion: apps.hstream.io/v1beta1
kind: ConnectorTemplate
metadata:
  name: sink-es-template
  namespace: hstream-connector
spec:
  type: sink-elasticsearch
  config: |
    {
      "auth": "basic",
      "username": "elastic",
      "password": "a-password",
      "buffer.enableBackgroundFlush": false,
      "buffer.batch.maxAge": 0,
      "buffer.batch.maxBytesSize": 0,
      "scheme": "http",
      "hosts": "localhost:9200",
      "task.error.maxRetries": 3,
      "task.error.skipStrategy": "SkipAll",
      "task.reader.fromOffset": "EARLIEST"
    }

sink-es.yaml

apiVersion: apps.hstream.io/v1beta1
kind: Connector
metadata:
  name: sink-es
  namespace: hstream-connector
spec:
  type: sink-elasticsearch
  templateName: sink-es-template
  streams:
    - stream01
    - stream02
  patches:
    stream01:
      offsetStream: stream01-offset
      index: index01
    stream02:
      offsetStream: stream02-offset
      index: index02
  hserverEndpoint: hstreamdb-sample-internal-hserver.hstreamdb:6570

@g1eny0ung g1eny0ung requested a review from Rory-Z as a code owner October 19, 2023 09:06
@codecov
Copy link

codecov bot commented Oct 19, 2023

Codecov Report

Attention: 82 lines in your changes are missing coverage. Please review.

Comparison is base (4fccd69) 83.90% compared to head (5884400) 82.73%.

❗ Current head 5884400 differs from pull request most recent head 0f34d01. Consider uploading reports for the commit 0f34d01 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
- Coverage   83.90%   82.73%   -1.18%     
==========================================
  Files          31       38       +7     
  Lines        2057     2398     +341     
==========================================
+ Hits         1726     1984     +258     
- Misses        237      302      +65     
- Partials       94      112      +18     
Files Coverage Δ
api/v1beta1/connector_types.go 100.00% <100.00%> (ø)
api/v1beta1/connector_utils.go 100.00% <100.00%> (ø)
api/v1beta1/connectortemplate_types.go 100.00% <100.00%> (ø)
mock/connector.go 100.00% <100.00%> (ø)
mock/connectortemplate.go 100.00% <100.00%> (ø)
...nternal/controller/connectortemplate_controller.go 60.00% <60.00%> (ø)
internal/controller/connector_controller.go 73.61% <73.61%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Set owners instead of manually control finalizers
Copy link
Collaborator

@Rory-Z Rory-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the APIVersion is v1beta1, and I think we should also synchronize the APIVersion of other CRDs to v1beta1 in another PR.

@g1eny0ung
Copy link
Contributor Author

I noticed that the APIVersion is v1beta1, and I think we should also synchronize the APIVersion of other CRDs to v1beta1 in another PR.

Okay for me.

@g1eny0ung
Copy link
Contributor Author

Since sink-es has recently provided a metrics interface for Prometheus to use. I've to make the pod container ports to be customized. Prometheus operator will also rely on annotations to discover pods, so I decided to let users define these annotations in Connector and copy them to the generated pods.

@g1eny0ung g1eny0ung merged commit bffc6e2 into hstreamdb:main Oct 30, 2023
@g1eny0ung g1eny0ung deleted the feat/impl-connector branch October 30, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Connector kind

2 participants