Hey everyone! A while back at work, I needed to create PrometheusRule objects dynamically for specific Deployments and StatefulSets across different namespaces. So, I developed a small controller that watches those resources and generates the related PrometheusRule whenever it detects one. Then I thought, why not broaden the concept? I turned it into a hobby project named Kroc (Kubernetes Reactive Object Creator). The main idea is to configure the operator to monitor any Kubernetes object, and when that object is created, it automatically generates one or more 'child' resources that can reference properties from the parent object. I primarily built this to enhance my Go programming skills and learn more about the Kubebuilder framework. Now, I'm curious about its potential usefulness beyond my specific scenario. I'm looking for your feedback on a few things: 1. Do you think this could be practical in real-world Kubernetes clusters? 2. Are there any interesting use cases that come to mind? 3. Was there a better approach to automate my original PrometheusRule issue? 4. Any concerns or things I should reconsider? If you're interested, you can check out the project on GitHub! Thanks for your insights!
3 Answers
This is actually the approach many operators take—creating objects in response to others. In our setup, we have an interconnected suite of resources functioning this way. The challenge in generalizing this lies in the unique business logic for each use case, though.
Thanks for sharing your work! I've been using Kyverno for similar tasks and find it quite effective.
Just a heads up, this concept is already present in the Kubernetes world with a project called Kro. It's similar in name, but it’s great that you’re exploring this for learning purposes!

Kroc actually stands apart from Kro and Crossplane. It can monitor existing Kubernetes resources without altering them, which makes it non-invasive. On the flip side, Kro and Crossplane let you define new composite CRDs, simplifying the creation of multiple objects via a single custom resource.