Skip to content

Commit

Permalink
enhancement: reference kyverno cli github action (#975)
Browse files Browse the repository at this point in the history
* enhancement: reference kyverno cli github action

Signed-off-by: Chandan-DK <[email protected]>

* edit workflow yaml

Signed-off-by: Chandan-DK <[email protected]>

* modify

Signed-off-by: Chandan-DK <[email protected]>

* add images

Signed-off-by: Chandan-DK <[email protected]>

* edit yaml

Signed-off-by: Chandan-DK <[email protected]>

* edit text

Signed-off-by: Chandan-DK <[email protected]>

* use folder path for images instead of image URLs

Signed-off-by: Chandan-DK <[email protected]>

* update release version

Signed-off-by: Chandan-DK <[email protected]>

---------

Signed-off-by: Chandan-DK <[email protected]>
Co-authored-by: Chip Zoller <[email protected]>
  • Loading branch information
Chandan-DK and chipzoller authored Nov 18, 2023
1 parent 353c52a commit de1b770
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions content/en/docs/Kyverno CLI/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ The Kyverno CLI can also be installed with [Homebrew](https://brew.sh/) as a [fo
brew install kyverno
```

### Install in GitHub Actions

The Kyverno CLI can be installed in GitHub Actions using [kyverno-cli-installer](https://github.com/marketplace/actions/kyverno-cli-installer) from the GitHub Marketplace. Please refer to [kyverno-cli-installer](https://github.com/marketplace/actions/kyverno-cli-installer) for more information.

### Manual Binary Installation

The Kyverno CLI may also be installed by manually downloading the compiled binary available on the [releases page](https://github.com/kyverno/kyverno/releases). An example of installing the Kyverno CLI v1.10.0 on a Linux x86_64 system is shown below.
Expand Down
30 changes: 16 additions & 14 deletions content/en/docs/Testing Policies/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,34 @@ The following is an example of a simple GitHub Actions workflow which may be use
The repository contains Kyverno policies stored in `policies/`, Kubernetes resource manifests stored in `resources/` and complete Kyverno test cases stored in `tests/`. A sample workflow may be added at the path `.github/workflows/kyverno.yaml` with the below contents which performs the following for both opened pull requests and manually if triggered on the repository.

1. The repository is checked out.
2. The Kyverno CLI is downloaded by naming a specific version. This can be changed to simulate the effect a Kyverno upgrade may have in a cluster.
3. Tests the unknown manifests in `resources/` against the known policies stored in `policies/`.
4. Tests the pre-defined test cases stored in `tests/` which contain Kyverno test manifests, policies, and resources separated by folder.
2. The GitHub action for Kyverno CLI is downloaded by naming a specific version. This can be changed to simulate the effect a Kyverno upgrade may have in a cluster. Please refer to [kyverno-cli-installer](https://github.com/marketplace/actions/kyverno-cli-installer) for more information on the GitHub action for Kyverno CLI.
3. Check the Kyverno CLI version
4. Tests the unknown manifests in `resources/` against the known policies stored in `policies/`.
5. Tests the pre-defined test cases stored in `tests/` which contain Kyverno test manifests, policies, and resources separated by folder.

```yaml
name: kyverno-policy-test
on:
- pull_request
- workflow_dispatch
env:
VERSION: v1.7.2
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Kyverno CLI
run: |
curl -sLO https://github.com/kyverno/kyverno/releases/download/${{ env.VERSION }}/kyverno-cli_${{ env.VERSION }}_linux_x86_64.tar.gz
tar -xf kyverno-cli_${{ env.VERSION }}_linux_x86_64.tar.gz
./kyverno version
uses: actions/checkout@v4
- name: Install Kyverno CLI
uses: kyverno/[email protected]
with:
release: 'v1.11.0'
- name: Check install
run: kyverno version
- name: Test new resources against existing policies
run: ./kyverno apply policies/ -r resources/
run: kyverno apply policies/ -r resources/
- name: Test pre-defined cases
run: ./kyverno test tests/
run: kyverno test tests/
```
Upon pull request to the repository containing this file, the GitHub Actions workflow will be triggered. If all tests succeed, the output will show a success for all steps.
Expand All @@ -90,4 +92,4 @@ If a pull request fails in any of the steps in the job, for example if a new man

Again, each step may be inspected for output. In the above screenshot, a Deployment manifest did not pass a validate policy and therefore caused the overall failure.

For full usage details of the Kyverno CLI, refer to the [documentation](/docs/kyverno-cli/).
For full usage details of the Kyverno CLI, refer to the [documentation](/docs/kyverno-cli/).
Binary file modified static/images/ci-fail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/ci-pass.png
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 de1b770

Please sign in to comment.