Skip to content

CRD scope reset to Namespaced on YAML generation #1650

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

Closed
NicolasT opened this issue Jul 8, 2019 · 4 comments · Fixed by #1652
Closed

CRD scope reset to Namespaced on YAML generation #1650

NicolasT opened this issue Jul 8, 2019 · 4 comments · Fixed by #1652
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@NicolasT
Copy link

NicolasT commented Jul 8, 2019

There's documentation on how to turn a scaffolded CRD into a cluster-scoped one, which works. However, when re-generating the OpenAPI CRD manifests, the CRD scope gets reset to Namespaced, which requires special care / manual reverts / ... It'd be nice if somehow the scope of a CRD could be declared somewhere, and this being honoured by the code generator.

For reference: https://kubernetes.slack.com/archives/CAW0GV7A5/p1562255836345700

@lilic
Copy link
Member

lilic commented Jul 8, 2019

cc @hasbro17 What do you think of the above feature request, as you worked on the operator scopes.

@lilic lilic added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 8, 2019
@estroz
Copy link
Member

estroz commented Jul 8, 2019

@NicolasT add the type comment // +genclient:nonNamespaced to your kind and the scope will be set to Cluster, like so:

// Memcached is the Schema for the memcacheds API
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
// +genclient:nonNamespaced
type Memcached struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   MemcachedSpec   `json:"spec,omitempty"`
	Status MemcachedStatus `json:"status,omitempty"`
}

Apologies for the lack of documentation on codegen annotations. We are in the process of refactoring the SDK to use controller-runtime/tools v0.2.0, which will have a complete list of new API annotations available that we will link to.

@estroz estroz self-assigned this Jul 8, 2019
@hasbro17
Copy link
Contributor

hasbro17 commented Jul 8, 2019

I'll update the cluster scope doc with the requirement of // +genclient:nonNamespaced tag.
But hopefully we should have a complete list of supported CRD generation tags documented soon.

@NicolasT
Copy link
Author

NicolasT commented Jul 9, 2019

That was fast 😄 I'll test this later today, but seems very reasonable, thanks for getting back! Looking forward to see more documentation about the available annotations.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants