Kubernetes Resource Mapping for Source Code Integration

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Overview

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

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

If you deployed resources using kubectl, use the following annotation format:

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

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:

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:

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>"
  }
}

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:

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>"
  }
}

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:

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>"
  }
}

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

Use the following annotation format:

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>"]
  }
}

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

Use the following annotation format:

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>"]
  }
}

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

Use the following annotation format:

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>"]
  }
}