This YAML balances enforcement and adoption: it enforces a minimal set of required tags while accepting common alternative label keys so teams aren’t forced into disruptive relabel operations. Use this as a governance contract for cost allocation, ownership routing, and automated audits.
-
required_tags
Canonical labels that must exist on every business workload to enable accurate ownership, routing, and cost allocation:owner,environment,cost-center,application, andtier. -
label_mappings
Maps canonical tag names to the alternate Kubernetes label keys teams may already be using (for example,envvsapp.kubernetes.io/env). The validator should treat any mapped key as equivalent to the canonical one so you can govern heterogeneous clusters without forcing immediate relabeling. -
cost_centers
A controlled vocabulary of business units that FinOps and billing systems use to attribute spend. Examples here:booking-engine,payment,inventory,customer-service,analytics,platform. -
environments, tiers, and compliance_levels
Lists of allowed values for environment, workload tier, and compliance. These are used for validation and audits to ensure labels conform to organizational policy. -
resource_types
Which Kubernetes object kinds the scanner should examine for labels. Typical choices includeDeployment,Service,ConfigMap,PersistentVolumeClaim,Ingress, andPod. -
excluded_namespaces
Namespaces skipped by the scanner (usually platform or system namespaces such askube-systemand provisioner namespaces). This reduces noise and false positives during audits.
Detailed guidance and considerations
- Enforcing
required_tags
- Purpose: Guarantees every tracked resource includes the minimal metadata needed for ownership, incident routing, and cost attribution.
- Implementation note: Validators should check both the canonical key (e.g.,
environment) and any mapped alternatives defined inlabel_mappings.
- Using
label_mappingsto avoid disruption
- Benefit: Allows gradual convergence to canonical keys. Treat mapped keys as equivalent during scans and reports.
- Example behavior: If a Deployment has
env: prodbut notenvironment: prod, the validator should accept it onceenvis listed underlabel_mappings.environment.
- Controlled vocabularies (
cost_centers,environments,tiers,compliance_levels)
- Purpose: Reduces ambiguity during audits and makes automated policies (e.g., cost reports, compliance checks) reliable.
- Enforcement tip: Use these lists as a whitelist—flag values not present for review rather than auto-failing immediately to allow remediation windows.
resource_types— what to scan
- Pick kinds that matter to your cost and security posture. Commonly scanned kinds are
Deployment,Service,Pod, etc. - Avoid scanning every possible kind by default; scanning fewer, high-value kinds reduces noise and speeds validation.
Excluding namespaces reduces noise, but be careful: excluding a namespace that contains business workloads will hide noncompliant resources from the auditor. Regularly review
excluded_namespaces and document the rationale for each excluded entry.- Minimal (non-negotiable) tags deliver immediate value for cost allocation and routing.
label_mappingssupports incremental adoption by accepting common, pre-existing label keys.- Controlled value lists (cost centers, environments, tiers, compliance) enable reliable automation, audits, and FinOps reporting.
- Start in audit-only mode: run the scanner to produce a report of missing/invalid labels across
resource_types. - Share findings with teams and allow an agreed remediation period.
- Move to enforcement mode (fail CI/policy checks) after remediation windows expire.
- Periodically review and update
label_mappingsto capture new common label patterns.
- Deploy a scanner/validator that reads this YAML and:
- Resolves canonical tags using
label_mappings. - Validates values against
cost_centers,environments,tiers, andcompliance_levels. - Scans only the
resource_typesand ignoresexcluded_namespaces.
- Resolves canonical tags using
- Run in audit mode first, then move to gating policy enforcement (e.g., admission controller, CI checks).
- Kubernetes Concepts — Labels and Selectors
- Kubernetes API Resource Kinds
- FinOps Foundation — best practices for cloud cost management