Skip to content

Conversation

@barney-s
Copy link
Contributor

Related PR that triggered this doc: #631

@barney-s barney-s requested review from a-hilaly and matthchr August 19, 2025 16:13
@barney-s barney-s mentioned this pull request Aug 19, 2025
Copy link
Member

@jakobmoellerdev jakobmoellerdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM. Just thinking we should really start unifying everything and not keep the old labels.

Copy link
Contributor

@fabianburth fabianburth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@barney-s barney-s added this to the 0.5 milestone Aug 20, 2025
barney-s added a commit to barney-s/kro that referenced this pull request Aug 21, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels and remove old labels
- Add new testcase for nested RGD and update existing testcase labels
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
barney-s added a commit to barney-s/kro that referenced this pull request Aug 21, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels and remove old labels
- Add new testcase for nested RGD and update existing testcase labels
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
barney-s added a commit to barney-s/kro that referenced this pull request Aug 21, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels
- Add deprecate TODO for old labels
- Add new testcase for nested RGD and update existing testcase labels
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
barney-s added a commit to barney-s/kro that referenced this pull request Aug 21, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels
- Add deprecate TODO for old labels
- Add new testcase for nested RGD and update existing testcase labels
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
barney-s added a commit to barney-s/kro that referenced this pull request Aug 21, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels
- Add deprecate TODO for old labels
- Add new testcase for nested RGD and update existing testcase labels
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
barney-s added a commit to barney-s/kro that referenced this pull request Aug 25, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels
- Add deprecate TODO for old labels
- Add new testcase for nested RGD and update existing testcase labels
- Add docs
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
- **Purpose:** To identify which RGD was used as a template to create a resource during the reconciliation of an instance. This label will be applied to all resources created by the instance controller.
- **Alternative Names:**
- kro.run/created-by-rgd
- kro.run/managed-by-rgd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think managed-by probably fits best since we continuously work on it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we have kro.run/managed-by-rgd it could be reused for the instance too. Is there a specific need to have two labels here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thats the whole point of the proposal.
I guess the problem statement did not do a good job. Let me know how i can update the problem statement to make the need for 2 labels more apparent.

