pepr 0.13.4 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/README.md +25 -5
  2. package/commitlint.config.js +1 -0
  3. package/dist/cli.js +375 -204
  4. package/dist/controller.js +1 -1
  5. package/dist/lib/assets/deploy.d.ts.map +1 -1
  6. package/dist/lib/assets/destroy.d.ts +2 -0
  7. package/dist/lib/assets/destroy.d.ts.map +1 -0
  8. package/dist/lib/assets/index.d.ts +6 -5
  9. package/dist/lib/assets/index.d.ts.map +1 -1
  10. package/dist/lib/assets/networking.d.ts +6 -5
  11. package/dist/lib/assets/networking.d.ts.map +1 -1
  12. package/dist/lib/assets/pods.d.ts +84 -4
  13. package/dist/lib/assets/pods.d.ts.map +1 -1
  14. package/dist/lib/assets/rbac.d.ts +6 -4
  15. package/dist/lib/assets/rbac.d.ts.map +1 -1
  16. package/dist/lib/assets/store.d.ts +7 -0
  17. package/dist/lib/assets/store.d.ts.map +1 -0
  18. package/dist/lib/assets/webhooks.d.ts +2 -2
  19. package/dist/lib/assets/webhooks.d.ts.map +1 -1
  20. package/dist/lib/assets/yaml.d.ts.map +1 -1
  21. package/dist/lib/capability.d.ts +21 -4
  22. package/dist/lib/capability.d.ts.map +1 -1
  23. package/dist/lib/controller/index.d.ts +10 -0
  24. package/dist/lib/controller/index.d.ts.map +1 -0
  25. package/dist/lib/controller/store.d.ts +7 -0
  26. package/dist/lib/controller/store.d.ts.map +1 -0
  27. package/dist/lib/filter.d.ts +2 -2
  28. package/dist/lib/filter.d.ts.map +1 -1
  29. package/dist/lib/{k8s/types.d.ts → k8s.d.ts} +14 -25
  30. package/dist/lib/k8s.d.ts.map +1 -0
  31. package/dist/lib/metrics.d.ts +12 -12
  32. package/dist/lib/metrics.d.ts.map +1 -1
  33. package/dist/lib/module.d.ts +25 -4
  34. package/dist/lib/module.d.ts.map +1 -1
  35. package/dist/lib/mutate-processor.d.ts +3 -3
  36. package/dist/lib/mutate-processor.d.ts.map +1 -1
  37. package/dist/lib/mutate-request.d.ts +11 -10
  38. package/dist/lib/mutate-request.d.ts.map +1 -1
  39. package/dist/lib/storage.d.ts +56 -0
  40. package/dist/lib/storage.d.ts.map +1 -0
  41. package/dist/lib/tls.d.ts.map +1 -0
  42. package/dist/lib/types.d.ts +28 -48
  43. package/dist/lib/types.d.ts.map +1 -1
  44. package/dist/lib/validate-processor.d.ts +2 -2
  45. package/dist/lib/validate-processor.d.ts.map +1 -1
  46. package/dist/lib/validate-request.d.ts +9 -8
  47. package/dist/lib/validate-request.d.ts.map +1 -1
  48. package/dist/lib/watch-processor.d.ts +3 -0
  49. package/dist/lib/watch-processor.d.ts.map +1 -0
  50. package/dist/lib.d.ts +3 -7
  51. package/dist/lib.d.ts.map +1 -1
  52. package/dist/lib.js +484 -807
  53. package/dist/lib.js.map +4 -4
  54. package/package.json +20 -22
  55. package/src/lib/assets/deploy.ts +69 -127
  56. package/src/lib/assets/destroy.ts +33 -0
  57. package/src/lib/assets/index.ts +8 -14
  58. package/src/lib/assets/networking.ts +28 -5
  59. package/src/lib/assets/pods.ts +130 -11
  60. package/src/lib/assets/rbac.ts +42 -4
  61. package/src/lib/assets/store.ts +49 -0
  62. package/src/lib/assets/webhooks.ts +2 -2
  63. package/src/lib/assets/yaml.ts +13 -3
  64. package/src/lib/capability.ts +69 -14
  65. package/src/lib/{controller.ts → controller/index.ts} +25 -23
  66. package/src/lib/controller/store.ts +197 -0
  67. package/src/lib/filter.ts +2 -2
  68. package/src/lib/{k8s/types.ts → k8s.ts} +15 -26
  69. package/src/lib/metrics.ts +22 -38
  70. package/src/lib/module.ts +47 -10
  71. package/src/lib/mutate-processor.ts +6 -6
  72. package/src/lib/mutate-request.ts +18 -26
  73. package/src/lib/storage.ts +128 -0
  74. package/src/lib/types.ts +30 -53
  75. package/src/lib/validate-processor.ts +5 -4
  76. package/src/lib/validate-request.ts +15 -19
  77. package/src/lib/watch-processor.ts +55 -0
  78. package/src/lib.ts +4 -8
  79. package/src/templates/capabilities/hello-pepr.ts +54 -5
  80. package/src/templates/package.json +1 -0
  81. package/dist/lib/controller.d.ts +0 -10
  82. package/dist/lib/controller.d.ts.map +0 -1
  83. package/dist/lib/fetch.d.ts +0 -23
  84. package/dist/lib/fetch.d.ts.map +0 -1
  85. package/dist/lib/k8s/index.d.ts +0 -7
  86. package/dist/lib/k8s/index.d.ts.map +0 -1
  87. package/dist/lib/k8s/kinds.d.ts +0 -12
  88. package/dist/lib/k8s/kinds.d.ts.map +0 -1
  89. package/dist/lib/k8s/tls.d.ts.map +0 -1
  90. package/dist/lib/k8s/types.d.ts.map +0 -1
  91. package/dist/lib/k8s/upstream.d.ts +0 -4
  92. package/dist/lib/k8s/upstream.d.ts.map +0 -1
  93. package/jest.config.json +0 -4
  94. package/journey/before.ts +0 -21
  95. package/journey/k8s.ts +0 -100
  96. package/journey/pepr-build.ts +0 -69
  97. package/journey/pepr-deploy.ts +0 -174
  98. package/journey/pepr-dev.ts +0 -155
  99. package/journey/pepr-format.ts +0 -13
  100. package/journey/pepr-init.ts +0 -12
  101. package/src/lib/fetch.ts +0 -76
  102. package/src/lib/k8s/index.ts +0 -14
  103. package/src/lib/k8s/kinds.ts +0 -531
  104. package/src/lib/k8s/upstream.ts +0 -53
  105. /package/dist/lib/{k8s/tls.d.ts → tls.d.ts} +0 -0
  106. /package/src/lib/{k8s/tls.ts → tls.ts} +0 -0
