1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-09 17:37:12 +00:00
kyverno/documentation/testing-policies.md

31 lines
1,015 B
Markdown
Raw Normal View History

2019-05-21 15:50:36 -07:00
<small>*[documentation](/README.md#documentation) / Testing Policies*</small>
2019-05-21 11:06:03 -07:00
# Testing Policies
2020-02-06 00:04:19 -08:00
2020-04-02 22:34:45 -07:00
The resources definitions for testing are located in the [test](/test) directory. Each test contains a pair of files: one is the resource definition, and the second is the Kyverno policy for this definition.
2019-05-21 15:50:36 -07:00
## Test using kubectl
2020-02-06 00:04:19 -08:00
2020-04-02 22:34:45 -07:00
To do this you should [install Kyverno to the cluster](installation.md).
2019-05-22 18:14:10 +03:00
2020-04-02 22:34:45 -07:00
For example, to test the simplest Kyverno policy for `ConfigMap`, create the policy and then the resource itself via `kubectl`:
2019-05-22 20:41:33 -07:00
2019-05-22 18:14:10 +03:00
````bash
cd test
kubectl create -f policy/policy-CM.yaml
kubectl create -f resources/CM.yaml
2019-05-22 18:14:10 +03:00
````
2020-04-02 22:34:45 -07:00
Then compare the original resource definition in `CM.yaml` with the actual one:
2019-05-22 20:41:33 -07:00
2019-05-22 18:14:10 +03:00
````bash
kubectl get -f resources/CM.yaml -o yaml
2019-05-22 18:14:10 +03:00
````
2020-02-07 12:33:57 -08:00
2020-02-19 18:50:03 -08:00
## Test using Kyverno CLI
The Kyverno CLI allows testing policies before they are applied to a cluster. It is documented at [Kyverno CLI](kyverno-cli.md)
2020-02-07 12:33:57 -08:00
<small>*Read Next >> [Policy Violations](/documentation/policy-violations.md)*</small>