- kro.run/instance-namespace: default
- **Proposed Labels:**
- `kro.run/managed-by-instance-group`: The API group of the instance (e.g., `mygroup.example.com`).
- `kro.run/managed-by-instance-kind`: The kind of the instance (e.g., `MyKind`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you define a group+kind, don't you also need to define a version?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

kro.run/instance: production/my-web-app  # namespace/name format
kro.run/instance-gvk: myapp.io/v1/WebService  # optional for additional context ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another approach would be to just include an RGD ref?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by RGD Ref ? in the ownerrefs ?

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 12, 2025
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting this together @barney-s ! you've identified an important issue - the current labeling scheme is definitely confusing with both resource-graph-definition-id and resource-graph-definition-name without clear semantics.

- kro.run/instance-namespace: default
- **Proposed Labels:**
- `kro.run/managed-by-instance-group`: The API group of the instance (e.g., `mygroup.example.com`).
- `kro.run/managed-by-instance-kind`: The kind of the instance (e.g., `MyKind`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

kro.run/instance: production/my-web-app  # namespace/name format
kro.run/instance-gvk: myapp.io/v1/WebService  # optional for additional context ?

- kro.run/instance-namespace: default
- **Proposed Labels:**
- `kro.run/managed-by-instance-group`: The API group of the instance (e.g., `mygroup.example.com`).
- `kro.run/managed-by-instance-kind`: The kind of the instance (e.g., `MyKind`).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another approach would be to just include an RGD ref?

barney-s added a commit to barney-s/kro that referenced this pull request Sep 17, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels
- Add deprecate TODO for old labels
- Add new testcase for nested RGD and update existing testcase labels
- Add docs
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
barney-s added a commit to barney-s/kro that referenced this pull request Sep 26, 2025
- Based on proposal: kubernetes-sigs#639
- Move to new labels
- Add deprecate TODO for old labels
- Add new testcase for nested RGD and update existing testcase labels
- Add docs
- Have separate instance labellers for different reconcile paths.
  This is needed when we have RGD2 instance in RGD1 resources.
  Today both paths use the same label resulting in conflict.
  path 1: RGD2.instance created as part of an RGD1 instance reconciliation
  path 2: RGD2.instance reconciled by RGD2 reconciler
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: barney-s

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 11, 2025
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 11, 2025
@k8s-ci-robot k8s-ci-robot removed the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 11, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 11, 2025
@barney-s
Copy link
Contributor Author

@jakobmoellerdev @a-hilaly @matthchr - Please Take a look at this updated proposal.

@barney-s barney-s force-pushed the labels-proposal branch 2 times, most recently from 95048ee to 9c1b2a3 Compare October 12, 2025 00:03
Copy link
Member

@jakobmoellerdev jakobmoellerdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this is looking good to go. Thanks a lot for the investment @barney-s !

@a-hilaly a-hilaly modified the milestones: 0.5, 0.6 Oct 21, 2025
@a-hilaly a-hilaly removed this from the 0.6 milestone Oct 29, 2025

## Problem statement

The current labels in KRO are used to track ownership and metadata of resources managed by the orchestrator. While these labels provide essential information, they lack a clear and standardized way to represent the relationships between different KRO components, such as ResourceGraphDefinitions (RGDs), instances, and the resources they generate. This ambiguity can make it difficult to query for related objects and understand the provenance of resources within a cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be interesting to remind about the current set of annotations/labels to better understand the problem and how it gets fixed

Comment on lines +34 to +36
- `kro.run/instance-gvk: mygroup.example.com/v1/MyKind`: The Group Version Kind (GVK) of the instance
- `kro.run/instance: default/my-instance`: The namespace and name of the instance.
- `app.kubernetes.io/instance: MyKind/default/my-instance`: Kind namespace and name of the instance
Copy link
Contributor

@tjamet tjamet Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Labels are extremely useful to select resources kubectl -n my-namespace get X -l my=label and identify them in a human readable manner.

Given that we refer to 2 owning objects, would it make sense to rather use dns notation:

instance.kro.run/apiVersion: mygroup.example.com/v1
instance.kro.run/kind: MyKind
instance.kro.run/name: my-instance
instance.kro.run/namespace: my-namespace
rgd.kro.run/name: some-rgd
rgd.kro.run/apiVersion: kro.run/v1alpha1
app.kubernetes.io/instance: MyKind/default/my-instance

that way we can easily perform different queries kubectl -n my-namespace get X -l instance.kro.run/kind to get all namespaced resources deployed by a certain kind, kubectl -n my-namespace get -A X -l instance.kro.run/name=my-instance

- To identify which RGD was used as a template to create a resource during the reconciliation of an instance. This label will be applied to all resources created by the instance controller.
- **Proposed Labels:**
- `kro.run/part-of: my-rgd-name` - The name of the ResourceGraphDefinition
- `app.kubernetes.io/part-of: my-rgd-name`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need both?

- Currently we dont differentiate, it results in a conflict (https://github.com/kro-run/kro/pull/631)
- To indicate that an instance is being actively reconciled against a specific RGD. This label will be applied to the instance itself.
- **Proposed Labels:**
- `kro.run/managed-by-rgd: my-rgd-name` - name of the ResourceGraphDefinition that reconciles the instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

instance.kro.run/managed-by: my-rgd-name

Could it help reveal the hierarchy for humans?

## Other solutions considered

1. We could continue using the existing labels, but their purpose is not as explicit for relationship tracking, which can lead to confusion for users and client tools.
2. We could also use annotations, but labels are better suited for this purpose as they are queryable via the Kubernetes API, which is a key requirement for observability and tooling.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest 1 or 2 annotations for programmatic access that include IDs

for example

instance.kro.run/reference: {"apiVersion": "kro.run/v1alpha1", "kind": "MyKind", "resource": "mykinds", "namespace": "default", "name": "my-instance", "id": "$id"}
rgd.kro.run/reference: {"apiVersion": "kro.run/v1", "name": "my-rgd", "id": "${id}"}

ID would help reconcilers detect that the instance (or RGD) was fully replaced between 2 reconciliation loops

- Updating the instance controller to apply these labels to instances and created resources during reconciliation.
- Updating the official KRO documentation to reflect the new labels and their usage.
- Adding docs reflecting the new labels. Old labels would not be documented.
- Deprecate old labels in next minor release or the one after that.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't 1-2 versions a bit short?
Are we confident most users will upgrade to migrate all their labels?

#### Test plan

- **Unit tests:** Add unit tests for any new labeler functions in `pkg/metadata/labels.go` to ensure they construct the correct labels.
- **Integration tests:**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want a migration test, to ensure we don't mess up deployed objects with the new version.

We may also want to ensure that in case users jumps directly from the current labels layout to the proposed one (i.e. skip the transition versions) kro keeps running as expected

Copy link
Contributor

@tjamet tjamet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good. i left some comments for discussion

@k8s-ci-robot
Copy link
Contributor

@barney-s: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
presubmits-build-image 642aef4 link true /test presubmits-build-image
presubmits-integration-tests 642aef4 link true /test presubmits-integration-tests
presubmits-e2e-tests 642aef4 link true /test presubmits-e2e-tests
presubmits-verify-lint 642aef4 link true /test presubmits-verify-lint

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants