Resources
Source: hello-pepr-store-resources
Pepr Store is backed by Kubernetes Custom Resources that can be accessed directly as PeprStore objects.
Behind the scenes, the Pepr Store API (Store.setItem(), Store.getItem(), etc.) uses a Custom Resource Definition called PeprStore to persist data in the cluster.
This example demonstrates how Store operations create and update PeprStore resources in Kubernetes.
Key Points
Section titled “Key Points”- All Store operations for a capability are persisted in a single PeprStore CRD
- The PeprStore resource lives in the
pepr-systemnamespace - Store keys can include special characters like
://(e.g., URLs) - Store data is stored as key-value string pairs in the
datafield - Store updates are batched and sent to the Kubernetes API at 5-second intervals
- The Store is eventually consistent, backed by etcd through Kubernetes
When to Use
Section titled “When to Use”Use this pattern when you need to:
- Inspect Store data directly using kubectl for debugging
- Understand how Store operations map to Kubernetes resources
- Verify that Store data is being persisted correctly
- Access Store data from outside your Pepr module
- Troubleshoot Store-related issues by examining the underlying CRD
Code Example
Section titled “Code Example”View full example on Github
When(a.ConfigMap) .IsCreated() .WithName("observe") .Watch(async function observeWatch() { Store.setItem("a", "1"); Store.setItem("b", "2"); Store.setItem("c", "3"); await Store.setItemAndWait("https://observed", "yay"); Log.info("observed"); });Example pod log output:
Section titled “Example pod log output:”{"level":30,"time":1726798504518,"pid":16,"hostname":"pepr-watcher-6dc69654c9-5ql6b","msg":"observed"}Viewing the PeprStore Resource
Section titled “Viewing the PeprStore Resource”You can inspect the PeprStore Custom Resources using kubectl:
# List all PeprStore resourceskubectl get peprstores -n pepr-system
# Get detailed YAML output for a specific storekubectl get peprstore <store-name> -n pepr-system -o yamlExample PeprStore YAML:
Section titled “Example PeprStore YAML:”After the Store operations execute, the PeprStore resource will contain:
apiVersion: pepr.dev/v1kind: PeprStoremetadata: name: pepr-<module-uuid>-store-hello-pepr-store-resources namespace: pepr-systemdata: a: "1" b: "2" c: "3" https://observed: "yay"