tagging-rules.yaml. Below I’ll walk through the file structure, why each section matters for Kubernetes tagging and governance, and how to keep the configuration maintainable and agent-friendly.
Open config/tagging-rules.yaml and you’ll see several logical sections: required tags, label mappings, allowed values (cost centers, environments, tiers, compliance levels), resource types, and excluded namespaces. Here is a consolidated, production-ready example of the YAML configuration used in an airline booking context:
Required tags
- The
required_tagslist defines canonical metadata every application resource should include. Your agent/tooling should validate these and flag or remediate resources missing any required tag. This drives consistent ownership, cost allocation, and environment separation across clusters.
label_mappingslets multiple teams keep their existing labels while your agent normalizes them to canonical tags. This reduces churn and redeploy work by interpretingapp.kubernetes.io/name,app, andapplicationas the same canonicalapplicationtag.
Label mappings reduce operational friction: allow teams to use commonly adopted label keys while your tooling maps them to a single canonical tag for policy checks, billing, and search.
- We added
slack-channelas a required tag. Many teams use eitherslack-channelorslack_channel; the difference between a dash (-) and an underscore (_) matters in Kubernetes label keys. Include both variants inlabel_mappingsto avoid forcing label changes across existing resources.
Kubernetes label keys are exact strings. If you expect multiple naming conventions (dash vs underscore), explicitly map each variant in
label_mappings to prevent false negatives during validation.- Use lists such as
cost_centers,environments,tiers, andcompliance_levelsto constrain allowed values. This makes automated checks and reporting deterministic (e.g., cost allocation bycost-centeror environment-based promotion pipelines). resource_typesdefines which Kubernetes kinds the agent should inspect or enforce tags for. Narrow this list to reduce noise and resource usage.excluded_namespacesprevents the agent from touching system or irrelevant namespaces (for example,kube-system), improving performance and avoiding unintended modifications.
- YAML is more human-friendly for configuration: it handles comments, is easier to read, and is forgiving for adding/removing lists—helpful for operational configs like tagging rules.
- JSON is stricter and can be used where required, but for day-to-day governance config files, YAML improves maintainability and reduces accidental schema breakage.
- Kubernetes labels & annotations: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
- YAML specification and best practices: https://yaml.org/
- Kubernetes documentation: https://kubernetes.io/docs/
tagging-rules.yaml should contain and why. Next, we’ll go into the prompting section.