mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
Merge pull request #85 from brancz/fix-config-reloading
*: fix config reloading when using external urls
This commit is contained in:
commit
f143b2fbf5
3 changed files with 25 additions and 5 deletions
4
Makefile
4
Makefile
|
@ -1,7 +1,7 @@
|
|||
all: build
|
||||
|
||||
REPO=quay.io/coreos/prometheus-operator
|
||||
TAG=$(shell git rev-parse --short HEAD)
|
||||
REPO?=quay.io/coreos/prometheus-operator
|
||||
TAG?=$(shell git rev-parse --short HEAD)
|
||||
|
||||
build:
|
||||
./scripts/check_license.sh
|
||||
|
|
|
@ -16,6 +16,8 @@ package alertmanager
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"k8s.io/client-go/pkg/api/resource"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
|
@ -118,8 +120,19 @@ func makeStatefulSetSpec(a *spec.Alertmanager) v1beta1.StatefulSetSpec {
|
|||
fmt.Sprintf("-storage.path=%s", "/etc/alertmanager/data"),
|
||||
}
|
||||
|
||||
webRoutePrefix := ""
|
||||
if a.Spec.ExternalURL != "" {
|
||||
commands = append(commands, "-web.external-url="+a.Spec.ExternalURL)
|
||||
extUrl, err := url.Parse(a.Spec.ExternalURL)
|
||||
if err == nil {
|
||||
webRoutePrefix = extUrl.Path
|
||||
}
|
||||
}
|
||||
|
||||
localReloadURL := &url.URL{
|
||||
Scheme: "http",
|
||||
Host: "localhost:9093",
|
||||
Path: path.Clean(webRoutePrefix + "/-/reload"),
|
||||
}
|
||||
|
||||
for i := int32(0); i < a.Spec.Replicas; i++ {
|
||||
|
@ -171,7 +184,7 @@ func makeStatefulSetSpec(a *spec.Alertmanager) v1beta1.StatefulSetSpec {
|
|||
Name: "config-reloader",
|
||||
Image: "jimmidyson/configmap-reload",
|
||||
Args: []string{
|
||||
"-webhook-url=http://localhost:9093/-/reload",
|
||||
fmt.Sprintf("-webhook-url=%s", localReloadURL),
|
||||
"-volume-dir=/etc/alertmanager/config",
|
||||
},
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
|
|
|
@ -156,6 +156,7 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
"-storage.local.path=/var/prometheus/data",
|
||||
"-config.file=/etc/prometheus/config/prometheus.yaml",
|
||||
}
|
||||
|
||||
webRoutePrefix := ""
|
||||
if p.Spec.ExternalURL != "" {
|
||||
promArgs = append(promArgs, "-web.external-url="+p.Spec.ExternalURL)
|
||||
|
@ -165,6 +166,12 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
}
|
||||
}
|
||||
|
||||
localReloadURL := &url.URL{
|
||||
Scheme: "http",
|
||||
Host: "localhost:9090",
|
||||
Path: path.Clean(webRoutePrefix + "/-/reload"),
|
||||
}
|
||||
|
||||
return v1beta1.StatefulSetSpec{
|
||||
ServiceName: "prometheus",
|
||||
Replicas: &p.Spec.Replicas,
|
||||
|
@ -224,7 +231,7 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
Name: "config-reloader",
|
||||
Image: "jimmidyson/configmap-reload",
|
||||
Args: []string{
|
||||
"-webhook-url=http://localhost:9090/-/reload",
|
||||
fmt.Sprintf("-webhook-url=%s", localReloadURL),
|
||||
"-volume-dir=/etc/prometheus/config",
|
||||
},
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
|
@ -244,7 +251,7 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
Name: "rules-reloader",
|
||||
Image: "jimmidyson/configmap-reload",
|
||||
Args: []string{
|
||||
"-webhook-url=http://localhost:9090/-/reload",
|
||||
fmt.Sprintf("-webhook-url=%s", localReloadURL),
|
||||
"-volume-dir=/etc/prometheus/rules/",
|
||||
},
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue