diff --git a/.e2e/chainsaw-tests.yaml b/.e2e/chainsaw-tests.yaml index 9889a87..c3897ed 100644 --- a/.e2e/chainsaw-tests.yaml +++ b/.e2e/chainsaw-tests.yaml @@ -22,3 +22,28 @@ spec: - my-virtual-namespace matchLabels: vcluster.loft.sh/label-vcluster-x-a172cedcae: example-app +--- +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + name: pm-with-ns-selector +spec: + steps: + - try: + - assert: + resource: + apiVersion: monitoring.coreos.com/v1 + kind: PodMonitor + metadata: + name: pm-with-ns-selector-x-default-x-vcluster + namespace: default + spec: + namespaceSelector: {} + selector: + matchExpressions: + - key: vcluster.loft.sh/namespace + operator: In + values: + - my-virtual-namespace + matchLabels: + vcluster.loft.sh/label-vcluster-x-a172cedcae: example-app diff --git a/.e2e/vcluster-resources.yaml b/.e2e/vcluster-resources.yaml index 8e61302..b46b344 100644 --- a/.e2e/vcluster-resources.yaml +++ b/.e2e/vcluster-resources.yaml @@ -15,3 +15,19 @@ spec: app: example-app endpoints: - port: web +--- +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: pm-with-ns-selector + namespace: default + labels: + team: frontend +spec: + namespaceSelector: + any: false + matchNames: + - my-virtual-namespace + selector: + matchLabels: + app: example-app diff --git a/v1/.e2e/scripts/init.sh b/v1/.e2e/scripts/init.sh index 8d594c0..ad206de 100755 --- a/v1/.e2e/scripts/init.sh +++ b/v1/.e2e/scripts/init.sh @@ -20,7 +20,7 @@ while [ $res -ne 0 ] && [ $secondsWaited -lt $timeout ]; do echo "Waiting for CRDs to get created, sleep for 30 seconds..." sleep 30 secondsWaited=$((secondsWaited + 30)) - vcluster connect vcluster -n default -- kubectl get servicemonitorr && vcluster connect vcluster -n default -- kubectl get podmonitor + vcluster connect vcluster -n default -- kubectl get servicemonitor && vcluster connect vcluster -n default -- kubectl get podmonitor res=$? done diff --git a/v2/.e2e/scripts/init.sh b/v2/.e2e/scripts/init.sh new file mode 100755 index 0000000..76783c8 --- /dev/null +++ b/v2/.e2e/scripts/init.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Deploy CRDs and vcluster with the plugin, connect to vcluster and apply resources in resources folder for testing + +PLUGIN_IMAGE=$1 +MYDIR=$(dirname $0) +ROOT_DIR=$MYDIR/../../ +RESOURCES_FILE=$MYDIR/../../../.e2e/vcluster-resources.yaml + +kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd-full/monitoring.coreos.com_podmonitors.yaml +kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd-full/monitoring.coreos.com_servicemonitors.yaml +helm upgrade --install --repo https://charts.loft.sh vcluster vcluster --version v0.20.0-beta.5 --values $MYDIR/vcluster-values.yaml --values $ROOT_DIR/plugin.yaml --set plugins.prometheus-operator-resources.image=$PLUGIN_IMAGE --wait + +vcluster connect vcluster -n default -- kubectl get servicemonitor && vcluster connect vcluster -n default -- kubectl get podmonitor + +res=$? +secondsWaited=0 +timeout=300 + +while [ $res -ne 0 ] && [ $secondsWaited -lt $timeout ]; do + echo "Waiting for CRDs to get created, sleep for 30 seconds..." + sleep 30 + secondsWaited=$((secondsWaited + 30)) + vcluster connect vcluster -n default -- kubectl get servicemonitor && vcluster connect vcluster -n default -- kubectl get podmonitor + res=$? +done + +if [ $res -ne 0 ]; then + echo "Timed out waiting for CRDs to get created in vcluster" + exit 1 +fi + +cat $RESOURCES_FILE | vcluster connect vcluster -n default -- kubectl -n default apply -f - diff --git a/v2/.e2e/scripts/vcluster-values.yaml b/v2/.e2e/scripts/vcluster-values.yaml new file mode 100644 index 0000000..f594a24 --- /dev/null +++ b/v2/.e2e/scripts/vcluster-values.yaml @@ -0,0 +1,17 @@ +controlPlane: + advanced: + serviceAccount: + enabled: false + name: default + statefulSet: + probes: + livenessProbe: + enabled: false + readinessProbe: + enabled: false + distro: + k3s: + enabled: true +rbac: + clusterRole: + enabled: true diff --git a/v2/devspace.yaml b/v2/devspace.yaml index 477feb6..2918c91 100644 --- a/v2/devspace.yaml +++ b/v2/devspace.yaml @@ -25,10 +25,6 @@ deployments: repo: https://charts.loft.sh version: v0.20.0-beta.5 values: - experimental: - syncSettings: - syncLabels: - - app controlPlane: advanced: serviceAccount: