-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: reference kyverno cli github action (#975)
* 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
1 parent
353c52a
commit de1b770
Showing
4 changed files
with
20 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -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/). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.