package/README.md CHANGED
@@ -12,10 +12,15 @@
12
12
 
13
13
  Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating glue code, bash scripts, and other makeshift solutions. As a Kubernetes controller, Pepr empowers you to define Kubernetes transformations using TypeScript, without software development expertise thanks to plain-english configurations. Pepr transforms a patchwork of forks, scripts, overlays, and other chaos into a cohesive, well-structured, and maintainable system. With Pepr, you can seamlessly transition IT ops tribal knowledge into code, simplifying documentation, testing, validation, and coordination of changes for a more predictable outcome.
14
14
 
15
+ #### _Note: Pepr is still in active development so breaking changes may occur, but will be documented in release notes._
16
+
15
17
  ## Features
16
18
 
17
- - Zero-config K8s webhook mutations and validations.
19
+ - Zero-config K8s webhook mutations and validations
20
+ - Automatic leader-elected K8s resource watching
21
+ - Lightweight async key-value store backed by K8s for stateful operations with the [Pepr Store](./docs/store.md)
18
22
  - Human-readable fluent API for generating [Pepr Capabilities](#capability)
23
+ - A fluent API for creating/modifying/watching and server-side applying K8s resources via [Kubernetes Fluent Client](https://github.com/defenseunicorns/kubernetes-fluent-client)
19
24
  - Generate new K8s resources based off of cluster resource changes
20
25
  - Perform other exec/API calls based off of cluster resources changes or any other arbitrary schedule
21
26
  - Out of the box airgap support with [Zarf](https://zarf.dev)
@@ -27,7 +32,7 @@ Pepr is on a mission to save Kubernetes from the tyranny of YAML, intimidating g
27
32
 
28
33
  ## Example Pepr Action
29
34
 
30
- This quick sample shows how to react to a ConfigMap being created or updated in the cluster. It adds a label and annotation to the ConfigMap and adds some data to the ConfigMap. Finally, it logs a message to the Pepr controller logs. For more see [actions](./docs/actions.md).
35
+ This quick sample shows how to react to a ConfigMap being created or updated in the cluster. It adds a label and annotation to the ConfigMap and adds some data to the ConfigMap. It also creates a Validating Webhook to make sure the "pepr" label still exists. Finally, after the ConfigMap is created, it logs a message to the Pepr controller and creates or updates a separate ConfigMap with the [kubernetes-fluent-client](https://github.com/defenseunicorns/kubernetes-fluent-client) using server-side apply. For more details see [actions](./docs/actions.md) section.
31
36
 
32
37
  ```ts
33
38
  When(a.ConfigMap)
@@ -54,12 +59,28 @@ When(a.ConfigMap)
54
59
 
55
60
  // Reject the ConfigMap if it doesn't have the label
56
61
  return request.Deny("ConfigMap must have a unicorn label");
62
+ })
63
+ // Watch behaves like controller-runtime's Manager.Watch()
64
+ .Watch(async (cm, phase) => {
65
+ Log.info(cm, `ConfigMap was ${phase}.`);
66
+
67
+ // Apply a ConfigMap using K8s server-side apply (will create or update)
68
+ await K8s(kind.ConfigMap).Apply({
69
+ metadata: {
70
+ name: "pepr-ssa-demo",
71
+ namespace: "pepr-demo-2",
72
+ },
73
+ data: {
74
+ uid: cm.metadata.uid,
75
+ },
76
+ });
57
77
  });
58
78
  ```
59
79
 
60
80
  ## Prerequisites
61
81
 
62
- - [Node.js](https://nodejs.org/en/) v18.0.0+.
82
+ - [Node.js](https://nodejs.org/en/) v18.0.0+ (even-numbered releases only).
83
+ - To ensure compatability and optimal performance, it is recommended to use even-numbered releases of Node.js as they are stable releases and receive long-term support for three years. Odd-numbered releases are experimental and may not be supported by certain libraries utilized in Pepr.
63
84
 
64
85
  - Recommended (optional) tools:
65
86
  - [Visual Studio Code](https://code.visualstudio.com/) for inline debugging and [Pepr Capabilities](#capability) creation.
@@ -104,7 +125,7 @@ Action is a discrete set of behaviors defined in a single function that acts on
104
125
 
105
126
  For example, an action could be responsible for adding a specific label to a Kubernetes resource, or for modifying a specific field in a resource's metadata. Actions can be grouped together within a Capability to provide a more comprehensive set of operations that can be performed on Kubernetes resources.
106
127
 
107
- There are both `Mutate()` and `Validate()` Actions that can be used to modify or validate Kubernetes resources.
128
+ There are both `Mutate()` and `Validate()` Actions that can be used to modify or validate Kubernetes resources within the admission controller lifecycle. There is also a `Watch()` Action that can be used to watch for changes to Kubernetes resources that already exist.
108
129
 
109
130
  See [actions](./docs/actions.md) for more details.
110
131
 
@@ -116,4 +137,3 @@ See [actions](./docs/actions.md) for more details.
116
137
  ## TypeScript
117
138
 
118
139
  [TypeScript](https://www.typescriptlang.org/) is a strongly typed, object-oriented programming language built on top of JavaScript. It provides optional static typing and a rich type system, allowing developers to write more robust code. TypeScript is transpiled to JavaScript, enabling it to run in any environment that supports JavaScript. Pepr allows you to use JavaScript or TypeScript to write capabilities, but TypeScript is recommended for its type safety and rich type system. You can learn more about TypeScript [here](https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html).
119
-
@@ -0,0 +1 @@
1
+ module.exports = { extends: ["@commitlint/config-conventional"] };