Comments (2)
This is great. Thankyou @camilamacedo86 !
from kubebuilder.
Hi @shach33,
Yes, you can accomplish that. It's important to understand that when you're creating a Custom Resource Definition (CRD) and its associated controller, you're essentially managing specific aspects of your Kubernetes cluster that are tailored to your business or solution's needs. For instance, consider Controller A, which is responsible for managing a custom resource, Thing A. To effectively manage Thing A within your cluster, you would typically need to interact with various Kubernetes objects such as Services and Deployments. This management is done within Controller A, where you'll import and manage these objects.
Similarly, you can also manipulate another CRD, let's call it CRD B, from within the controller for CRD A. This is particularly useful for cases where one resource depends on another.
Therefore, in other words, when you extend the K8s API and create your OWN APIs/CRDs you can use at the same way that you use the K8S ones. So, at the same way that you for example watch a ConfigMap you can watch a "Your OWN Kind X" and go on.
Example Solution
Take, for example, a project where one CRD represents a database and another CRD represents a backup process. It wouldn't be practical to initiate a backup if the database it depends on doesn't exist. Hence, within the backup's controller, there's functionality to monitor the database CR in the cluster to ensure that backups are only attempted when the database is present and to gather necessary information from the database for the backup process.
See:
- Project to Manage a Postgree Database: https://github.com/dev4devs-com/postgresql-operator
- See that we are watching resources created by the Database Controller: https://github.com/dev4devs-com/postgresql-operator/blob/master/pkg/controller/backup/controller.go#L60-L63
Please note that the project mentioned above is somewhat outdated and uses older syntax and Kubernetes API versions. However, it serves as a valuable example to understand the concept and the operational dynamics between different CRDs and their controllers.
To know more about:
- See watching: https://book.kubebuilder.io/reference/watching-resources
- See getting started: https://book.kubebuilder.io/getting-started (15 min it will give a very good idea over how the things work)
- See: https://book.kubebuilder.io/cronjob-tutorial/gvks (it will help you out understand the APIs)
I am closing this one, since I think the above info answer your question.
however, feel free to re-open or open new issues as you see fit.
from kubebuilder.
Related Issues (20)
- Title: Storage Error and Duplicate Reconciliation Leading to Resource Synchronization Issue HOT 1
- Error to scaffold conversion webhooks HOT 4
- ERROR: Invalid or corrupt Go version HOT 1
- Evaludate and Apply Latest Lint Rules and Features HOT 5
- cannot be handled as a CronJob unknown field HOT 2
- docs/scaffold: reconciler client and its methods should be private HOT 3
- Support +enum tags in k8s APIs HOT 4
- [META - Phases]: Discontinue Kube RBAC Proxy in Default Kubebuilder Scaffolding HOT 4
- Add in the docs a link for the controller-runtime FAQ
- Implement e2e controller tests for the multi-version sample used in the docs HOT 1
- Use Upgrade Assistance to re-generate samples docs HOT 1
- Update the Multi-Version tutorial programatically when we run `make generate` HOT 4
- kubebuilder make install fails [again]: metadata.annotations: Too long HOT 1
- OpenAPI Schema Validation Errors for imagePullSecrets and hostAliases for CronjobTutorial sample with controller-runtime v0.18.3 and Kubernetes 1.30 HOT 3
- pull controller image failed HOT 2
- DNS Entry for book-v3 - We need figure out how to create it to publish the legacy docs HOT 1
- kustomize: strategicMergePatch clobbers patched arrays HOT 1
- GitHub page link update HOT 3
- RFE: Replace ServiceMonitor for PodMonitor HOT 3
- book.kubebuilder.io no longer reachable / dns record issing HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubebuilder.