Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate load tests via GH actions #10

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8a5d138
add thresholds
realshuting Oct 12, 2023
7fdda23
add GH actions
realshuting Oct 17, 2023
729dff2
Merge pull request #4 from realshuting/add_threshold
realshuting Oct 17, 2023
801a1ec
add KIND config files
realshuting Oct 17, 2023
edb98bb
Merge pull request #6 from realshuting/add_threshold
realshuting Oct 17, 2023
c267037
fix path
realshuting Oct 17, 2023
281017d
add kyverno chart
realshuting Oct 17, 2023
09072fa
add helm repo
realshuting Oct 24, 2023
83c3efd
refactor
realshuting Oct 24, 2023
75f2518
update cmd
realshuting Oct 24, 2023
1260c6f
add values.yaml
realshuting Oct 24, 2023
5c9286b
add values.yaml
realshuting Oct 24, 2023
abe380a
update workflow cmd
realshuting Oct 24, 2023
cb4ed6c
addcat output
realshuting Oct 24, 2023
1cc0db2
add tests/kyverno-pss.js
realshuting Oct 25, 2023
6a33d5f
update failure threshold
realshuting Oct 25, 2023
a28a913
fail on error
realshuting Oct 25, 2023
1d2d75a
fix typo
realshuting Oct 25, 2023
5174113
remove unused files
realshuting Oct 25, 2023
334dfea
update makefile
realshuting Oct 27, 2023
fe26f98
Merge branch 'add_threshold' of https://github.com/kyverno/load-testi…
realshuting Oct 27, 2023
47c90b9
fix typo
realshuting Oct 27, 2023
6ca54fd
fix indent
realshuting Oct 27, 2023
8038764
fix format
realshuting Oct 27, 2023
0f4860d
fix excluded namespace
realshuting Oct 27, 2023
4acee8b
bump k6
realshuting Oct 27, 2023
8935cd5
Merge pull request #9 from realshuting/add_threshold
realshuting Oct 27, 2023
b10511f
typo
realshuting Oct 27, 2023
862ceb0
Merge pull request #11 from realshuting/add_threshold
realshuting Oct 27, 2023
e16d558
fix paths
realshuting Oct 27, 2023
1193c6d
merge changes
realshuting Oct 27, 2023
813d740
fix path
realshuting Oct 27, 2023
742094d
fix typo
realshuting Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/kyverno-wait-ready/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Kyverno pods ready

description: Wait kyverno pods are ready

runs:
using: composite
steps:
- shell: bash
run: |
kubectl wait --namespace kyverno --for=condition=ready pod --selector '!job-name' --timeout=60s
29 changes: 29 additions & 0 deletions .github/actions/setup-test-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Setup test env

description: Create kind cluster, deploy kyverno, and wait pods are ready.

inputs:
version:
description: kubernetes version
default: v1.27.3
free-disk-space:
description: free disk space
default: 'false'

runs:
using: composite
steps:
- uses: jlumbroso/free-disk-space@76866dbe54312617f00798d1762df7f43def6e5c # v1.2.0
if: ${{ inputs.free-disk-space == 'true' }}
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: false
swap-storage: false
- shell: bash
run: |
export KIND_IMAGE=kindest/node:${{ inputs.version }}
make kind-create-cluster kind-deploy-kyverno
- uses: ./.github/actions/kyverno-wait-ready
52 changes: 52 additions & 0 deletions .github/workflows/load-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: load-test

permissions: {}

on:
pull_request:
branches:
- 'main'
- 'add_threshold'

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

jobs:
run-load-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
vus:
- name: vu
values:
- 1000
iterations:
- name: iteration
values:
- 1000
scripts:
- name: script
values:
- kyverno-pss.js
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Setup build env
uses: ./.github/actions/setup-test-env
timeout-minutes: 10
- name: Wait for kyverno ready
uses: ./.github/actions/kyverno-wait-ready
- name: Run local k6 test
shell: bash
run: |
export VUS=${{ join(matrix.vus.values, ',') }}
export ITERATIONS=${{ join(matrix.iterations.values, ',') }}
export SCRIPT=${{ join(matrix.scripts.values, ',') }}
make kyverno-pss-block
cat k6/${SCRIPT}-${VUS}vu-${ITERATIONS}it-logs.txt
- name: Check errors
shell: bash
run: |
make check-error
70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
############
# DEFAULTS #
############

