Skip to content

Commit

Permalink
add metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Nairn <[email protected]>
  • Loading branch information
mikenairn committed Dec 4, 2024
1 parent b9e0013 commit 1409e70
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/metallb/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- github.com/metallb/metallb/config/native?ref=v0.13.7
12 changes: 12 additions & 0 deletions config/observability/k8s_prometheus_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: k8s
namespace: monitoring
spec:
remoteWrite:
- url: http://thanos-receive-router:19291/api/v1/receive
writeRelabelConfigs:
- action: replace
replacement: cluster1
targetLabel: cluster_id
16 changes: 16 additions & 0 deletions config/observability/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resources:
- github.com/kuadrant/kuadrant-operator/config/observability?ref=main
- ./thanos
- github.com/kuadrant/kuadrant-operator/examples/dashboards?ref=main
- github.com/kuadrant/kuadrant-operator/examples/alerts?ref=main

patches:
- target:
kind: ServiceMonitor
patch: |
$patch: delete
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: ANY
- path: k8s_prometheus_patch.yaml
10 changes: 10 additions & 0 deletions config/observability/thanos/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resources:
- github.com/kuadrant/kuadrant-operator/config/thanos?ref=main

patches:
- patch: |-
$patch: delete
apiVersion: v1
kind: Namespace
metadata:
name: monitoring
29 changes: 26 additions & 3 deletions test/scale/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@

Create a kind cluster with prometheus/thanos installed and configured
```shell
make kube-burner
./bin/kube-burner init -c config.yaml
```
make local-setup
kubectl apply --server-side -k config/observability
kubectl apply --server-side -k config/observability # Run twice if it fails the first time
```

Forward port for prometheus
```shell
kubectl -n monitoring port-forward service/thanos-query 9090:9090
```

Forward port for graphana (Optional)
```shell
kubectl -n monitoring port-forward service/grafana 3000:3000
```
Access dashboards http://127.0.0.1:3000

Tail all operator logs (Optional)
```shell
kubectl stern -l control-plane=dns-operator-controller-manager -A
```

Run default scale test(1 iteration using the inmemory provider)
```shell
PROMETHEUS_URL=http://127.0.0.1:9090 PROMETHEUS_TOKEN="" make test-scale
```
15 changes: 15 additions & 0 deletions test/scale/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
metricsEndpoints:
- endpoint: {{ .PROMETHEUS_URL }}
token: {{ .PROMETHEUS_TOKEN }}
metrics:
- ./metrics.yaml
indexer:
type: local
metricsDirectory: ./metrics

jobs:
- name: scale-test-setup-dns-operator-cluster-roles
jobIterations: 1
Expand Down Expand Up @@ -35,6 +44,12 @@ jobs:
- objectTemplate: ./dns-operator/dns-operator-deployment.yaml
kind: Deployment
replicas: 1
- objectTemplate: ./dns-operator/metrics-service.yaml
kind: Service
replicas: 1
- objectTemplate: ./dns-operator/service-monitor.yaml
kind: ServiceMonitor
replicas: 1
- name: scale-test-setup
jobType: create #default
jobIterations: {{ .JOB_ITERATIONS }}
Expand Down
4 changes: 4 additions & 0 deletions test/scale/dns-operator/dns-operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
containers:
- args:
- --leader-elect
- --metrics-bind-address=:8080
- --provider=aws,google,inmemory,azure
- --zap-log-level=debug
command:
Expand All @@ -34,6 +35,9 @@ spec:
initialDelaySeconds: 15
periodSeconds: 20
name: manager
ports:
- containerPort: 8080
name: metrics
readinessProbe:
httpGet:
path: /readyz
Expand Down
2 changes: 1 addition & 1 deletion test/scale/dns-operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- ../../../config/manager
- ../../../config/default

patches:
- patch: |-
Expand Down
13 changes: 13 additions & 0 deletions test/scale/dns-operator/metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
control-plane: dns-operator-controller-manager
name: dns-operator-controller-manager-metrics-service
spec:
ports:
- name: metrics
port: 8080
targetPort: metrics
selector:
control-plane: dns-operator-controller-manager
14 changes: 14 additions & 0 deletions test/scale/dns-operator/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
control-plane: controller-manager
name: dns-operator-metrics-monitor
spec:
endpoints:
- path: /metrics
port: metrics
scheme: http
selector:
matchLabels:
control-plane: dns-operator-controller-manager
2 changes: 2 additions & 0 deletions test/scale/metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- query: sum(rate(container_cpu_usage_seconds_total{container="",namespace=~"kuadrant-system|kuadrant-dns-operator-*|scale-test-.*"}[5m])) by(namespace)
metricName: namespaceCPU
2 changes: 2 additions & 0 deletions test/scale/metrics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 1409e70

Please sign in to comment.