From 7867bc07fa611b19cd56f19a6097032c832092ed Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Mon, 28 Apr 2025 16:31:53 +0200 Subject: [PATCH] [k8s] Introduce semantic conventions for k8s CronJob labels and annotations (#2172) Signed-off-by: odubajDT --- .chloggen/cronjob-labels-annotations.yaml | 22 ++++++++++++++++++++++ docs/attributes-registry/k8s.md | 18 ++++++++++++------ docs/resource/k8s.md | 6 ++++++ model/k8s/registry.yaml | 16 ++++++++++++++++ model/k8s/resources.yaml | 4 ++++ 5 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 .chloggen/cronjob-labels-annotations.yaml diff --git a/.chloggen/cronjob-labels-annotations.yaml b/.chloggen/cronjob-labels-annotations.yaml new file mode 100644 index 000000000..b94e781bc --- /dev/null +++ b/.chloggen/cronjob-labels-annotations.yaml @@ -0,0 +1,22 @@ +# Use this changelog template to create an entry for release notes. +# +# If your change doesn't affect end users you should instead start +# your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the area of concern in the attributes-registry, (e.g. http, cloud, db) +component: k8s + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Introduce semantic conventions for k8s CronJob labels and annotations" + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +# The values here must be integers. +issues: [2138] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/docs/attributes-registry/k8s.md b/docs/attributes-registry/k8s.md index a7494f3ba..2eb700c80 100644 --- a/docs/attributes-registry/k8s.md +++ b/docs/attributes-registry/k8s.md @@ -17,6 +17,8 @@ Kubernetes resource attributes. | `k8s.container.name` | string | The name of the Container from Pod specification, must be unique within a Pod. Container runtime usually uses different globally unique name (`container.name`). | `redis` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.container.restart_count` | int | Number of times the container was restarted. This attribute can be used to identify a particular container (running or stopped) within a container spec. | | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.container.status.last_terminated_reason` | string | Last terminated reason of the Container. | `Evicted`; `Error` | ![Development](https://img.shields.io/badge/-development-blue) | +| `k8s.cronjob.annotation.` | string | The annotation key-value pairs placed on the CronJob. [2] | `4`; `` | ![Development](https://img.shields.io/badge/-development-blue) | +| `k8s.cronjob.label.` | string | The label key-value pairs placed on the CronJob. [3] | `weekly`; `` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.cronjob.name` | string | The name of the CronJob. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.cronjob.uid` | string | The UID of the CronJob. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.daemonset.name` | string | The name of the DaemonSet. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) | @@ -28,9 +30,9 @@ Kubernetes resource attributes. | `k8s.job.name` | string | The name of the Job. | `opentelemetry` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.job.uid` | string | The UID of the Job. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.namespace.name` | string | The name of the namespace that the pod is running in. | `default` | ![Development](https://img.shields.io/badge/-development-blue) | -| `k8s.namespace.phase` | string | The phase of the K8s namespace. [2] | `active`; `terminating` | ![Development](https://img.shields.io/badge/-development-blue) | -| `k8s.node.annotation.` | string | The annotation key-value pairs placed on the Node. [3] | `k8s.node.annotation.node.alpha.kubernetes.io/ttl=0`; `k8s.node.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) | -| `k8s.node.label.` | string | The label key-value pairs placed on the Node. [4] | `k8s.node.label.kubernetes.io/arch=arm64`; `k8s.node.label.data=` | ![Development](https://img.shields.io/badge/-development-blue) | +| `k8s.namespace.phase` | string | The phase of the K8s namespace. [4] | `active`; `terminating` | ![Development](https://img.shields.io/badge/-development-blue) | +| `k8s.node.annotation.` | string | The annotation key-value pairs placed on the Node. [5] | `k8s.node.annotation.node.alpha.kubernetes.io/ttl=0`; `k8s.node.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) | +| `k8s.node.label.` | string | The label key-value pairs placed on the Node. [6] | `k8s.node.label.kubernetes.io/arch=arm64`; `k8s.node.label.data=` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.node.name` | string | The name of the Node. | `node-1` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.node.uid` | string | The UID of the Node. | `1eb3a0c6-0477-4080-a9cb-0cb7db65c6a2` | ![Development](https://img.shields.io/badge/-development-blue) | | `k8s.pod.annotation.` | string | The annotation key-value pairs placed on the Pod, the `` being the annotation name, the value being the annotation value. | `k8s.pod.annotation.kubernetes.io/enforce-mountable-secrets=true`; `k8s.pod.annotation.mycompany.io/arch=x64`; `k8s.pod.annotation.data=` | ![Development](https://img.shields.io/badge/-development-blue) | @@ -71,12 +73,16 @@ Which states: Therefore, UIDs between clusters should be extremely unlikely to conflict. -**[2] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the +**[2] `k8s.cronjob.annotation`:** The `` being the annotation name, the value being the annotation value, even if the value is empty. + +**[3] `k8s.cronjob.label`:** The `` being the label name, the value being the label value, even if the value is empty. + +**[4] `k8s.namespace.phase`:** This attribute aligns with the `phase` field of the [K8s NamespaceStatus](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#namespacestatus-v1-core) -**[3] `k8s.node.annotation`:** The `` being the annotation name, the value being the annotation value, even if the value is empty. +**[5] `k8s.node.annotation`:** The `` being the annotation name, the value being the annotation value, even if the value is empty. -**[4] `k8s.node.label`:** The `` being the label name, the value being the label value, even if the value is empty. +**[6] `k8s.node.label`:** The `` being the label name, the value being the label value, even if the value is empty. --- diff --git a/docs/resource/k8s.md b/docs/resource/k8s.md index 5dc07b44a..0f38f809f 100644 --- a/docs/resource/k8s.md +++ b/docs/resource/k8s.md @@ -353,6 +353,12 @@ A CronJob creates Jobs on a repeating schedule. |---|---|---|---|---|---| | [`k8s.cronjob.name`](/docs/attributes-registry/k8s.md) | string | The name of the CronJob. | `opentelemetry` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | | [`k8s.cronjob.uid`](/docs/attributes-registry/k8s.md) | string | The UID of the CronJob. | `275ecb36-5aa8-4c2a-9c47-d8bb681b9aff` | `Recommended` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`k8s.cronjob.annotation.`](/docs/attributes-registry/k8s.md) | string | The annotation key-value pairs placed on the CronJob. [1] | `4`; `` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) | +| [`k8s.cronjob.label.`](/docs/attributes-registry/k8s.md) | string | The label key-value pairs placed on the CronJob. [2] | `weekly`; `` | `Opt-In` | ![Development](https://img.shields.io/badge/-development-blue) | + +**[1] `k8s.cronjob.annotation`:** The `` being the annotation name, the value being the annotation value, even if the value is empty. + +**[2] `k8s.cronjob.label`:** The `` being the label name, the value being the label value, even if the value is empty. diff --git a/model/k8s/registry.yaml b/model/k8s/registry.yaml index 0b885d93e..9fb612dad 100644 --- a/model/k8s/registry.yaml +++ b/model/k8s/registry.yaml @@ -229,6 +229,22 @@ groups: brief: > The name of the CronJob. examples: ['opentelemetry'] + - id: k8s.cronjob.label + type: template[string] + stability: development + brief: > + The label key-value pairs placed on the CronJob. + note: | + The `` being the label name, the value being the label value, even if the value is empty. + examples: ['weekly', ''] + - id: k8s.cronjob.annotation + type: template[string] + stability: development + brief: > + The annotation key-value pairs placed on the CronJob. + note: | + The `` being the annotation name, the value being the annotation value, even if the value is empty. + examples: [ '4', '' ] - id: k8s.volume.name type: string stability: development diff --git a/model/k8s/resources.yaml b/model/k8s/resources.yaml index 67bb4a453..3b41ab368 100644 --- a/model/k8s/resources.yaml +++ b/model/k8s/resources.yaml @@ -116,6 +116,10 @@ groups: attributes: - ref: k8s.cronjob.uid - ref: k8s.cronjob.name + - ref: k8s.cronjob.label + requirement_level: opt_in + - ref: k8s.cronjob.annotation + requirement_level: opt_in - id: resource.k8s.replicationcontroller type: resource