-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Refactor sampleexternalplugin to be a Valid Reference Implementation #5116
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
base: master
Are you sure you want to change the base?
Refactor sampleexternalplugin to be a Valid Reference Implementation #5116
Conversation
Hi @nerdeveloper. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: nerdeveloper The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
63b82e0
to
edc4046
Compare
Transform the sample external plugin from mock scaffolding to a realistic working example that demonstrates best practices for external plugin development. Changes: - Replace mock init/create api/webhook commands with meaningful edit command - Add Prometheus ServiceMonitor scaffolding for operator monitoring - Implement PROJECT config reading to align with internal plugin patterns - Add local source replace directive for contributor testing - Update documentation to reflect realistic plugin usage The plugin now serves as a proper reference for: - Reading PROJECT config in external plugins - Scaffolding real, production-ready configurations - Testing plugins against local Kubebuilder source - Adding optional features via the edit subcommand
- Change ProjectConfig tags from json to yaml for correct unmarshaling - Unmarshal directly into ProjectConfig struct instead of config.Config interface - Fix fmt.Sprintf template to pass domain twice for both Service and ServiceMonitor labels - Remove unused config import - Tested plugin successfully generates correct Prometheus monitoring files
…ustomization, update PROJECT file handling, and improve test script
…ry intentionally empty
d42c0be
to
5395def
Compare
Hi @nerdeveloper thanks for the PR! This is a large one and will take some time to review. While you wait for the review, could you please adjust the title so it follows the guidelines for PR titles? Also, could you squash the four commits into one just so we keep the rule of a single commit per PR? Thanks! |
Summary
This PR refactors the
sampleexternalplugin
from outdated mock scaffolding into a realistic, working reference implementation that demonstrates best practices for external plugin development.Problem
The current
sampleexternalplugin
(issue #4824) had several issues:initFile.txt
,apiFile.txt
)Solution
Transformed the plugin into a Prometheus Monitoring Generator that:
edit
subcommand to add optional Prometheus monitoring featuresChanges
Plugin Functionality
init
,create api
,create webhook
subcommandsedit
subcommand that scaffolds Prometheus monitoringconfig/prometheus/monitor.yaml
- ServiceMonitor resourceconfig/prometheus/kustomization.yaml
- Kustomize configconfig/default/kustomization_prometheus_patch.yaml
- Integration instructionsCode Quality
config.Config
APIs like internal pluginsreplace sigs.k8s.io/kubebuilder/v4 => ../../../../../../../
Documentation
external-plugins.md
with realisticedit
command examplesUsage Example
# Add Prometheus monitoring to your operator project kubebuilder edit --plugins sampleexternalplugin/v1
This will scaffold:
Testing
Impact
This PR makes the sample plugin a proper reference that:
Fixes #4824