mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
commit
a428c581c8
3 changed files with 34 additions and 9 deletions
pkg
|
@ -117,6 +117,11 @@ func makeStatefulSetSpec(a *spec.Alertmanager) v1beta1.StatefulSetSpec {
|
|||
fmt.Sprintf("-mesh.listen-address=:%d", 6783),
|
||||
fmt.Sprintf("-storage.path=%s", "/etc/alertmanager/data"),
|
||||
}
|
||||
|
||||
if a.Spec.ExternalURL != "" {
|
||||
commands = append(commands, "-web.external-url="+a.Spec.ExternalURL)
|
||||
}
|
||||
|
||||
for i := int32(0); i < a.Spec.Replicas; i++ {
|
||||
commands = append(commands, fmt.Sprintf("-mesh.peer=%s-%d.%s.%s.svc", a.Name, i, "alertmanager", a.Namespace))
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ package prometheus
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
"k8s.io/client-go/pkg/api/resource"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
|
@ -146,6 +148,23 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
// generally has a very high time series churn.
|
||||
memChunks := reqMem.Value() / 1024 / 5
|
||||
|
||||
promArgs := []string{
|
||||
"-storage.local.retention=" + p.Spec.Retention,
|
||||
"-storage.local.memory-chunks=" + fmt.Sprintf("%d", memChunks),
|
||||
"-storage.local.max-chunks-to-persist=" + fmt.Sprintf("%d", memChunks/2),
|
||||
"-storage.local.num-fingerprint-mutexes=4096",
|
||||
"-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)
|
||||
extUrl, err := url.Parse(p.Spec.ExternalURL)
|
||||
if err == nil {
|
||||
webRoutePrefix = extUrl.Path
|
||||
}
|
||||
}
|
||||
|
||||
return v1beta1.StatefulSetSpec{
|
||||
ServiceName: "prometheus",
|
||||
Replicas: &p.Spec.Replicas,
|
||||
|
@ -168,14 +187,7 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
Args: []string{
|
||||
"-storage.local.retention=" + p.Spec.Retention,
|
||||
"-storage.local.memory-chunks=" + fmt.Sprintf("%d", memChunks),
|
||||
"-storage.local.max-chunks-to-persist=" + fmt.Sprintf("%d", memChunks/2),
|
||||
"-storage.local.num-fingerprint-mutexes=4096",
|
||||
"-storage.local.path=/var/prometheus/data",
|
||||
"-config.file=/etc/prometheus/config/prometheus.yaml",
|
||||
},
|
||||
Args: promArgs,
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
{
|
||||
Name: "config",
|
||||
|
@ -196,7 +208,7 @@ func makeStatefulSetSpec(p spec.Prometheus) v1beta1.StatefulSetSpec {
|
|||
ReadinessProbe: &v1.Probe{
|
||||
Handler: v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/status",
|
||||
Path: path.Clean(webRoutePrefix + "/status"),
|
||||
Port: intstr.FromString("web"),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -44,6 +44,7 @@ type PrometheusSpec struct {
|
|||
BaseImage string `json:"baseImage"`
|
||||
Replicas int32 `json:"replicas"`
|
||||
Retention string `json:"retention"`
|
||||
ExternalURL string `json:"externalUrl"`
|
||||
Storage *StorageSpec `json:"storage"`
|
||||
Alerting AlertingSpec `json:"alerting"`
|
||||
Resources v1.ResourceRequirements `json:"resources"`
|
||||
|
@ -143,6 +144,13 @@ type AlertmanagerSpec struct {
|
|||
// Storage is the definition of how storage will be used by the Alertmanager
|
||||
// instances.
|
||||
Storage *StorageSpec `json:"storage"`
|
||||
// ExternalURL is the URL under which Alertmanager is externally reachable
|
||||
// (for example, if Alertmanager is served via a reverse proxy). Used for
|
||||
// generating relative and absolute links back to Alertmanager itself. If the
|
||||
// URL has a path portion, it will be used to prefix all HTTP endpoints
|
||||
// served by Alertmanager. If omitted, relevant URL components will be
|
||||
// derived automatically.
|
||||
ExternalURL string `json:"externalUrl,omitempty"`
|
||||
}
|
||||
|
||||
type AlertmanagerList struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue