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

Make a test to show how to use the clusterMetrics feature support the CoreDNS service integration #1229

Merged
merged 6 commits into from
Feb 12, 2025
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
3 changes: 2 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

- name: List tests
id: list_tests
working-directory: charts/k8s-monitoring/tests/integration
run: |
tests=$(ls charts/k8s-monitoring/tests/integration)
tests=$(find . -name values.yaml -exec dirname {} \;)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tests=$(find . -name values.yaml -exec dirname {} \;)
tests=$(find . -name values.yaml -exec dirname {} +)

🤷

echo "Tests: ${tests}"
echo "tests=$(echo "${tests}" | jq --raw-input --slurp --compact-output 'split("\n") | map(select(. != ""))')" >> "${GITHUB_OUTPUT}"

Expand Down Expand Up @@ -57,7 +58,7 @@

- name: Read special test dependencies
id: read_deps
run: |

Check warning on line 61 in .github/workflows/integration-test.yml

View workflow job for this annotation

GitHub Actions / runner / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:3:114: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/integration-test.yml:61:9: shellcheck reported issue in this script: SC2086:info:3:114: Double quote to prevent globbing and word splitting [shellcheck]

Check warning on line 61 in .github/workflows/integration-test.yml

View workflow job for this annotation

GitHub Actions / runner / actionlint

[actionlint] reported by reviewdog 🐶 shellcheck reported issue in this script: SC2086:info:5:21: Double quote to prevent globbing and word splitting [shellcheck] Raw Output: i:.github/workflows/integration-test.yml:61:9: shellcheck reported issue in this script: SC2086:info:5:21: Double quote to prevent globbing and word splitting [shellcheck]
if [ -f "charts/k8s-monitoring/tests/integration/${{ matrix.test }}/deps.json" ]; then
# e.g. ["terraform", "vendir"]
echo "deps=$(jq --compact-output '.' charts/k8s-monitoring/tests/integration/${{ matrix.test }}/deps.json)" >> $GITHUB_ENV
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: grafana
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: grafana
namespace: grafana
spec:
interval: 1m
url: https://grafana.github.io/helm-charts
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: grafana
namespace: grafana
spec:
interval: 1m
chart:
spec:
chart: grafana
sourceRef:
kind: HelmRepository
name: grafana
namespace: grafana
interval: 1m
values:
grafana.ini:
auth.anonymous:
enabled: true
org_role: Admin
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc:9090
isDefault: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: k8s-monitoring-test
spec:
interval: 1m
url: https://github.com/grafana/k8s-monitoring-helm
ref:
branch: main
ignore: |
/*
!/charts/k8s-monitoring-test
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: k8s-monitoring-test
spec:
interval: 1m
chart:
spec:
chart: charts/k8s-monitoring-test
sourceRef:
kind: GitRepository
name: k8s-monitoring-test
interval: 1m
dependsOn:
- name: prometheus
namespace: prometheus
values:
tests:
- env:
CLUSTER: coredns-integration-test
PROMETHEUS_URL: http://prometheus-server.prometheus.svc:9090/api/v1/query

queries:
# CoreDNS metrics
- query: coredns_build_info{cluster="$CLUSTER", job="integrations/coredns"}
type: promql

# DPM check
- query: avg(count_over_time(scrape_samples_scraped{cluster="$CLUSTER"}[1m]))
type: promql
expect:
value: 1
operator: ==
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
cluster:
name: coredns-integration-test

destinations:
- name: localPrometheus
type: prometheus
url: http://prometheus-server.prometheus.svc:9090/api/v1/write

clusterMetrics:
enabled: true
kubeDNS:
enabled: true
jobLabel: integrations/coredns

alloy-metrics:
enabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: prometheus
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: prometheus-community
namespace: prometheus
spec:
interval: 1m
url: https://prometheus-community.github.io/helm-charts
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: prometheus
namespace: prometheus
spec:
interval: 1m
chart:
spec:
chart: prometheus
version: "^25"
sourceRef:
kind: HelmRepository
name: prometheus-community
namespace: prometheus
interval: 1m
values:
server:
extraFlags:
- enable-feature=remote-write-receiver

persistentVolume:
enabled: false

service:
servicePort: 9090

serverFiles:
prometheus.yml:
scrape_configs: []

configmapReload:
prometheus:
enabled: false

alertmanager:
enabled: false

kube-state-metrics:
enabled: false

prometheus-node-exporter:
enabled: false

prometheus-pushgateway:
enabled: false