You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📖 Refactor sampleexternalplugin to be a valid reference implementation
Transform the sample external plugin from mock scaffolding to a realistic
Prometheus monitoring generator that demonstrates best practices for external
plugin development.
Key changes:
- Implement init and edit subcommands that scaffold Prometheus instance manifests
- Add PROJECT config reading to align with internal plugin patterns
- Replace mock ServiceMonitor with complete Prometheus CR including RBAC
- Add --namespace flag support to demonstrate argument passing
- Update documentation with realistic examples showing argument usage
- Fix error handling to properly validate PROJECT file existence
- Centralize kustomization in config/default/kustomization.yaml (no separate prometheus kustomization)
- Provide clear instructions for users to add Prometheus resources manually
The plugin now serves as a proper reference implementation for:
- Reading PROJECT configuration in external plugins
- Scaffolding production-ready Kubernetes manifests
- Supporting command-line arguments (--namespace flag)
- Testing plugins against local Kubebuilder source
- Adding optional monitoring features via edit subcommand
- Following Kubebuilder's centralized kustomization pattern
Addresses maintainer feedback on PR kubernetes-sigs#5116 including proper error handling,
argument passing examples, realistic manifest generation, and centralized kustomization.
Fixeskubernetes-sigs#4824
Copy file name to clipboardExpand all lines: docs/book/src/plugins/extending/external-plugins.md
+27-20Lines changed: 27 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,17 @@ structures.
71
71
}
72
72
```
73
73
74
+
**Example `PluginRequest` (triggered by `kubebuilder edit --plugins sampleexternalplugin/v1 --namespace monitoring`):**
75
+
76
+
```json
77
+
{
78
+
"apiVersion": "v1alpha1",
79
+
"args": ["--namespace", "monitoring"],
80
+
"command": "edit",
81
+
"universe": {}
82
+
}
83
+
```
84
+
74
85
### PluginResponse
75
86
76
87
`PluginResponse` contains the modifications made by the plugin to the project. This data is serialized as JSON and returned to Kubebuilder through `stdout`.
@@ -79,13 +90,15 @@ structures.
79
90
```json
80
91
{
81
92
"apiVersion": "v1alpha1",
82
-
"command": "init",
93
+
"command": "edit",
83
94
"metadata": {
84
-
"description": "The `init` subcommand initializes a project via Kubebuilder. It scaffolds a single file: `initFile`.",
0 commit comments