Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions docs/operate/explanations/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ A label might describe ownership, a project, an environment grouping, or anythin

## How labels work on Nais

Labels on Nais are regular [Kubernetes labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) with one requirement: the key must use the `labels.nais.io/` prefix.
Labels on Nais are regular [Kubernetes labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). You can use any key and value that follows the standard Kubernetes label syntax.

```text
labels.nais.io/<key>: <value>
<key>: <value>
```

This prefix keeps your own labels clearly separated from the labels that Nais manage internally, so the two never collide.

When you set a label on a resource, Nais keeps it verbatim and propagates it to the underlying Kubernetes resources that the resource owns. For a [workload](../../workloads/README.md), this means the label is also applied to the resources Nais generates on your behalf.

## Hidden labels

Nais surfaces all labels on your resources, except for a few that Nais and Kubernetes manage internally. The following labels are hidden in [Nais Console](../console/README.md) and the [Nais API](../console/api.md):

- the `app` label
- the `team` label
- any label whose key contains the substring `nais.io/`

These labels are still present on the underlying Kubernetes resources — they are only hidden from the Nais-managed views.

## Where you can use labels

You can define labels on any of the Kubernetes resources that Nais supports, under `metadata.labels`.
Expand Down
8 changes: 4 additions & 4 deletions docs/operate/how-to/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This guide shows you how to add [labels](../explanations/labels.md) to your reso

## Add labels in your manifest

Add your labels under `metadata.labels`, using the `labels.nais.io/` prefix:
Add your labels under `metadata.labels`:

=== "app.yaml"

Expand All @@ -19,8 +19,8 @@ Add your labels under `metadata.labels`, using the `labels.nais.io/` prefix:
name: <MY-APP>
namespace: <MY-TEAM>
labels:
labels.nais.io/team-area: payments
labels.nais.io/sensitive: "true"
team-area: payments
sensitive: "true"
spec:
...
```
Expand All @@ -33,7 +33,7 @@ You can add and edit labels from Console for [Valkey](../../persistence/valkey/R

1. Open [Nais Console](<<tenant_url("console")>>) and navigate to the resource you want to label.
2. Find the **Labels** section in the sidebar and click the edit icon.
3. Enter a key and a value. The `labels.nais.io/` prefix is added automatically.
3. Enter a key and a value.
4. Click **Add label** to add more labels.
5. Click **Save**.

Expand Down
21 changes: 16 additions & 5 deletions docs/operate/reference/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ Labels are user-defined key-value pairs used to organize and categorize your res
A label consists of a key and a value:

```text
labels.nais.io/<key>: <value>
<key>: <value>
```

| Part | Description |
|:-----|:------------|
| `labels.nais.io/` | Required prefix. It is the only constraint Nais adds on top of the standard Kubernetes label rules. |
| `<key>` | Your label name. Must follow the [Kubernetes label syntax](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set). |
| `<value>` | Your label value. Must follow the [Kubernetes label syntax](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set). |

Expand All @@ -26,6 +25,18 @@ labels.nais.io/<key>: <value>
- Labels are **propagated** to the underlying Kubernetes resources that the resource owns.
- Labels carry **no special meaning** to Nais. They are only used for your own organization.

## Hidden labels

[Nais Console](../console/README.md) and the [Nais API](../console/api.md) surface all labels on a resource, except for the following internal labels, which are hidden:

| Label key | Match |
|:----------|:------|
| `app` | Exact match |
| `team` | Exact match |
| `*nais.io/*` | Any key containing the substring `nais.io/` |

Hidden labels remain present on the underlying Kubernetes resources.

## Setting labels

Labels are defined under `metadata.labels` for any Kubernetes resource that Nais supports:
Expand All @@ -37,13 +48,13 @@ metadata:
name: myapplication
namespace: myteam
labels:
labels.nais.io/team-area: payments
labels.nais.io/sensitive: "true"
team-area: payments
sensitive: "true"
spec:
...
```

Labels can also be added and edited from [Nais Console](../console/README.md) for [Valkey](../../persistence/valkey/README.md), [OpenSearch](../../persistence/opensearch/README.md), [Config](../../services/config/README.md), and [Secret](../../services/secrets/README.md).
Labels can also be added and edited from [Nais Console](../console/README.md) for [Valkey](../../persistence/valkey/README.md), [OpenSearch](../../persistence/opensearch/README.md), [Config](../../services/config/README.md), and [Secret](../../services/secrets/README.md).

## Related pages

Expand Down