Discovery
By default, Cortex uses the Cortex tag as a best guess for the Kubernetes resource. For example, if your Cortex tag ismy-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 acortex.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:
deployment.yaml file should be configured as:
metadata.annotations), not the pod template annotations (spec.template.metadata.annotations).
Customizing annotation mapping
You can customize annotation mapping in Cortex:
- From the main sidebar, select Integrations.
- Locate Kubernetes, then click Settings.
- From the Integration settings tab, locate the K8s annotation mapping customization section.
- Enter a
jqmapping in the annotation mapping field. - Click Save mapping.
.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:
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:- From the main sidebar, select Integrations.
- Locate Kubernetes, then click Settings.
- From the Integration settings tab, locate the K8s auto-mapping customization section.
- Enter a list of metadata label keys.
- Click Save.
- The resource’s spec metadata key contains any of the specified labels.
- The key values match a Cortex entity tag.
example and entity, and the following Kubernetes JSON blob:
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