Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New EventTrigger CRD to create Jobs for status changes in the VerticaDB #377

Merged
merged 48 commits into from
Apr 26, 2023

Conversation

albertogg
Copy link
Contributor

@albertogg albertogg commented Apr 17, 2023

We need the ability to run arbitrary scripts immediately following a new database creation. This is intended to be used for cases where specific DB initialization is required before the database can be used by apps. We are going to take advantage of the Job type and have the operator create the job when the DB is initialized. This will be handled in a separate custom resource, called the EventTrigger.

The new CRD will allow you to specify what object and states to watch. And it will have a job template in it that will get constructed when the event matches the desired condition. The first use case will look at specific conditions in the VerticaDB. But it is generic enough so that we could extend it for other events in the future -- a future use case that we may want is to watch a secret and update Vertica when its contents change.

This runs as a separate controller in our existing operator pod.

A sample EventTrigger CR is as follows. This will create a user table (T1) right after the VerticaDB completes its database creation.

apiVersion: vertica.com/v1beta1
kind: EventTrigger
metadata:
  name: eventtrigger-sample
spec:
  references:
  - object:
      apiVersion: vertica.com/v1beta1
      kind: VerticaDB
      name: verticadb-sample
  matches:
  - condition:
      type: DBInitialized
      status: "True"
  template:
    metadata:
      generateName: create-user-table-
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: main
            image: "vertica/vertica-k8s:latest"
            command: ["/opt/vertica/bin/vsql", "-h", "verticadb-sample-defaultsubcluster", "-c", "CREATE TABLE T1 (C1 INT);"]

@CLAassistant
Copy link

CLAassistant commented Apr 17, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Some early comments. I'll take another pass tomorrow.

pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/createet_reconciler_test.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler_test.go Outdated Show resolved Hide resolved
api/v1beta1/eventtrigger_webhook.go Show resolved Hide resolved
Alberto Grespan added 3 commits April 20, 2023 17:04
We want to share this functionality among other ET reconcilers.
Copy link
Collaborator

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

It's looking in good shape. Just a few more comments. But, I think we are really close here.

pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
api/v1beta1/eventtrigger_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/eventtrigger_webhook_test.go Outdated Show resolved Hide resolved
api/v1beta1/eventtrigger_webhook.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler.go Outdated Show resolved Hide resolved
pkg/controllers/et/verticadbref_reconciler_test.go Outdated Show resolved Hide resolved
Alberto Grespan and others added 3 commits April 21, 2023 17:23
This is needed to maintain the CHANGELOG when we create a new GitHub
release.
@spilchen spilchen changed the title Event Trigger New EventTrigger CRD to create Jobs for status changes in the VerticaDB Apr 24, 2023
@spilchen spilchen changed the base branch from vnext to main April 26, 2023 15:26
@spilchen spilchen merged commit d871665 into vertica:main Apr 26, 2023
@albertogg albertogg deleted the vnext branch April 26, 2023 15:44
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.

3 participants