

billing-info. Developers sometimes forget to add the label or paste outdated values, producing inaccurate billing and forcing Alex to manually correct Deployments after creation.

billing-info ConfigMap and applies it to new Deployments automatically.

- Use ConfigMaps and Secrets via the
contextblock to access centrally managed configuration values. - Query the Kubernetes API (the API data source) to fetch other cluster resources when needed.
- Leverage the global context to cache external data for better performance and lower API load.
- Use image registry variables to fetch image metadata and make image-aware policy decisions.
Note: ConfigMap keys are case-sensitive; when referencing a key from
billing-info, ensure you use the exact key name. Also ensure the ConfigMap name matches exactly (Kubernetes resource names are typically lowercase and must follow DNS label rules).- Use a
contextentry that points to the ConfigMap. - Reference the loaded data inside
mutateusing the context variable.
cost-center from the billing-info ConfigMap in the finance namespace and apply it to matched Deployments.
Further resources and references
- Kyverno documentation: https://kyverno.io/docs/
- Kubernetes ConfigMap docs: https://kubernetes.io/docs/concepts/configuration/configmap/
- Kyverno tutorial on external data sources: https://kyverno.io/docs/writing-policies/external-data/