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

Data Model orchestration #10

Open
beasteers opened this issue Jan 10, 2023 · 4 comments
Open

Data Model orchestration #10

beasteers opened this issue Jan 10, 2023 · 4 comments

Comments

@beasteers
Copy link

I'm trying to deploy directus as part of an automatic CI/CD pipeline (with terraform) so that instances can be brought up and down automatically.

Ideally, I'd like to synchronize directus's snapshot so that it can be instantiated from a github repo. I'm thinking of adding some sidecars such as git-sync and another sidecar that runs npx directus schema snapshot --yes ./snapshot.yaml periodically to dump the current schema so that it can be picked up by git-sync and uploaded to github.

So all that needs to be done to the chart for that part is to add the ability to add sidecars to the deployment.


But the second part is how to apply the snapshot to directus. The obvious answer is to use an initcontainer and to mount the snapshot as a config map, but it would need to be careful to not overwrite changes that a user makes through the UI.

That leads me to think that there is room for an extension that synchronizes the schema with a local file

  • Listen to data model change events -> write snapshot to file
    • (I don't see data model changes in the events listed 😥)
  • Watch for file change events -> apply snapshot
    • (Can use kiwigrid/k8s-sidecar with REQ_URL and the extension could have a custom endpoint to do the apply)

Then you'd use git-sync to sync the file with github.

I'm wondering if anyone else has a similar use case?

tl;dr - looking for a robust way to sync the directus data model with git

@kyuumeitai
Copy link

I'm a total k8s noob but I was wondering the same thing.

@kyuumeitai
Copy link

Hi @beasteers ! is this relevant to what you're trying to achieve?

directus/directus#14713

@beasteers
Copy link
Author

Oooo that's great! I love when features you've been searching for were merged "last week" 🌈 Thanks so much for the heads up 🙏🏻

There's still a question of synchronization, but the API endpoints make it much easier to decouple that functionality from the container.

@fr3fou
Copy link

fr3fou commented Jun 2, 2023

Have you figured anything new out yet? @beasteers
I was thinking of a similar idea, but instead of using sidecar for applying the schema snapshots, I'd use ArgoCD's PreSync resource hook https://argo-cd.readthedocs.io/en/stable/user-guide/resource_hooks to run a container which applies the snapshot using the Directus API.

I haven't figured out a way to reliably dump the snapshots though -- the schema can be changed both in a remote deployment (e.g staging / dev) or locally.

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

No branches or pull requests

3 participants