Kubernetes Namespace Labels and Annotations
Every Environment is a Kubernetes namespace on its Cluster. You can set the labels and annotations of that namespace from CodeNOW — for example to let policy engines, cost reporting or monitoring tools select your environment's namespace.
These are Kubernetes metadata written onto the namespace itself. They are separate from the Labels shown in the header of the Environment Detail, which are CodeNOW labels used to organize and filter environments (for example in Service Availability) and never reach the cluster.
Where to Find Them
The Kubernetes namespace card is the first card below the header of the
Environment Detail. It lists the environment's
Namespace labels and Namespace annotations side by side, one entry per line as key: value — the way kubectl
shows namespace metadata; an empty value appears as key: "" (No labels. / No annotations. when there are none).
Entries reserved by the platform are marked with a lock — see Reserved Keys.
1 — Edit — opens the editor; see Edit Labels and Annotations
2 — Copy cluster defaults into editor — shown only when there are differences from the cluster defaults; opens the editor with the cluster's values added; your own keys stay
3 — Reserved entry — marked with a lock, always taken from the cluster defaults
4 — Different from the cluster default — the entry's value differs from the cluster's; the chip shows the cluster value
5 — Missing from the environment — a key the cluster defaults have but the namespace doesn't, shown dimmed
Points 2, 4 and 5 appear only when the environment differs from the cluster defaults; see Differences from the Cluster Defaults.
Defaults When Creating an Environment
In the create form, once you choose a cluster, the Kubernetes namespace section below Allow deployment from pipelines is prefilled with that cluster's default labels and annotations. You can change or remove these entries and add your own before confirming; reserved entries are shown read-only. After you edit the section, Reset to cluster defaults brings back the cluster's values.
If you choose a different cluster after editing the section, the section is prefilled with the new cluster's defaults and your edits are kept on top of them; entries with keys that the new cluster reserves are dropped.
Defaults are set per cluster, so the prefilled values may differ between clusters. If the defaults cannot be loaded, the section says so: leave it empty to create the namespace with the cluster defaults, or add entries to use them instead.
What you confirm is saved as the environment's own set of labels and annotations. Later changes to the cluster defaults do not change existing environments automatically — see Differences from the Cluster Defaults.
Edit Labels and Annotations
- On the Kubernetes namespace card, click Edit. The Kubernetes namespace drawer opens.
- Under Namespace labels and Namespace annotations, change keys and values, remove a row with its remove icon, or add one with + Add label / + Add annotation. Reserved rows are greyed out and cannot be changed. Differences from the cluster defaults are marked in the editor too — see Differences from the Cluster Defaults.
- Click Confirm. CodeNOW shows Namespace labels and annotations saved.
The change is applied to the namespace right away. The environment stays in its current state and is not re-created.
- A key you remove in CodeNOW is removed from the namespace.
- Keys that were added to the namespace outside of CodeNOW (for example with
kubectl) stay.
Editing requires the permission to update the environment; without it, the Edit button is disabled.
If the change cannot be applied, the drawer tells you why and nothing is changed:
| Message | What to do |
|---|---|
| The environment is being created or deleted. Try again once it is ready. | Wait until the environment is ready and confirm again |
| The namespace could not be updated in the GitOps repository. Nothing was changed — you can try again. | Confirm again; nothing was applied |
Reserved Keys
Some keys are used by CodeNOW, Kubernetes, Istio and Argo CD to manage the namespace and the traffic in it, so the platform keeps them in line with the cluster. They always take the value from the current cluster defaults, are shown with a lock, and cannot be added, changed or removed in CodeNOW:
- keys with the prefixes
codenow.com/,istio.io/,argocd.argoproj.io/,kubernetes.io/,k8s.io/and their subdomains, e.g.node.kubernetes.io/orsidecar.istio.io/ - the key
istio-injection
Entering a reserved key shows This key is reserved by the platform.
Rules for Keys and Values
Keys and values follow the Kubernetes rules. The editor checks them as you type and shows the problem at the field:
| Rule | Message |
|---|---|
| A key is required and must be unique | Key is required. · Duplicate key. |
The optional prefix before / is a lowercase DNS subdomain of at most 253 characters | The prefix before '/' must be a lowercase DNS subdomain (max 253 characters). |
The name after / is required, at most 63 characters, starts and ends with a letter or digit and contains only letters, digits, -, _ and . | The name after '/' is required. · The name must be 63 characters or less. · The name must start and end with a letter or digit and contain only letters, digits, '-', '_' and '.'. |
A label value is empty or at most 63 characters, starting and ending with a letter or digit and containing only letters, digits, -, _ and . | The value must be 63 characters or less. · The value must be empty, or start and end with a letter or digit and contain only letters, digits, '-', '_' and '.'. |
| An annotation value can be any text; all annotations together must stay within 256 KiB | Annotations together exceed the Kubernetes limit of 256 KiB. |
Differences from the Cluster Defaults
When the environment's labels or annotations differ from the current defaults of its cluster, the Kubernetes namespace card marks each difference at its entry, and the section heading counts them, for example Namespace labels · 1 difference:
- Different value — the entry is shown with its own value and a chip cluster default: <value> (This value differs from the cluster default.).
- Missing key — a key the cluster defaults have but the environment doesn't is shown as a dimmed
key: valueline with the cluster's value and the chip missing — from cluster defaults.
Reserved keys are never marked; they always follow the cluster. Keys of your own that the cluster defaults don't have are not differences.
You can resolve the differences in the editor (with the permission to update the environment):
- Copy cluster defaults into editor — in the card header next to Edit, and at the top of the editor while differences remain. It adds the cluster's values to the editor: missing keys are added and different values are replaced; your own keys stay as they are.
- One by one in the editor: a differing value has a warning icon and the helper cluster default: <value> · Use cluster value; a missing key is listed as a dimmed suggestion row with the same chip and Add, which adds it with the cluster's value.
Nothing is saved until you click Confirm.
1 — Copy cluster defaults into editor — adds all cluster values at once; shown while differences remain
2 — Use cluster value — replaces this entry's value with the cluster's
3 — Add — adds the missing key with the cluster's value
The differences can only be determined while the cluster is reachable. When it isn't, the card marks no entries and says The cluster defaults could not be read, so differences from them are not shown.
API
Namespace labels and annotations can also be managed through the CodeNOW API:
- Create an environment and update an environment accept them;
- Get an environment returns them, marks the reserved entries and reports the differences from the cluster defaults;
- Get the namespace defaults of a cluster returns the values the create form is prefilled with.