|
| 1 | +.. |
| 2 | + SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | + |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + |
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | + |
| 16 | + SPDX-License-Identifier: Apache-2.0 |
| 17 | + |
| 18 | + |
| 19 | +.. _workflow_labels_config: |
| 20 | + |
| 21 | +======================================================= |
| 22 | +Workflow Labels |
| 23 | +======================================================= |
| 24 | + |
| 25 | +Users attach labels to a workflow to record who owns it and what it is for. Label syntax is checked on every submission even when nothing is configured here; a policy adds requirements on top, so you can decide which keys must be present and which values are accepted. |
| 26 | + |
| 27 | +See :ref:`workflow_spec_labels` for how users set labels, and :ref:`workflow_submission` for the CLI flags and list filters. Field definitions are in :ref:`workflow_config`. |
| 28 | + |
| 29 | + |
| 30 | +Why Configure a Policy? |
| 31 | +======================= |
| 32 | + |
| 33 | +✓ **Attribute usage** |
| 34 | + Require a key such as ``team`` or ``cost-center`` so every workflow can be traced back to an owner. |
| 35 | + |
| 36 | +✓ **Keep values consistent** |
| 37 | + An allow-list rejects typos and near-duplicates, which keeps reports and dashboards aligned. |
| 38 | + |
| 39 | +✓ **Roll out gradually** |
| 40 | + Warn before you enforce, so users see what to change while their submissions still succeed. |
| 41 | + |
| 42 | + |
| 43 | +Enforcement Modes |
| 44 | +================= |
| 45 | + |
| 46 | +Each entry in ``policy`` controls one key independently. |
| 47 | + |
| 48 | +.. list-table:: |
| 49 | + :header-rows: 1 |
| 50 | + :widths: 15 85 |
| 51 | + |
| 52 | + * - **Mode** |
| 53 | + - **Behavior when the key is missing, or its value is outside a non-empty allow-list** |
| 54 | + * - ``"off"`` |
| 55 | + - Accepted, with no warning. Same as omitting the key from ``policy``. |
| 56 | + * - ``warn`` |
| 57 | + - Accepted, and the submit response carries a warning. |
| 58 | + * - ``enforce`` |
| 59 | + - Rejected. No workflow row and no stored specification are created. |
| 60 | + |
| 61 | +.. code-block:: yaml |
| 62 | +
|
| 63 | + labels_config: |
| 64 | + policy: |
| 65 | + - key: team |
| 66 | + allow_list: |
| 67 | + - robotics |
| 68 | + - simulation |
| 69 | + enforcement: warn |
| 70 | + - key: cost-center |
| 71 | + allow_list: [] |
| 72 | + enforcement: enforce |
| 73 | +
|
| 74 | +An empty ``allow_list`` accepts any well-formed value, so the key becomes required without constraining what it holds. |
| 75 | + |
| 76 | +.. note:: |
| 77 | + |
| 78 | + Quote ``"off"``. Unquoted YAML ``off`` parses as boolean false. |
| 79 | + |
| 80 | +The same policy applies to new submissions, resubmission by ID, restart, and validation-only requests. Warnings are recomputed from the stored labels and the current policy, so a workflow always shows the warnings its policy would produce today, including after it completes. |
| 81 | + |
| 82 | + |
| 83 | +Rolling Out a Requirement |
| 84 | +========================= |
| 85 | + |
| 86 | +.. grid:: 3 |
| 87 | + :gutter: 2 |
| 88 | + |
| 89 | + .. grid-item-card:: |
| 90 | + :class-header: sd-bg-info sd-text-white |
| 91 | + |
| 92 | + **1. Announce** 📣 |
| 93 | + ^^^ |
| 94 | + |
| 95 | + Add the key with ``enforcement: warn`` |
| 96 | + |
| 97 | + +++ |
| 98 | + |
| 99 | + Submissions succeed; users see what to add |
| 100 | + |
| 101 | + .. grid-item-card:: |
| 102 | + :class-header: sd-bg-warning sd-text-white |
| 103 | + |
| 104 | + **2. Watch** 📊 |
| 105 | + ^^^ |
| 106 | + |
| 107 | + Check the :ref:`validation metrics <workflow_labels_metrics>` |
| 108 | + |
| 109 | + +++ |
| 110 | + |
| 111 | + See who is still missing the key before it starts rejecting |
| 112 | + |
| 113 | + .. grid-item-card:: |
| 114 | + :class-header: sd-bg-success sd-text-white |
| 115 | + |
| 116 | + **3. Enforce** ✅ |
| 117 | + ^^^ |
| 118 | + |
| 119 | + Switch to ``enforcement: enforce`` |
| 120 | + |
| 121 | + +++ |
| 122 | + |
| 123 | + Remaining violations are rejected at submission |
| 124 | + |
| 125 | +Changing a policy leaves existing and in-flight workflows untouched. To roll back, set ``enforcement: warn``; to disable the key entirely, set ``enforcement: "off"`` or remove the entry. In ConfigMap mode, an invalid edit is rejected and the previous valid snapshot stays active. |
| 126 | + |
| 127 | +.. warning:: |
| 128 | + |
| 129 | + Removing a value from an allow-list while the key is in ``enforce`` mode rejects every later submission that uses it, including restarts of workflows that were accepted earlier. Soak the change in ``warn`` first. |
| 130 | + |
| 131 | + |
| 132 | +Prefixing Pod Labels |
| 133 | +==================== |
| 134 | + |
| 135 | +``pod_label_prefix`` is prepended to every workflow label key when labels are stamped onto task pods, and nowhere else: |
| 136 | + |
| 137 | +.. code-block:: yaml |
| 138 | +
|
| 139 | + labels_config: |
| 140 | + pod_label_prefix: example.com/ |
| 141 | + policy: |
| 142 | + - key: team |
| 143 | + enforcement: warn |
| 144 | +
|
| 145 | +A workflow submitted with ``team: robotics`` then carries ``example.com/team=robotics`` on its pods. Everywhere else keeps the bare ``team`` key: the stored specification, the workflow API, list filters, the CLI, and the metric attributes below. Users never type or query the prefix. |
| 146 | + |
| 147 | +The prefix is an opaque string, not an assumed DNS prefix: it is joined to the label key, and the merged key is validated as a Kubernetes label key at submission, in the same check as the policy. An invalid merged key is rejected with an error reporting the original key, the prefix, and the result. |
| 148 | + |
| 149 | +.. tip:: |
| 150 | + |
| 151 | + Set a prefix when task pods share a cluster with unrelated workloads. Pod labels are exported by key name, so a short key such as ``team`` can match an identically named label on another pod. |
| 152 | + |
| 153 | + |
| 154 | +.. _workflow_labels_metrics: |
| 155 | + |
| 156 | +Metrics |
| 157 | +======= |
| 158 | + |
| 159 | +Only configured policy keys become workflow-label dimensions on ``osmo_tasks_count``. Attribute names start with ``workflow_label_``. Letters and numbers are unchanged; ``_``, ``-``, ``.``, and ``/`` are encoded as ``__``, ``_dash_``, ``_dot_``, and ``_slash_`` respectively. For example, ``project`` is exported as ``workflow_label_project``. |
| 160 | + |
| 161 | +.. list-table:: |
| 162 | + :header-rows: 1 |
| 163 | + :widths: 30 70 |
| 164 | + |
| 165 | + * - **Exported value** |
| 166 | + - **When** |
| 167 | + * - The value itself |
| 168 | + - The value is in the configured allow-list. |
| 169 | + * - ``<other>`` |
| 170 | + - The key is present with a value outside that list. An empty allow-list exports every value this way. |
| 171 | + * - ``<missing>`` |
| 172 | + - The key is absent. |
| 173 | + |
| 174 | +This bounds the series count to the allow-list plus two sentinels per key, so keep the policy list small to control cardinality. |
| 175 | + |
| 176 | +Admission also emits ``osmo_label_validation_total{key, outcome}``, where ``outcome`` is ``ok``, ``missing``, ``invalid``, or ``rejected``. The counter covers rejected submissions that never create a workflow row. |
| 177 | + |
| 178 | +.. seealso:: |
| 179 | + |
| 180 | + Exporting a Pod label through ``kube_pod_labels`` is a separate kube-state-metrics allow-list decision; see :ref:`adding_observability`. |
0 commit comments