Skip to content
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

Annotate CRD structs with categories #1650

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Conversation

Baarsgaard
Copy link
Contributor

@Baarsgaard Baarsgaard commented Aug 26, 2024

Background

Kubernetes CRD definitions support a nifty categories field which is a list of strings that can be used for grouping CRs together under umbrella terms.
An example of this is Istio resources all having the category istio-io

Reason

Making use of categories allows for a pleasant way of listing all resources in a given scope.
And it is currently necessary to write pretty long commands to get an overview of all Grafana-Operator CRs in a cluster:

# Examples
kubectl get grafanas,grafanadashboards -A
# Or when using completions
kubectl get grafanas.grafana.integreatly.org,grafanadashboards.grafana.integreatly.org -A

> NAMESPACE    NAME                                           VERSION   STAGE      STAGE STATUS   AGE
> monitoring   grafana.grafana.integreatly.org/kind-grafana   11.1.3    complete   success        5d

> NAMESPACE   NAME                                            NO MATCHING INSTANCES   LAST RESYNC   AGE
> default     grafanadashboard.grafana.integreatly.org/dash                           38s           38s

Solution

Annotating CRD structs to generate with categories: grafanacrs and grafana-operator

// GrafanaSpec defines the desired state of Grafana
+ // +kubebuilder:resource:categories={grafanacrs,grafana-operator}
type GrafanaSpec struct {
# Alternative command which finds everything
> kubectl get grafana-operator -A
NAMESPACE   NAME                                            NO MATCHING INSTANCES   LAST RESYNC   AGE
default     grafanadashboard.grafana.integreatly.org/dash                           57s           57s

NAMESPACE    NAME                                                 NO MATCHING INSTANCES   AGE
default      grafanafolder.grafana.integreatly.org/test-folder2                           9m13s
monitoring   grafanafolder.grafana.integreatly.org/test-folder                            9m13s

NAMESPACE    NAME                                           VERSION   STAGE      STAGE STATUS   AGE
monitoring   grafana.grafana.integreatly.org/kind-grafana   11.1.3    complete   success        5d

Primary questions

  • Is this wanted?
  • Names of the categories?
  • One category or multiple?
  • What documentation would make sense to write on this?

@Baarsgaard Baarsgaard marked this pull request as ready for review September 1, 2024 05:38
@theSuess
Copy link
Member

theSuess commented Sep 2, 2024

Thanks for the PR, this is a cool feature! We discussed this today and in our opinion grafanacrs doesn't really "vibe". grafana-operator should be enough as a category.

Hope this makes sense, and we'll merge this once the category has been changed!

@Baarsgaard
Copy link
Contributor Author

Glad to hear you were interested, I have removed the the extra grafanacrs category and left in the grafana-operator

@theSuess theSuess added this pull request to the merge queue Sep 3, 2024
Merged via the queue into grafana:master with commit 4255eb3 Sep 3, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants