Comments (9)
Hi @yaa110,
See that the value is generated here: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/v4/scaffolds/internal/templates/main.go#L282
LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}",
So, can you please share with us what values do you use to to create the project?
How we can reproduce it so that it can help us to fix it?
from kubebuilder.
This one seems to be a good first issue.
What we need to do here:
- a) First, we must see if we can reproduce the described issue. To do so, create a new project and ensure that the LeaderElection is enabled in the
cmd/main.go
. ( See: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/cmd/main.go#L62C2-L64C77 ) If not, then we can close this one - b) IF we are able to reproduce then, we need to change the implementation https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/v4/scaffolds/internal/templates/main.go#L282 to ensure that we are generating a random valid value. Also, we should ensure that this scenario is validated in the e2e tests. So, we need to change the test for go/v4 to deploy the project with leaderElection enabled, see: https://github.com/kubernetes-sigs/kubebuilder/tree/master/test/e2e/v4
from kubebuilder.
Hey @camilamacedo86 I can take a look on this issue
from kubebuilder.
I need some steps to get started as I am new contributor
from kubebuilder.
Thank you @camilamacedo86. According to the source code you shared, the issue is connected to the empty domain value I set for the init command:
kubebuilder init --domain "" --repo github.com/blah/blah --project-name mykind
kubebuilder create api --group domain.com --version v1 --kind MyKind
It would be nice to also take this situation into consideration.
from kubebuilder.
Great job !!! thank you for check this one
kubebuilder init --domain "" --repo github.com/blah/blah --project-name mykind
So, the root cause is to empty the domain.
Why should we allow that? Why did you create the project with an empty domain?
Therefore, just adding a validation to ensure it fails should be enough.
I do not know if other options will properly work with an empty domain.
Would you like to push a PR so we add validation and do not allow this scenario?
WDYT?
from kubebuilder.
@camilamacedo86 I intended to use an API group of domain.com
. Therefore, if I had set the domain, I would have expected to create the following resource sample, which was deemed unacceptable (observe the value of the apiVersion
field):
using:
kubebuilder init --domain "domain.com" --repo github.com/blah/blah --project-name mykind
kubebuilder create api --group domain.com --version v1 --kind MyKind
generates:
apiVersion: domain.com.domain.com/v1
kind: MyKind
spec: {}
however, using aforementioned commands (with empty domain), generates:
apiVersion: domain.com/v1
kind: MyKind
spec: {}
Is it a bad idea to leave the domain blank? Does it cause issues beyond the leader election ID? Wouldn't it be better to allow the domain to be empty and change the templating code accordingly to support it?
{{ if .Domain }}
LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}",
{{ else }}
LeaderElectionID: "{{ hashFNV .Repo }}",
{{ end }}
from kubebuilder.
Maybe I can check and see if I need to submit a PR
from kubebuilder.
Hi @yaa110,
The "domain" and "group" serve different purposes in structuring and naming resources. A "domain" usually refers to the base DNS domain name used for all resources, serving as a namespace to group them under a common name, preventing conflicts across different projects or organizations.
A "group", on the other hand, is a subdivision within the domain that categorizes related kinds of resources, allowing for clearer organization and resource management within the domain.
Example if your base domain is example.com, you might define a resource in the ships group. The full API Group for a resource named Sloop would be ships.example.com.
So, the domain should be filled with the domain of your project.
Using empty domains in Kubernetes could bring issues like:
- Naming Conflicts: Easier creation of resources that might conflict with others, potentially causing overwrites or interference.
- Identification Problems: Complications in identifying or categorizing resources, affecting management and deployments.
- Integration Challenges: Potential difficulties in integrating with tools or systems that expect domain-based naming conventions.
Therefore, I thought in not allow empty domains. However, others might either done the same.
In this way, the second option approach might be as you suggested use only the repo instead of the repo + domain seems OK too
I am OK within as well if you want to push this change.`
replace: "{{ hashFNV .Repo }}.{{ .Domain }}",
with: LeaderElectionID: "{{ hashFNV .Repo }}", (ONLY when the domain is not informed)
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 2
- 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 2
- 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.