---
title: Kubernetes Resource Mapping for Source Code Integration
description: >-
  Learn how to connect Kubernetes cluster resources to the source code that was
  used to deploy them using annotations.
breadcrumbs: >-
  Docs > Source Code Integration > Kubernetes Resource Mapping for Source Code
  Integration
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Kubernetes Resource Mapping for Source Code Integration

Datadog's source code and resource mapping allow you to connect cluster resources to the source code that was used to deploy them, using Kubernetes annotations.

## Configuration{% #configuration %}

`origin.datadoghq.com/location` contains different content depending on how the resources were deployed.

Add the appropriate annotation below under `metadata.annotations`.

{% tab title="Raw Kubernetes YAML" %}
If you deployed resources using `kubectl`, use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
	"repo": {
		"url": "<repo URL>",
		"targetRevision": "<SHA for commit being deployed>",
		"path": "<file path of the resource>"
	}
}'
```

{% /tab %}

{% tab title="Helm chart" %}
If you deployed resources using `helm`, the annotation format you need to use depends on how `helm install` was invoked. These are the possible ways to do it:

{% collapsible-section #chart-reference %}
### Chart reference

Use this option when the chart is stored in the git repo in unpacked form.

Use the installation command `helm install <release> <chart/path>`.

Use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
  "helm": {
    "repoURL": "<repo where the chart and values.yaml files are stored>",
    "targetRevision": "<commit SHA of repoURL>",
    "valuesPath": ["location of values.yaml files relative to <repoURL>"],
    "chartPath": "<chart/path> relative to <repoURL>"
  }
}'
```

{% /collapsible-section %}

{% collapsible-section #path-to-chart %}
### Path to a packaged chart

Use this option when the chart is stored in the git repo in the form of an archive.

Use the installation command `helm install <release> <chart/path/arch-x.y.z.tgz>`.

Use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
  "helm": {
    "repoURL": "<repo where the chart and values.yaml files are stored>",
    "targetRevision": "<commit SHA of repoURL>",
    "valuesPath": ["location of values.yaml files relative to <repoURL>"],
    "chartPath": "<chart/path/arch-x.y.z.tgz relative to repoURL>"
  }
}'
```

{% /collapsible-section %}

{% collapsible-section #path-to-unpacked-chart %}
### Path to an unpacked chart directory

Use this option when the chart is stored somewhere in the current git repo and unpacked during the installation.

Use the installation command `helm install <release> <unpacked/path/dir>`.

Use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
  "helm": {
    "chartURL": "<URL of the chart>",
    "repoURL": "<repo where the values.yaml files are stored>",
    "targetRevision": "<commit SHA of repoURL>",
    "valuesPath": ["location of values.yaml files relative to <repoURL>"],
    "chartPath": "<unpacked/path/dir relative to repoURL>"
  }
}'
```

{% /collapsible-section %}

{% collapsible-section #absolute-url %}
### Absolute URL

Use the installation command `helm install mynginx https://example.com/charts/nginx-1.2.3.tgz`.

Use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
  "helm": {
    "chartURL": "<URL in the format https://example.com/charts/nginx-1.2.3.tgz>",
    "repoURL": "<repo where the values.yaml files are stored>",
    "targetRevision": "<commit SHA of repoURL>",
    "valuesPath": ["location of values.yaml files relative to <repoURL>"]
  }
}'
```

{% /collapsible-section %}

{% collapsible-section #chart-reference-and-repo %}
### Chart reference and repo URL

Use the installation command `helm install --repo https://example.com/charts/ mynginx nginx`.

Use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
  "helm": {
    "chartURL": "<URL in the format https://example.com/charts/nginx>",
    "repoURL": "<repo where the values.yaml files are stored>",
    "targetRevision": "<commit SHA of repoURL>",
    "valuesPath": ["location of values.yaml files relative to <repoURL>"]
  }
}'
```

{% /collapsible-section %}

{% collapsible-section #oci-registries %}
### OCI registries

Use the installation command `helm install mynginx --version 1.2.3 oci://example.com/charts/nginx`.

Use the following annotation format:

```yaml
origin.datadoghq.com/location: '{
  "helm": {
    "chartURL": "<URL in the format oci://example.com/charts/nginx>",
    "repoURL": "<repo where the values.yaml files are stored>",
    "targetRevision": "<commit SHA of repoURL>",
    "valuesPath": ["location of `values.yaml` files relative to <repoURL>"]
  }
}'
```

{% /collapsible-section %}

For the Helm use case, Datadog provides an open-source Helm plugin that you can install and use to add annotations automatically. Check the plugin repo on [GitHub](https://github.com/DataDog/helm-plugin).
{% /tab %}
