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

Pepr K8s-native state system #173

Closed
jeff-mccoy opened this issue Jun 27, 2023 · 0 comments · Fixed by #180
Closed

Pepr K8s-native state system #173

jeff-mccoy opened this issue Jun 27, 2023 · 0 comments · Fixed by #180
Labels
enhancement New feature or request

Comments

@jeff-mccoy
Copy link
Member

As we've started to develop use cases for Pepr, it is becoming apparent that there are times when you need to share data between different Capabilities and CapabilityActions. After discussing several ways we might do this, @bburky @cmwylie19 @bdw617 @rjferguson21 and I landed on the general idea for persisting shared state within K8s and maintaining an automated watch system for changes. More thoughts and details are below:

Problem: we need to share data, and using K8s resource metadata exclusively is cumbersome and brittle. One option is to generate more K8s resources, which is more complex and slower and requires resource cleanup.

Idea: define a simple key-value store native to Pepr core and transparently available for users of the SDK. More details:

  • Leverage a K8s CRD/CR (PeprStore) for pepr to maintain key-value state data per-capability
  • Provide an API that generally matches the Web Storage API
  • A watcher for all PeprStore resources (watchers are batch operations) that updates the internal state of the object for read
  • A Store method available from Capabilities to bind data
  • This can be exported for sharing data between Capabilities
// Use the 'When' function to create a new Capability Action, 'Store' to persist data
const { When, Store } = HelloPepr;

// Save some data to the store
Store.setItem("hello-pepr", "Hello Pepr!");

// Add an item to the store
Store.setItem("hello-pepr-2", "Hello Pepr! I'm a second item!");

// Read the data back from the store
console.log(Store.getItem("hello-pepr"));

// Update the data in the store
Store.setItem("hello-pepr", "Hello Pepr! I've been updated!");

// Get the length of the store
console.log(Store.length);

// Delete an item from the store
Store.removeItem("hello-pepr");

// Clear the store
Store.clear();
  • Discuss write operations: batching, collisions, performance, failures, etc
  • Discuss read/write contracts: i.e., don't return write until successful persistence, require force K8s resource get before returning a read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant