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

chore: chainsaw improvements #2642

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ KUBEBUILDER_ASSETS=$(./bin/setup-envtest use -p path 1.23) go test ./pkg...

To run the end-to-end tests, you'll need [`kind`](https://kind.sigs.k8s.io) and [`chainsaw`](https://kyverno.github.io/chainsaw). Refer to their documentation for installation instructions.

Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Each call to the `e2e` target will setup a fresh `kind` cluster, making it safe to be executed multiple times with a single `prepare-e2e` step.
Once they are installed, the tests can be executed with `make prepare-e2e`, which will build an image to use with the tests, followed by `make e2e`. Each call to the `e2e` target will set up a fresh `kind` cluster, making it safe to be executed multiple times with a single `prepare-e2e` step.

The tests are located under `tests/e2e` and are written to be used with `chainsaw`. Refer to their documentation to understand how tests are written.

To evert the changes made by the `make prepare-e2e` run `make reset`.
To revert the changes made by the `make prepare-e2e` run `make reset`.

### OpenShift End to End tests
To run the end-to-end tests written for OpenShift, you'll need a OpenShift cluster.
Expand Down
19 changes: 3 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,13 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
CHLOGGEN ?= $(LOCALBIN)/chloggen
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
CHAINSAW ?= $(LOCALBIN)/chainsaw

KUSTOMIZE_VERSION ?= v5.0.3
CONTROLLER_TOOLS_VERSION ?= v0.12.0
GOLANGCI_LINT_VERSION ?= v1.54.0
KIND_VERSION ?= v0.20.0

# Checks if chainsaw is in your PATH
ifneq ($(shell which chainsaw),)
CHAINSAW ?= $(shell which chainsaw)
else
CHAINSAW ?= $(LOCALBIN)/chainsaw
endif
CHAINSAW_VERSION ?= v0.1.4

.PHONY: install-tools
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw
Expand Down Expand Up @@ -406,15 +401,7 @@ crdoc: ## Download crdoc locally if necessary.

.PHONY: chainsaw
chainsaw: ## Find or download chainsaw
ifeq (, $(shell which chainsaw))
@{ \
set -e ;\
go install github.com/kyverno/chainsaw@v0.1.4 ;\
}
CHAINSAW ?= $(GOBIN)/chainsaw
else
CHAINSAW ?= $(shell which chainsaw)
endif
$(call go-get-tool,$(CHAINSAW), github.com/kyverno/chainsaw,$(CHAINSAW_VERSION))

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
creationTimestamp: null
name: instrumentation-apache-httpd
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 3000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=3000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-dotnet-musl
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=2000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-dotnet
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=2000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ metadata:
creationTimestamp: null
name: instrumentation-go
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 0/0
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-00
try:
Expand All @@ -14,12 +19,6 @@ spec:
file: 00-install-instrumentation.yaml
- name: step-01
try:
- script:
content: kubectl annotate namespace ${NAMESPACE} openshift.io/sa.scc.uid-range=0/0
--overwrite
- script:
content: kubectl annotate namespace ${NAMESPACE} openshift.io/sa.scc.supplemental-groups=2000/1000
--overwrite
- script:
content: ./add-scc.sh
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ metadata:
creationTimestamp: null
name: instrumentation-java-other-ns
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-01
try:
Expand All @@ -15,22 +20,6 @@ spec:
name: my-other-ns
- name: step-02
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=2000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 02-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-java
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=2000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-nginx-contnr-secctx
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 3000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=3000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-nginx-multicontainer
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 3000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=3000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-nginx
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 3000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=3000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-nodejs
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=2000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@ metadata:
creationTimestamp: null
name: instrumentation-python
spec:
namespaceTemplate:
metadata:
annotations:
openshift.io/sa.scc.uid-range: 1000/1000
openshift.io/sa.scc.supplemental-groups: 2000/1000
steps:
- name: step-00
try:
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.uid-range=1000/1000
- --overwrite
entrypoint: kubectl
- command:
args:
- annotate
- namespace
- ${NAMESPACE}
- openshift.io/sa.scc.supplemental-groups=2000/1000
- --overwrite
entrypoint: kubectl
- apply:
file: 00-install-collector.yaml
- apply:
Expand Down
Loading
Loading