From 8a1be3c4d4373137e6db5a50a2d5b38a8f207a07 Mon Sep 17 00:00:00 2001 From: realanna Date: Thu, 23 Mar 2023 10:48:39 +0100 Subject: [PATCH 1/2] fix: move prometheus install into make file to allow local integration tests Signed-off-by: realanna --- .../deploy-prometheus-on-cluster/action.yml | 23 +++++-------------- Makefile | 17 ++++++++++++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/actions/deploy-prometheus-on-cluster/action.yml b/.github/actions/deploy-prometheus-on-cluster/action.yml index 503c9702c0..99885c9e4a 100644 --- a/.github/actions/deploy-prometheus-on-cluster/action.yml +++ b/.github/actions/deploy-prometheus-on-cluster/action.yml @@ -4,28 +4,17 @@ runs: using: "composite" steps: - name: Install and expose Prometheus - working-directory: ./test shell: bash run: | - kubectl create namespace monitoring --dry-run=client -o yaml | kubectl apply -f - - kubectl apply --server-side -f ./prometheus/setup - kubectl wait --for=condition=Established --all CustomResourceDefinition --namespace=monitoring - kubectl apply -f ./prometheus/ - kubectl wait --for=condition=available deployment/prometheus-operator -n monitoring --timeout=120s - kubectl wait --for=condition=available deployment/prometheus-adapter -n monitoring --timeout=120s - kubectl wait --for=condition=available deployment/kube-state-metrics -n monitoring --timeout=120s - kubectl wait pod/prometheus-k8s-0 --for=condition=ready --timeout=120s -n monitoring - kubectl -n monitoring port-forward svc/prometheus-k8s 9090 & - kubectl -n monitoring port-forward svc/node-exporter 9100 & - + make install-prometheus # wait for port 9090 to become available while ! nc -vz localhost 9090 > /dev/null 2>&1 ; do - echo "Sleeping until port-forward for Prometheus at port 9090 is ready..." - sleep 5 + echo "Sleeping until port-forward for Prometheus at port 9090 is ready..." + sleep 5 done - + # wait until node exporter is available while ! nc -vz localhost 9100 > /dev/null 2>&1 ; do - echo "Sleeping until port-forward for node exporter at port 9100 is ready..." - sleep 5 + echo "Sleeping until port-forward for node exporter at port 9100 is ready..." + sleep 5 done diff --git a/Makefile b/Makefile index c215b4495c..96351bb002 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ integration-test: kubectl kuttl test --start-kind=false ./test/integration/ --config=kuttl-test.yaml .PHONY: integration-test-local #these tests should run on a real cluster! -integration-test-local: +integration-test-local: install-prometheus kubectl kuttl test --start-kind=false ./test/integration/ --config=kuttl-test-local.yaml .PHONY: load-test @@ -46,6 +46,20 @@ load-test: kubectl apply -f ./test/load/assets/templates/provider.yaml kube-burner init -c ./test/load/cfg.yml --metrics-profile ./test/load/metrics.yml +.PHONY: install-prometheus +install-prometheus: + kubectl create namespace monitoring --dry-run=client -o yaml | kubectl apply -f - + kubectl apply --server-side -f test/prometheus/setup + kubectl wait --for=condition=Established --all CustomResourceDefinition --namespace=monitoring + kubectl apply -f test/prometheus/ + kubectl wait --for=condition=available deployment/prometheus-operator -n monitoring --timeout=120s + kubectl wait --for=condition=available deployment/prometheus-adapter -n monitoring --timeout=120s + kubectl wait --for=condition=available deployment/kube-state-metrics -n monitoring --timeout=120s + kubectl wait pod/prometheus-k8s-0 --for=condition=ready --timeout=120s -n monitoring + kubectl -n monitoring port-forward svc/prometheus-k8s 9090 & + kubectl -n monitoring port-forward svc/node-exporter 9100 & + + .PHONY: cleanup-manifests cleanup-manifests: rm -rf manifests @@ -68,7 +82,6 @@ helm-package: $(MAKE) build-release-manifests CHART_APPVERSION=$(CHART_APPVERSION) RELEASE_REGISTRY=$(RELEASE_REGISTRY) $(MAKE) release-helm-manifests CHART_APPVERSION=$(CHART_APPVERSION) RELEASE_REGISTRY=$(RELEASE_REGISTRY) - .PHONY: build-release-manifests build-release-manifests: $(MAKE) -C operator generate From 6e2df9910b673537255a6364fc28f3d507255934 Mon Sep 17 00:00:00 2001 From: realanna Date: Thu, 23 Mar 2023 11:25:02 +0100 Subject: [PATCH 2/2] fix: pr review Signed-off-by: realanna --- .github/actions/deploy-prometheus-on-cluster/action.yml | 4 ++++ Makefile | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/deploy-prometheus-on-cluster/action.yml b/.github/actions/deploy-prometheus-on-cluster/action.yml index 99885c9e4a..2ebfd8a004 100644 --- a/.github/actions/deploy-prometheus-on-cluster/action.yml +++ b/.github/actions/deploy-prometheus-on-cluster/action.yml @@ -7,6 +7,10 @@ runs: shell: bash run: | make install-prometheus + + kubectl -n monitoring port-forward svc/prometheus-k8s 9090 & + kubectl -n monitoring port-forward svc/node-exporter 9100 & + # wait for port 9090 to become available while ! nc -vz localhost 9090 > /dev/null 2>&1 ; do echo "Sleeping until port-forward for Prometheus at port 9090 is ready..." diff --git a/Makefile b/Makefile index 96351bb002..dab3852de7 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,7 @@ install-prometheus: kubectl wait --for=condition=available deployment/prometheus-adapter -n monitoring --timeout=120s kubectl wait --for=condition=available deployment/kube-state-metrics -n monitoring --timeout=120s kubectl wait pod/prometheus-k8s-0 --for=condition=ready --timeout=120s -n monitoring - kubectl -n monitoring port-forward svc/prometheus-k8s 9090 & - kubectl -n monitoring port-forward svc/node-exporter 9100 & + .PHONY: cleanup-manifests