1
0
Fork 0
mirror of https://github.com/prometheus-operator/prometheus-operator.git synced 2025-04-21 11:48:53 +00:00

Add script using either curl or wget to probe, or failing completely

This commit is contained in:
Matthias Loibl 2019-09-23 18:38:20 +02:00
parent e169f9527a
commit 5eb9cb53db
No known key found for this signature in database
GPG key ID: 78A796CA74CA38BA

View file

@ -596,6 +596,8 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
fmt.Sprintf("--config-envsubst-file=%s", path.Join(confOutDir, configEnvsubstFilename)),
}
const localProbe = `if [ -x "$(command -v curl)" ]; then curl %s; elif [ -x "$(command -v wget)" ]; then wget -q %s; else exit 1; fi`
var livenessProbeHandler v1.Handler
var readinessProbeHandler v1.Handler
var livenessFailureThreshold int32
@ -603,11 +605,12 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
{
healthyPath := path.Clean(webRoutePrefix + "/-/healthy")
if p.Spec.ListenLocal {
localHealthyPath := fmt.Sprintf("http://localhost:9090%s", healthyPath)
livenessProbeHandler.Exec = &v1.ExecAction{
Command: []string{
"wget",
"-q",
fmt.Sprintf("http://localhost:9090%s", healthyPath),
"sh",
"-c",
fmt.Sprintf(localProbe, localHealthyPath, localHealthyPath),
},
}
} else {
@ -620,13 +623,15 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
{
readyPath := path.Clean(webRoutePrefix + "/-/ready")
if p.Spec.ListenLocal {
localReadyPath := fmt.Sprintf("http://localhost:9090%s", readyPath)
readinessProbeHandler.Exec = &v1.ExecAction{
Command: []string{
"wget",
"-q",
fmt.Sprintf("http://localhost:9090%s", readyPath),
"sh",
"-c",
fmt.Sprintf(localProbe, localReadyPath, localReadyPath),
},
}
} else {
readinessProbeHandler.HTTPGet = &v1.HTTPGetAction{
Path: readyPath,