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 k8gb custom dashboards for Grafana #959

Merged
merged 4 commits into from
Oct 5, 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
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ check: license lint gokart test ## Check project integrity

.PHONY: clean-test-apps
clean-test-apps:
kubectl delete -f deploy/test-apps
kubectl delete --ignore-not-found -f deploy/test-apps
helm -n test-gslb uninstall frontend

# see: https://dev4devs.com/2019/05/04/operator-framework-how-to-debug-golang-operator-projects/
Expand Down Expand Up @@ -264,9 +264,17 @@ deploy-grafana:
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
helm -n k8gb upgrade -i grafana grafana/grafana -f deploy/grafana/values.yaml \
--wait --timeout=2m30s \
--wait --timeout=4m \
--version=6.38.6 \
--kube-context=k3d-$(CLUSTER_NAME)1
kubectl --context k3d-$(CLUSTER_NAME)1 apply -f deploy/grafana/dashboard-cm.yaml -n k8gb
mkdir grafana/dashboards/ || true
cat grafana/controller-resources-metrics.json | sed 's/$${DS_PROMETHEUS}/Prometheus/g' > grafana/dashboards/controller-resources-metrics.json
cat grafana/controller-runtime-metrics.json | sed 's/$${DS_PROMETHEUS}/Prometheus/g' > grafana/dashboards/controller-runtime-metrics.json
cat grafana/custom-metrics/pretty-custom-metrics-dashboard.json | sed 's/$${DS_PROMETHEUS}/Prometheus/g' > grafana/dashboards/pretty-custom-metrics-dashboard.json
kubectl --context k3d-$(CLUSTER_NAME)1 -n k8gb create cm -n k8gb k8gb-dashboards --from-file=./grafana/dashboards/ --dry-run=client -oyaml | kubectl apply --context k3d-$(CLUSTER_NAME)1 -f -
kubectl --context k3d-$(CLUSTER_NAME)1 -n k8gb label cm k8gb-dashboards grafana_dashboard=true --overwrite
rm -rf grafana/dashboards/
@echo -e "\nGrafana is listening on http://localhost:3000\n"
@echo -e "🖖 credentials are admin:admin\n"

Expand All @@ -275,7 +283,8 @@ deploy-grafana:
uninstall-grafana:
@echo -e "\n$(YELLOW)Local cluster $(CYAN)$(CLUSTER_GSLB1)$(NC)"
@echo -e "\n$(YELLOW)uninstall grafana $(NC)"
kubectl --context k3d-$(CLUSTER_NAME)1 delete -f deploy/grafana/dashboard-cm.yaml -n k8gb
kubectl --context k3d-$(CLUSTER_NAME)1 delete --ignore-not-found -f deploy/grafana/dashboard-cm.yaml -n k8gb
kubectl --context k3d-$(CLUSTER_NAME)1 delete cm --ignore-not-found -n k8gb k8gb-dashboards
helm uninstall grafana -n k8gb --kube-context=k3d-$(CLUSTER_NAME)1

.PHONY: dns-tools
Expand Down Expand Up @@ -309,7 +318,7 @@ ensure-cluster-size:

.PHONY: goreleaser
goreleaser:
go install github.com/goreleaser/[email protected]
command -v goreleaser &> /dev/null || go install github.com/goreleaser/[email protected]

.PHONY: release-images
release-images: goreleaser
Expand Down Expand Up @@ -572,7 +581,7 @@ define deploy-prometheus
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts ;\
helm repo update ;\
helm -n k8gb upgrade -i prometheus prometheus-community/prometheus -f deploy/prometheus/values.yaml \
--version 14.2.0 \
--version 15.14.0 \
--wait --timeout=2m0s \
--kube-context=k3d-$1
endef
Expand Down
10 changes: 6 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
domain: absa.oss
layout: go.kubebuilder.io/v2
layout:
- go.kubebuilder.io/v3
plugins:
grafana.kubebuilder.io/v1-alpha: {}
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
projectName: k8gb
repo: github.com/k8gb-io/k8gb
resources:
- group: k8gb
kind: Gslb
version: v1beta1
version: "3"
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
15 changes: 9 additions & 6 deletions deploy/grafana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ datasources:
datasources.yaml:
apiVersion: 1
datasources:
# use this proxied datasource for single cluster deployment
# - name: Prometheus
# type: prometheus
# url: http://prometheus-server.k8gb.svc.cluster.local:9090
# access: proxy
# isDefault: true
- name: Prometheus
type: prometheus
url: http://k3d-test-gslb1-agent-0:30090
access: proxy
isDefault: true
- name: Prometheus-cluster1
type: prometheus
url: http://localhost:9080
Expand Down Expand Up @@ -45,3 +44,7 @@ dashboards:
k8s-node-exporter-full:
# Node Exporter Full https://grafana.com/grafana/dashboards/1860
url: https://grafana.com/api/dashboards/1860/revisions/23/download
rbac:
pspEnabled: false
testFramework:
enabled: false
10 changes: 10 additions & 0 deletions grafana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Sample Grafana Dashboards

This directory contains semi-generated dashboards for Grafana. It's using kubebuilder's
plugin introduced in [pr #2858](https://github.com/kubernetes-sigs/kubebuilder/pull/2858).

In order to modify the custom metrics, change the config in [`custom-metrics/config.yaml`](./custom-metrics/config.yaml) and in project root run:

```bash
kubebuilder edit --plugins grafana.kubebuilder.io/v1-alpha
```
Loading