Skip to main content
This article explains how entities in Cortex get associated with Kubernetes resources. For configuration instructions, see Configuring the integration for Kubernetes. For instructions on using the integration, see Using the integration for Kubernetes.

Discovery

By default, Cortex uses the Cortex tag as a best guess for the Kubernetes resource. For example, if your Cortex tag is my-entity, the corresponding resource in Kubernetes should also be my-entity. If your Kubernetes resources don’t cleanly match the Cortex tag, you can override this behavior.

Methods for mapping Kubernetes resources

There are three ways to map Kubernetes resources to Cortex entities:

Annotation-based mapping

You can link a Kubernetes deployment to a Cortex entity by adding an annotation to the deployment’s metadata. By default, Cortex maps Kubernetes deployments with a cortex.io/tag annotation to Cortex entities with the same tag. Use cortex.io/tag as the key, and the value of x-cortex-tag in the entity’s cortex.yaml as the value. For example, if the cortex.yaml file is:
Then the deployment.yaml file should be configured as:
Cortex reads the top-level metadata annotations on the Deployment object itself (metadata.annotations), not the pod template annotations (spec.template.metadata.annotations). Customizing annotation mapping You can customize annotation mapping in Cortex:
  1. From the main sidebar, select Integrations.
  2. Locate Kubernetes, then click Settings.
  3. From the Integration settings tab, locate the K8s annotation mapping customization section.
  4. Enter a jq mapping in the annotation mapping field.
  5. Click Save mapping.
If auto-mapping isn’t working as expected, confirm that the annotation mapping is at the default absolute path of .metadata.annotations."cortex.io/tag". If it isn’t, update the annotation mapping on the Kubernetes settings page to match the exact absolute path of the Cortex tag. Example Say your deployment.yaml includes my.service as the cortex.io/tag:
If this deployment should map to a Cortex entity with the tag my-entity, enter the following jq expression to convert all periods in the deployment annotation tag to dashes:

Label-based auto-mapping

You can override Cortex tag discovery and have Cortex discover Kubernetes resources by their metadata labels instead:
  1. From the main sidebar, select Integrations.
  2. Locate Kubernetes, then click Settings.
  3. From the Integration settings tab, locate the K8s auto-mapping customization section.
  4. Enter a list of metadata label keys.
  5. Click Save.
Once the list is saved, Cortex discovers all Kubernetes resources that meet both of the following criteria:
  • The resource’s spec metadata key contains any of the specified labels.
  • The key values match a Cortex entity tag.
Example Say you have two Cortex entities, example and entity, and the following Kubernetes JSON blob:
By default, example and entity have no Kubernetes resource mappings. If the list of metadata labels is set to ["app"], then the entity example is associated with “Sample Kubernetes resource.” If the list is set to ["app", "another"], then both example and entity are associated with the resource.

Mapping resources in the YAML

Cortex accepts several Kubernetes resource types, which can be on different clusters: Deployments, Argo Rollouts, StatefulSets, and CronJobs. All of these resource types share the same field definitions: Argo Rollouts
StatefulSets
CronJobs

Importing entities from Kubernetes

For instructions on manually importing entities, see Adding services.
Last modified on September 9, 2026