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

Add prometheus scraping also for external-dns and coredns pods #876

Merged
merged 1 commit into from
Apr 25, 2022
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
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,20 @@ define debug
dlv $1
endef

define annotate-for-scraping
kubectl annotate pods -n k8gb -l $1 --overwrite prometheus.io/scrape="true" --overwrite prometheus.io/port="$2" --context=k3d-$3
endef

define stop-scraping
kubectl annotate pods -n k8gb -l $1 prometheus.io/scrape- prometheus.io/port- --context=k3d-$2
endef

define deploy-prometheus
echo -e "\n$(YELLOW)Local cluster $(CYAN)$1$(NC)" ;\
echo -e "\n$(YELLOW)Set annotations on pods that will be scraped by prometheus$(NC)" ;\
kubectl annotate pods -l name=k8gb -n k8gb --overwrite prometheus.io/scrape="true" --context=k3d-$1 ;\
kubectl annotate pods -l name=k8gb -n k8gb --overwrite prometheus.io/port="8080" --context=k3d-$1 ;\
$(call annotate-for-scraping,"name=k8gb",8080,$1) ;\
$(call annotate-for-scraping,"app=external-dns",7979,$1) ;\
$(call annotate-for-scraping,"app.kubernetes.io/name=coredns",9153,$1) ;\
echo -e "\n$(YELLOW)install prometheus $(NC)" ;\
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts ;\
helm repo update ;\
Expand All @@ -565,6 +574,7 @@ define uninstall-prometheus
echo -e "\n$(YELLOW)Local cluster $(CYAN)$1$(NC)" ;\
echo -e "\n$(YELLOW)uninstall prometheus $(NC)" ;\
helm uninstall prometheus -n k8gb --kube-context=k3d-$1 ;\
kubectl annotate pods -l name=k8gb -n k8gb prometheus.io/scrape- --context=k3d-$1 ;\
kubectl annotate pods -l name=k8gb -n k8gb prometheus.io/port- --context=k3d-$1
$(call stop-scraping,"name=k8gb",$1) ;\
$(call stop-scraping,"app=external-dns",$1) ;\
$(call stop-scraping,"app.kubernetes.io/name=coredns",$1)
endef
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This setup is adapted for local scenarios and works without external DNS provide

Consult with [local playground](/docs/local.md) documentation to learn all the details of experimenting with local setup.

Optionally, you can run `make deploy-prometheus` and check the metrics on the test clusters (http://localhost:8080, http://localhost:8081).
Optionally, you can run `make deploy-prometheus` and check the metrics on the test clusters (http://localhost:9080, http://localhost:9081).

## Motivation and Architecture

Expand Down