Skip to content

Commit

Permalink
add usage
Browse files Browse the repository at this point in the history
Signed-off-by: Chip Zoller <[email protected]>
  • Loading branch information
chipzoller committed Jul 17, 2023
1 parent 12a1065 commit 9873ffd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,33 @@ This repo is for an **experimental only** demo application which shows how Kyver
## Installation

See installation instructions in the Helm chart's README [here](/charts/kyverno-json-validator/README.md#installing-the-chart).

## Usage

The chart will install the CRD which maps onto a generic JSON payload with pseudo-Kubernetes Custom Resource called `MyJson`. Install a matching Kyverno policy which contains the validation you wish to make.

```yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: json-test
spec:
background: false
validationFailureAction: Enforce
rules:
- name: test
match:
any:
- resources:
kinds:
- MyJson
validate:
message: The value of `foo` must be set to `bar`.
pattern:
spec:
foo: bar
```
Navigate to the UI using the link provided after the chart was installed (which varies depending on whether you used the default of ClusterIP or LoadBalancer) and validate the JSON payload you wish. Validation failures return the message from Kyverno defined in the `message` field of the matching policy.

![gif](static/gif.gif)
Binary file added static/gif.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9873ffd

Please sign in to comment.