kyverno / chainsaw

Declarative K8s e2e testing
https://kyverno.github.io/chainsaw/
Apache License 2.0
312 stars 46 forks source link

[Question] Run test on multiple clusters #2125

Open pgmgb opened 1 month ago

pgmgb commented 1 month ago

Describe your question

Not sure, if I'm going in the wrong direction here - so let me know if there is another way to achieve this :-)

We have two different cluster types (hyperscaler) and our tests need to be executed with also two different permission sets (admin and customer). 

Based on the documentation, I solved the hyperscaler "issue" with labels:

chainsaw test --selector "test-target in (all, h1)"...
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: my-test
  labels:
    test-target: all # all, h1, h2
(...)

The two different permissions would be handled with the cluster configuration. \ $KUBECONFIG_PATH will be the same file with one cluster but two different users and contexts.

chainsaw test \
    --cluster customer=$KUBECONFIG_PATH:customer \
    --cluster admin=$KUBECONFIG_PATH:admin \
    --no-cluster
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: my-test
spec:
  cluster: customer
(...)

There is now the use case, that certain tests should be executed in the customer and administrator contexts. \ At the moment, I see the only option to duplicate the test and adjusting the cluster: customer to cluster: admin because cluster is a string and not a list.

Are there any suggestions on how to handle this?

chainsaw version Version

v0.2.11

Additional context

No response