Skip to content

Commit

Permalink
fix: exporter connect to custom redis port (#736)
Browse files Browse the repository at this point in the history
* fix port check

Signed-off-by: drivebyer <wuyangmuc@gmail.com>

* test redis_up

Signed-off-by: drivebyer <wuyangmuc@gmail.com>

* fix exporter env

Signed-off-by: drivebyer <wuyangmuc@gmail.com>

* fix url

Signed-off-by: drivebyer <wuyangmuc@gmail.com>

---------

Signed-off-by: drivebyer <wuyangmuc@gmail.com>
  • Loading branch information
drivebyer authored Dec 25, 2023
1 parent 8e8ded9 commit 8f789aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
8 changes: 7 additions & 1 deletion k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,18 @@ func getExporterEnvironmentVariables(params containerParameters) []corev1.EnvVar
Value: "true",
})
}
if params.Port != nil {
if params.RedisExporterPort != nil {
envVars = append(envVars, corev1.EnvVar{
Name: "REDIS_EXPORTER_WEB_LISTEN_ADDRESS",
Value: fmt.Sprintf(":%d", *params.RedisExporterPort),
})
}
if params.Port != nil {
envVars = append(envVars, corev1.EnvVar{
Name: "REDIS_ADDR",
Value: fmt.Sprintf("redis://localhost:%d", *params.Port),
})
}
if params.RedisExporterEnv != nil {
envVars = append(envVars, *params.RedisExporterEnv...)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,39 +77,40 @@ spec:
- script:
timeout: 30s
content: |
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 1 | tail -n 1 | xargs -I {} curl -s -o /dev/null -w '%{http_code}' http://{}:9122
#
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 1 | tail -n 1 | xargs -I {} curl -s http://{}:9122/metrics | grep -v '^#' | grep -E '\bredis_up\b' | awk '{print $2}'
check:
($stdout=='200'): true
($stdout=='1'): true
- script:
timeout: 30s
content: |
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 2 | tail -n 1 | xargs -I {} curl -s -o /dev/null -w '%{http_code}' http://{}:9122
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 2 | tail -n 1 | xargs -I {} curl -s http://{}:9122/metrics | grep -v '^#' | grep -E '\bredis_up\b' | awk '{print $2}'
check:
($stdout=='200'): true
($stdout=='1'): true
- script:
timeout: 30s
content: |
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 3 | tail -n 1 | xargs -I {} curl -s -o /dev/null -w '%{http_code}' http://{}:9122
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 3 | tail -n 1 | xargs -I {} curl -s http://{}:9122/metrics | grep -v '^#' | grep -E '\bredis_up\b' | awk '{print $2}'
check:
($stdout=='200'): true
($stdout=='1'): true
- script:
timeout: 30s
content: |
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 4 | tail -n 1 | xargs -I {} curl -s -o /dev/null -w '%{http_code}' http://{}:9122
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 4 | tail -n 1 | xargs -I {} curl -s http://{}:9122/metrics | grep -v '^#' | grep -E '\bredis_up\b' | awk '{print $2}'
check:
($stdout=='200'): true
($stdout=='1'): true
- script:
timeout: 30s
content: |
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 5 | tail -n 1 | xargs -I {} curl -s -o /dev/null -w '%{http_code}' http://{}:9122
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 5 | tail -n 1 | xargs -I {} curl -s http://{}:9122/metrics | grep -v '^#' | grep -E '\bredis_up\b' | awk '{print $2}'
check:
($stdout=='200'): true
($stdout=='1'): true
- script:
timeout: 30s
content: |
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 6 | tail -n 1 | xargs -I {} curl -s -o /dev/null -w '%{http_code}' http://{}:9122
kubectl get node -o wide | grep 'worker' | awk '{print $6}' | head -n 6 | tail -n 1 | xargs -I {} curl -s http://{}:9122/metrics | grep -v '^#' | grep -E '\bredis_up\b' | awk '{print $2}'
check:
($stdout=='200'): true
($stdout=='1'): true

- name: Try saving a key from every node
try:
Expand Down

0 comments on commit 8f789aa

Please sign in to comment.