Skip to content

Commit

Permalink
Merge pull request #106 from nirmata/chainsaw-test
Browse files Browse the repository at this point in the history
Added the chainsaw tests for pod security and rbac policies
  • Loading branch information
anusha94 authored Feb 21, 2024
2 parents 9874511 + 90755a7 commit 106d05d
Show file tree
Hide file tree
Showing 248 changed files with 19,039 additions and 2,519 deletions.
17 changes: 17 additions & 0 deletions .chainsaw-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
creationTimestamp: null
name: configuration
spec:
parallel: 1
timeouts:
apply: 1m30s
assert: 1m30s
cleanup: 2m30s
delete: 1m30s
error: 1m30s
exec: 1m30s
fullName: true
forceTerminationGracePeriod: 5s
delayBeforeCleanup: 3s
46 changes: 46 additions & 0 deletions .github/workflows/chainsaw-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: ChainSaw Test
on:
push:
branches:
- 'main'

pull_request:
branches:
- 'main'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
run-e2etest:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
k8s-version: [v1.29.2, v1.28.7, v1.27.11, v1.26.14, v1.25.16, v1.24.12, v1.23.17]
# For n4k-versions 1.9
n4k-chart-version: [1.6.11]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Prepare environment
run: K8S_VERSION=${{ matrix.k8s-version }} make kind-create-cluster

- name: Install kyverno
run: N4K_VERSION=${{ matrix.n4k-chart-version }} make kind-deploy-kyverno

- name: Check Kyverno status
run: make wait-for-kyverno

- name: Install Chainsaw
uses: kyverno/[email protected]

- name: Verify Chainsaw Installation
run: chainsaw version

- name: Test with Chainsaw
run: make test-chainsaw
32 changes: 0 additions & 32 deletions .github/workflows/e2e.yaml

This file was deleted.

33 changes: 14 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
.DEFAULT_GOAL: build-all

K8S_VERSION ?= $(shell kubectl version --short | grep -i server | cut -d" " -f3 | cut -c2-)
KIND_IMAGE ?= kindest/node:v1.25.2
KIND_IMAGE ?= kindest/node:$(K8S_VERSION)
KIND_NAME ?= kind
USE_CONFIG ?= standard

TOOLS_DIR := $(PWD)/.tools
KIND := $(TOOLS_DIR)/kind
KIND_VERSION := v0.17.0
KIND_VERSION := v0.22.0
HELM := $(TOOLS_DIR)/helm
HELM_VERSION := v3.10.1
KUTTL := $(TOOLS_DIR)/kubectl-kuttl
KUTTL_VERSION := v0.0.0-20230108220859-ef8d83c89156
TOOLS := $(KIND) $(HELM) $(KUTTL)
TOOLS := $(KIND) $(HELM)

$(KIND):
@echo Install kind... >&2
Expand All @@ -22,10 +20,6 @@ $(HELM):
@echo Install helm... >&2
@GOBIN=$(TOOLS_DIR) go install helm.sh/helm/v3/cmd/helm@$(HELM_VERSION)

$(KUTTL):
@echo Install kuttl... >&2
@GOBIN=$(TOOLS_DIR) go install github.com/kyverno/kuttl/cmd/kubectl-kuttl@$(KUTTL_VERSION)

.PHONY: install-tools
install-tools: $(TOOLS)

Expand All @@ -34,20 +28,20 @@ clean-tools:
@echo Clean tools... >&2
@rm -rf $(TOOLS_DIR)

###############
# KUTTL TESTS #
###############
##################
# CHAINSAW TESTS #
##################

.PHONY: test-kuttl
test-kuttl: $(KUTTL) ## Run kuttl tests
@echo Running kuttl tests... >&2
@$(KUTTL) test --config kuttl-test.yaml
.PHONY: test-chainsaw
test-chainsaw:
@echo Running chainsaw tests... >&2
@chainsaw test --config .chainsaw-config.yaml

## Create kind cluster
.PHONY: kind-create-cluster
kind-create-cluster: $(KIND)
@echo Create kind cluster... >&2
@$(KIND) create cluster --name $(KIND_NAME)
@$(KIND) create cluster --name $(KIND_NAME) --image $(KIND_IMAGE)

## Delete kind cluster
.PHONY: kind-delete-cluster
Expand All @@ -60,13 +54,14 @@ kind-delete-cluster: $(KIND)
kind-deploy-kyverno: $(HELM)
@echo Install kyverno chart... >&2
@$(HELM) repo add nirmata https://nirmata.github.io/kyverno-charts
@$(HELM) install kyverno --namespace kyverno --create-namespace nirmata/kyverno
@$(HELM) repo update
@$(HELM) install kyverno nirmata/kyverno -n kyverno --create-namespace --version=$(N4K_VERSION)

## Check Kyverno status
.PHONY: wait-for-kyverno
wait-for-kyverno:
@echo Check kyverno status to be ready... >&2
@kubectl wait --namespace kyverno --for=condition=ready pod --all --timeout=120s
@kubectl wait --namespace kyverno --for=condition=ready pod --all --timeout=180s

#####################
# Kyverno CLI TESTS #
Expand Down
6 changes: 0 additions & 6 deletions best-practices/disallow-empty-ingress-host/e2e/01-policy.yaml

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions best-practices/disallow-empty-ingress-host/e2e/04-manifests.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions best-practices/disallow-empty-ingress-host/e2e/99-delete.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions best-practices/disallow-empty-ingress-host/e2e/good-ingress.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions best-practices/disallow_cri_sock_mount/e2e/01-policy.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions best-practices/disallow_cri_sock_mount/e2e/02-enforce.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions best-practices/disallow_cri_sock_mount/e2e/04-manifests.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions best-practices/disallow_cri_sock_mount/e2e/99-delete.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions best-practices/disallow_cri_sock_mount/e2e/good-pod.yaml

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions best-practices/disallow_cri_sock_mount/e2e/pod-crio-sock.yaml

This file was deleted.

Loading

0 comments on commit 106d05d

Please sign in to comment.