-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #614 from redpanda-data/ae/568b
feat: add prometheus for testing
- Loading branch information
Showing
10 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
--- | ||
tls: | ||
enabled: false | ||
|
||
monitoring: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
--- | ||
tls: | ||
enabled: true | ||
|
||
monitoring: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
charts/redpanda/templates/tests/test-prometheus-targets.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{{/* | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/}} | ||
{{- if .Values.monitoring.enabled }} | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ include "redpanda.fullname" . }}-test-prometheus-targets" | ||
namespace: {{ .Release.Namespace | quote }} | ||
labels: | ||
{{- with include "full.labels" . }} | ||
{{- . | nindent 4 }} | ||
{{- end }} | ||
annotations: | ||
"helm.sh/hook": test | ||
"helm.sh/hook-delete-policy": before-hook-creation | ||
spec: | ||
restartPolicy: Never | ||
securityContext: | ||
runAsUser: 65535 | ||
runAsGroup: 65535 | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ template "redpanda.name" . }} | ||
image: mintel/docker-alpine-bash-curl-jq:latest | ||
command: [ "/bin/bash", "-c" ] | ||
args: | ||
- | | ||
set -xe | ||
# added since it takes 20s to start | ||
sleep 20 | ||
curl_prometheus_retry() { | ||
local retries="$1" | ||
# Run the command, and save the exit code | ||
# from: https://prometheus.io/docs/prometheus/latest/querying/api/ | ||
local RESULT=$( curl --fail http://prometheus-operated.prometheus.svc.cluster.local:9090/api/v1/targets?scrapePool=serviceMonitor/{{ .Release.Namespace }}/{{ .Release.Namespace }}/0 | jq . | grep '"health": "up"' | wc -l ) | ||
local exit_code=$? | ||
# If the exit code is non-zero (i.e. command failed), and we have not | ||
# reached the maximum number of retries, run the command again | ||
if [[ ( $exit_code -ne 0 || $RESULT -ne {{ .Values.statefulset.replicas }} ) && $retries -gt 0 ]]; then | ||
sleep 2 | ||
echo $( curl_prometheus_retry $(($retries - 1)) ) | ||
return | ||
fi | ||
echo $RESULT | ||
} | ||
RESULT=$(curl_prometheus_retry 20) | ||
set +x | ||
if [ $RESULT != {{ .Values.statefulset.replicas }} ]; then | ||
curl --fail http://prometheus-operated.prometheus.svc.cluster.local:9090/api/v1/targets?scrapePool=serviceMonitor/{{ .Release.Namespace }}/{{ .Release.Namespace }}/0 | jq . | ||
echo "the number of targets unexpected; got ${RESULT} targets 'up', but was expecting {{ .Values.statefulset.replicas }} " | ||
exit 1 | ||
fi | ||
{{- end }} |