diff --git a/tests/e2e/examples/crossnamespace/assertions.yaml b/tests/e2e/examples/crossnamespace/assertions.yaml new file mode 100644 index 000000000..47508961a --- /dev/null +++ b/tests/e2e/examples/crossnamespace/assertions.yaml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: grafana-deployment + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +spec: {} +--- +apiVersion: v1 +kind: Service +metadata: + name: grafana-service + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +spec: {} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-ini + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: grafana-plugins + ownerReferences: + - apiVersion: grafana.integreatly.org/v1beta1 + kind: Grafana + name: grafana +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDatasource +metadata: + name: example-grafanadatasource + namespace: (join('-', ['cross', $namespace])) +status: + (lastMessage != null): true \ No newline at end of file diff --git a/tests/e2e/examples/crossnamespace/chainsaw-test.yaml b/tests/e2e/examples/crossnamespace/chainsaw-test.yaml new file mode 100755 index 000000000..279667eba --- /dev/null +++ b/tests/e2e/examples/crossnamespace/chainsaw-test.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: basic +spec: + steps: + - name: step-00 + try: + - apply: + template: true + file: resources.yaml + - assert: + template: true + file: assertions.yaml diff --git a/tests/e2e/examples/crossnamespace/resources.yaml b/tests/e2e/examples/crossnamespace/resources.yaml new file mode 100644 index 000000000..0b0c1a805 --- /dev/null +++ b/tests/e2e/examples/crossnamespace/resources.yaml @@ -0,0 +1,50 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: (join('-', ['cross', $namespace])) +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: Grafana +metadata: + name: grafana + labels: + dashboards: "grafana" +spec: + config: + log: + mode: "console" + auth: + disable_login_form: "false" + security: + admin_user: root + admin_password: secret + deployment: + spec: + template: + spec: + containers: + - name: grafana + securityContext: + allowPrivilegeEscalation: true + readOnlyRootFilesystem: false + readinessProbe: + failureThreshold: 3 +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDatasource +metadata: + name: example-grafanadatasource + namespace: (join('-', ['cross', $namespace])) +spec: + allowCrossNamespaceImport: true + datasource: + access: proxy + database: prometheus + jsonData: + timeInterval: 5s + tlsSkipVerify: true + name: Prometheus + url: http://prometheus-service:9090 + instanceSelector: + matchLabels: + dashboards: grafana