KIND_IMAGE ?= kindest/node:v1.27.3
KIND_NAME ?= kind
KIND_CONFIG ?= default

#########
# TOOLS #
#########

TOOLS_DIR := $(PWD)/.tools
KIND := $(TOOLS_DIR)/kind
KIND_VERSION := v0.20.0
HELM := $(TOOLS_DIR)/helm
HELM_VERSION := v3.12.3
HELM_DOCS := $(TOOLS_DIR)/helm-docs
HELM_DOCS_VERSION := v1.11.0

$(KIND):
@echo Install kind... >&2
@GOBIN=$(TOOLS_DIR) go install sigs.k8s.io/kind@$(KIND_VERSION)

$(HELM):
@echo Install helm... >&2
@GOBIN=$(TOOLS_DIR) go install helm.sh/helm/v3/cmd/helm@$(HELM_VERSION)

########
# HELM #
########

.PHONY: helm-add-repo # Add Kyverno chart repository
helm-add-repo: $(HELM)
@echo Add kyverno chart... >&2
@$(HELM) repo add kyverno https://kyverno.github.io/kyverno/

.PHONY: helm-install-kyverno
helm-install-kyverno: helm-add-repo ## Install kyverno helm chart
@echo Install kyverno chart... >&2
@$(HELM) upgrade --install kyverno --namespace kyverno --create-namespace --wait kyverno/kyverno --devel --values ./configs/kyverno/values.yaml

########
# KIND #
########

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

.PHONY: kind-deploy-kyverno
kind-deploy-kyverno: helm-add-repo helm-install-kyverno ## Deploy kyverno helm chart

######
# K6 #
######

VUS ?= 10
ITERATIONS ?= 1000
SCRIPT ?= kyverno-pss.js

.PHONY: kyverno-pss-block
kyverno-pss-block:
cd k6 && \
./start.sh ./tests/${SCRIPT} ${VUS} ${ITERATIONS}

.PHONY: check-error
check-error:
@grep -q "level=error" "k6/${SCRIPT}-${VUS}vu-${ITERATIONS}it-logs.txt" || (echo "Unexpected behavior during load testing, please check results."; exit 1)
36 changes: 36 additions & 0 deletions configs/kind/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
kubeadmConfigPatches:
- |-
kind: ClusterConfiguration
controllerManager:
extraArgs:
bind-address: 0.0.0.0
etcd:
local:
extraArgs:
listen-metrics-urls: http://0.0.0.0:2382
scheduler:
extraArgs:
bind-address: 0.0.0.0
- |-
kind: KubeProxyConfiguration
metricsBindAddress: 0.0.0.0
nodes:
- role: control-plane
kubeadmConfigPatches:
- |-
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
- role: worker
- role: worker
- role: worker
40 changes: 40 additions & 0 deletions configs/kyverno/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
features:
admissionReports:
enabled: false
omitEvents:
eventTypes:
- PolicyViolation
- PolicyApplied
- PolicyError
- PolicySkipped

admissionController:

serviceMonitor:
enabled: true

container:
image:
tag: release-1.11

resources:
limits:
memory: 2Gi
requests:
cpu: 1
memory: 1Gi

reportsController:
serviceMonitor:
enabled: true

container:
image:
tag: release-1.11

resources:
limits:
memory: 10Gi
requests:
cpu: 1
memory: 1Gi
3 changes: 1 addition & 2 deletions k6/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ spec:
spec:
serviceAccountName: load-test
containers:
- image: grafana/k6:0.45.0
- image: grafana/k6:0.47.0
resources: {}
name: k6
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
capabilities:
Expand Down
34 changes: 17 additions & 17 deletions k6/pss-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,101 +5,101 @@ policyExclude:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
adding-capabilities-strict:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-host-namespaces:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-host-path:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-host-ports:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-host-process:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-privilege-escalation:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-privileged-containers:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-proc-mount:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
disallow-selinux:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
require-run-as-non-root-user:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
require-run-as-nonroot:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
restrict-apparmor-profiles:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
restrict-seccomp:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
restrict-seccomp-strict:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
restrict-sysctls:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
restrict-volume-types:
any:
- resources:
namespaces:
- load-tests
- load-test
name: load-test*
Loading
Loading