Skip to content

Commit 95048ee

Browse files
committed
Addressing review comments
1 parent f06ebe7 commit 95048ee

File tree

1 file changed

+49
-22
lines changed

1 file changed

+49
-22
lines changed

docs/design/proposals/labels.md

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,70 @@ This aligns with the common Kubernetes practice of using labels for discovery an
2929
We will introduce the following new labels, which will be defined in `@pkg/metadata/labels.go`:
3030

3131
1. **Label for an instance being reconciled:**
32-
- **Proposed Label:** `kro.run/reconciled-by`
33-
- **Value:** The name of the ResourceGraphDefinition (e.g., `my-rgd-name`).
34-
- **Purpose:** To indicate that an instance is being actively reconciled against a specific RGD. This label will be applied to the instance itself.
35-
- **Alternative Names:** `kro.run/reconciling-rgd`, `kro.run/template`.
32+
- **Purpose:** To indicate that an instance is being actively reconciled against a specific RGD. This label will be applied to the instance itself.
33+
- **Proposed Label:**
34+
- `kro.run/managed-by-rgd: my-rgd-name` - name of the ResourceGraphDefinition
35+
- **Existing Labels:**
36+
- `kro.run/resource-graph-definition-id: 761e8fb7-14d5-4da1-b4f9-0a16fc334d6c`
37+
- `kro.run/resource-graph-definition-name: my-rgd-name`
38+
- Conflicts with label used in creation path for nested RGD (https://github.com/kro-run/kro/pull/631)
3639

3740
2. **Label for resources created during instance reconciliation:**
38-
- **Proposed Label:** `kro.run/created-by`
39-
- **Value:** The name of the ResourceGraphDefinition (e.g., `my-rgd-name`).
40-
- **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.
41-
- **Alternative Names:** `kro.run/managed-by-rgd`, `kro.run/owner-rgd`, `kro.run/template-rgd`. The `managed-by` label is a common pattern in the Kubernetes ecosystem.
41+
- **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.
42+
- **Proposed Label:**
43+
- `kro.run/part-of: my-rgd-name` - The name of the ResourceGraphDefinition
44+
- `app.kubernetes.io/part-of: my-rgd-name`
45+
- **Existing Labels:**
46+
- `kro.run/resource-graph-definition-id: 761e8fb7-14d5-4da1-b4f9-0a16fc334d6c`
47+
- `kro.run/resource-graph-definition-name: my-rgd-name`
4248

4349
3. **Labels for resources to link back to the instance:**
44-
- **Proposed Labels:**
45-
- `kro.run/managed-by-instance-group`: The API group of the instance (e.g., `mygroup.example.com`).
46-
- `kro.run/managed-by-instance-kind`: The kind of the instance (e.g., `MyKind`).
47-
- `kro.run/managed-by-instance-namespace`: The namespace of the instance (e.g., `default`).
48-
- `kro.run/managed-by-instance-name`: The name of the instance (e.g., `my-instance`).
49-
- The `managed-by` label is a common pattern in the Kubernetes ecosystem.
50-
- **Purpose:** To provide a direct and queryable link from a created resource back to the instance that caused its creation. This set of labels uniquely identifies the instance.
51-
- **Alternative Name prefix:** `kro.run/owner-`, `kro.run/created-by-`, etc.
50+
- **Purpose:** To provide a direct and queryable link from a created resource back to the instance that caused its creation. This set of labels uniquely identifies the instance.
51+
- **Proposed Labels:**
52+
- `kro.run/instance-gvk: mygroup.example.com/v1/MyKind`: The Group Version Kind (GVK) of the instance
53+
- `kro.run/instance: default/my-instance`: The namespace and name of the instance.
54+
- `app.kubernetes.io/instance: MyKind/default/my-instance`: Kind namespace and name of the instance
55+
- **Existing Label:**
56+
- `kro.run/instance-id: 6e6a1d95-4855-4062-b51b-8f288cb96365`
57+
- `kro.run/instance-name: test-instance`
58+
- `kro.run/instance-namespace: default`
59+
60+
4. **Kubernetes Common Labels:**
61+
- **Purpose:** Conforming to standard/common k8s labels allows easier integration across tools in k8s ecosystem.
62+
- **Proposed Labels:**
63+
- `app.kubernetes.io/managed-by: KRO` : Fixed value
5264

5365
## Other solutions considered
5466

55-
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. 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.
67+
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.
68+
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.
69+
3. Use common k8s labels: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/
70+
* `app.kubernetes.io/name: mysql`
71+
* `app.kubernetes.io/instance: mysql-abcxyz`
72+
* `app.kubernetes.io/version: 5.7.21`
73+
* `app.kubernetes.io/component: database`
74+
* `app.kubernetes.io/part-of: wordpress`
75+
* `app.kubernetes.io/managed-by: Helm`
76+
5677

5778
## Scoping
5879

5980
#### What is in scope for this proposal?
6081

61-
- Defining and adding the new labels to the KRO API.
62-
- Updating the instance controller to apply these labels to instances and created resources during reconciliation.
63-
- Updating the official KRO documentation to reflect the new labels and their usage.
82+
- Defining and adding the new labels to the KRO API.
83+
- Updating the instance controller to apply these labels to instances and created resources during reconciliation.
84+
- Updating the official KRO documentation to reflect the new labels and their usage.
85+
- Adding docs reflecting the new labels. Old labels would not be documented.
86+
- Deprecate old labels in next minor release or the one after that.
6487

6588
#### What is not in scope?
6689

67-
- Removing or deprecating the existing labels. This could be considered in a future proposal to maintain backward compatibility.
68-
- Changing how KRO uses annotations.
90+
- Tracking UID od RGD, Instance in the labels. We need to handle recreation of parent resources where UID changes. Can be a future enhancement.
91+
- Supporting deeply nested RGDs. When RGD1 created RGD2 and that creates RGD3, do we add labels in objects of RGD3 linking it back to RGD2 and RGD1 ?
92+
- Changing how KRO uses annotations.
93+
- Changing these existing labels:
94+
- kro.run/kro-version: v0.4.0
95+
- kro.run/owned: "true"
6996

7097
## Testing strategy
7198

0 commit comments

Comments
 (0)