Kubernetes
Kubernetes is a container orchestration system that automates software deployment, scaling, and management. The Cortex K8s agent is a lightweight agent that collects information from your cluster (Deployments, StatefulSets, Argo Rollouts, and CronJobs) and surfaces it in your Cortex workspace's catalog, Scorecards, and more.
Integrating Kubernetes with Cortex allows you to:
Discover and import services directly from K8s clusters into Cortex, making it easy to keep the catalog in sync with what's actually running in production
View Kubernetes data on entity pages in Cortex, giving you visibility into your infrastructure and how services are deployed
Create Scorecards to track progress and drive alignment on projects relating to Kubernetes, and to enforce Kubernetes best practices
How to configure Kubernetes with Cortex
Prerequisites
Before getting started:
Reach out to the Cortex customer engineering team for the Helm chart used for deployment and a username and password.
Generate an API key in Cortex.
The API key should have the
User (edit catalog entities)role at a minimum.Note: It is also possible to programmatically create your API key via the Cortex API.
Security considerations
The Cortex k8s agent uses a push model that ensures you do not need to expose your cluster to the public internet.
Additionally, the Helm chart comes with a predefined ClusterRole that provides the correct RBACs:
Permissions:
["get", "watch", "list"]Resources:
["deployments", "services", "pods", "replicationcontrollers", "statefulsets", "rollouts", "cronjobs"]API groups:
["apps", "argoproj.io", "batch"]
Communication out of the cluster to Cortex happens over HTTPS. There is no inbound traffic to the agent.
Install the Cortex k8s agent in your Kubernetes cluster
To connect Cortex to your Kubernetes instance, you’ll need to install the Cortex k8s agent in your Kubernetes cluster. The agent is lightweight and adds negligible impact to your cluster.
Create a Docker image pull secret:
Run the following command, replacing
cortex-keywith the value of your Cortex API key, to create a secret in your cluster:Run the following command to install the Helm chart provided by Cortex:
Connecting Cortex entities to Kubernetes
Discovery
By default, Cortex will use the Cortex tag (e.g. my-entity) as the "best guess" for Kubernetes resource. For example, if your Cortex tag is my-entity, then the corresponding resource in Kubernetes should also be my-entity.
If your Kubernetes resource don’t cleanly match the Cortex tag, you can override this in the Cortex entity descriptor.
Methods for mapping Kubernetes resources
See the table below for the methods of mapping resources to entities:
Services that own their K8s infra
By default, Cortex maps Kubernetes deployments with a cortex.io/tag annotation to Cortex entities with the same tag.
Annotation mapping should be at the default absolute path of .metadata.annotations."cortex.io/tag".
Shared infra or external-managed services
Specify a list of label keys in the Kubernetes integration settings page of your Cortex workspace
Complex or legacy workloads
Add the resource manually to your entity descriptor
See the tabs below to learn how to use each option:
Annotation
You can link your Kubernetes deployment to a Cortex entity by adding an annotation to your k8s deployment 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 use the value of x-cortex-tag in the Cortex entity's cortex.yaml as the value.
For example, if the cortex.yaml file is:
Then the deployment.yaml file should be configured as:
Customize annotation mapping
It is possible to customize annotation mapping in Cortex:
Label-based auto-mapping
You can override Cortex tag discovery and have Cortex discover Kubernetes resources using their metadata labels instead:
Editing the entity descriptor
Cortex accepts several k8s resources, which can be on different clusters or of different types: deployments, ArgoCD rollout, StatefulSet, and CronJob.
All of these resource types have the same field definitions:
identifier
namespace/name as found in Kubernetes
✓
cluster
The name of the cluster, which is set when deploying the agent
Deployments
ArgoCD Rollout
StatefulSet
CronJob
Import entities from Kubernetes
See the Create services documentation for instructions on manually importing entities.
Using the Kubernetes integration
View Kubernetes data on entity pages
Kubernetes deployment data will be available in the Kubernetes block on the entity details pages for entities imported from Kubernetes or linked to a k8s resource.

In the entity's sidebar, click Environments to see Kubernetes deployments, clusters, active replicas, and pending deployments, as well as:
Replicas: Number of available, ready, and desired replicas.
Containers: Resource containers, including requested memory, memory limit, and CPU data. Also includes the full container definition.

Eng Intelligence
Track and analyze your software delivery performance using real-time data from your Kubernetes environments in Eng Intelligence features.
Deployment data from your clusters is surfaced in Metrics Explorer and in dashboards, such as the DORA Dashboard, and can be used to assess key engineering metrics like deployment frequency, change failure rate, and more.
Scorecards and CQL
With the Kubernetes integration, you can create Scorecard rules and write CQL queries based on Kubernetes resources. For an example, see Cortex's prebuilt Kubernetes Deployment Baseline Scorecard template.
See more rule examples in the CQL Explorer in Cortex.
Background sync
The Cortex k8s agent is a cron job that runs every 5 minutes by default.
FAQs and troubleshooting
When I try to import entities, I don't see all the supported workload types (deployments, ArgoCD rollout, StatefulSet, CronJob)
Make sure that the types you expected to see are in the cluster you are attempting to import.
Missing namespaces from Kubernetes discovery
If you're using Cortex's k8s agent to import entities into Cortex but don't see all expected namespaces during the import process, make sure app.namespace is commented out in values.yaml:
If app.namespace is defined the Cortex k8s agent will only be able to discover services from that namespace. This behavior can be confirmed with a backend log similar to:
Once app.namespace is commented out, restart your pods. You will then be able to see all expected namespaces when importing new services.
Helm chart and deprecated Kubernetes Docker registry
If your Cortex agent in Kubernetes clusters is blocked due to deprecation of Docker registry after an upgrade, you can make these direct edits using the same credentials:
Access the image from
ghcr.ioinstead ofdocker.pkg.github.com.Update the registry secret, setting the server to
https://ghcr.io.
If you are unable to make these changes, please reach out to [email protected] and request a new Helm chart with this change already reflected.
Failing ArcoCD rollouts error in the k8s agent
When running the self-hosted Kubernetes agent successfully, users may see failing ArgoCD rollouts errors while not using this tool.
Cortex logs this exception for verbosity - this error is harmless if not using ArgoCD tool.
Can I deploy on prem if I don’t use Kubernetes?
Yes - the Cortex Helm chart deploys two Cortex-specific pods from images for the frontend and backend, as well as a data store. You can use these images to run Docker containers on other platforms, such as ECS.
Still need help?
The following options are available to get assistance from the Cortex Customer Engineering team:
Email: [email protected], or open a support ticket in the in app Resource Center
Slack: Users with a connected Slack channel will have a workflow added to their account. From here, you can either @CortexTechnicalSupport or add a
:ticket:reaction to a question in Slack, and the team will respond directly.
Don’t have a Slack channel? Talk with your Customer Success Manager.
Last updated
Was this helpful?