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

prometheus: initial integration with prometheus-watcher

Config reload working, rule integration still to be done.
This commit is contained in:
Frederic Branczyk 2017-03-15 14:29:38 +01:00
parent 793b55c7a5
commit de2fad714e
No known key found for this signature in database
GPG key ID: CA14788B1E48B256
2 changed files with 23 additions and 39 deletions
cmd/operator
pkg/prometheus

View file

@ -48,7 +48,7 @@ func init() {
flagset.StringVar(&cfg.KubeletObject, "kubelet-object", "", "Endpoints object to write kubelets into in format \"namespace/name\"")
flagset.BoolVar(&cfg.TLSInsecure, "tls-insecure", false, "- NOT RECOMMENDED FOR PRODUCTION - Don't verify API server's CA certificate.")
flagset.BoolVar(&analyticsEnabled, "analytics", true, "Send analytical event (Cluster Created/Deleted etc.) to Google Analytics")
flagset.StringVar(&cfg.ConfigReloaderImage, "config-reloader-image", "jimmidyson/configmap-reload:latest", "Reload Image ")
flagset.StringVar(&cfg.ConfigReloaderImage, "config-reloader-image", "quay.io/coreos/prometheus-watcher:v0.0.1", "Config and rule reload image")
flagset.Parse(os.Args[1:])
}

View file

@ -107,36 +107,6 @@ func makeStatefulSet(p v1alpha1.Prometheus, old *v1beta1.StatefulSet, config *Co
return statefulset
}
func volumesInfoFromRuleConfigMaps(ruleConfigMaps []*v1.ConfigMap) ([]v1.Volume, []v1.VolumeMount, []string) {
volumes := make([]v1.Volume, len(ruleConfigMaps))
volumeMounts := make([]v1.VolumeMount, len(ruleConfigMaps))
ruleFileVolumeArgs := make([]string, len(ruleConfigMaps))
for i, c := range ruleConfigMaps {
volumeName := fmt.Sprintf("rules-%d", i)
ruleFilePath := configMapRuleFileFolder(i)
volumes[i] = v1.Volume{
Name: volumeName,
VolumeSource: v1.VolumeSource{
ConfigMap: &v1.ConfigMapVolumeSource{
LocalObjectReference: v1.LocalObjectReference{
Name: c.Name,
},
},
},
}
volumeMounts[i] = v1.VolumeMount{
Name: volumeName,
ReadOnly: true,
MountPath: ruleFilePath,
}
ruleFileVolumeArgs[i] = fmt.Sprintf("-volume-dir=%s", ruleFilePath)
}
return volumes, volumeMounts, ruleFileVolumeArgs
}
func makeEmptyConfig(name string) *v1.Secret {
return &v1.Secret{
ObjectMeta: apimetav1.ObjectMeta{
@ -224,8 +194,6 @@ func makeStatefulSetSpec(p v1alpha1.Prometheus, c *Config, ruleConfigMaps []*v1.
Path: path.Clean(webRoutePrefix + "/-/reload"),
}
ruleFileVolumes, ruleFileVolumeMounts, ruleFileVolumeArgs := volumesInfoFromRuleConfigMaps(ruleConfigMaps)
volumes := append([]v1.Volume{
{
Name: "config",
@ -235,7 +203,13 @@ func makeStatefulSetSpec(p v1alpha1.Prometheus, c *Config, ruleConfigMaps []*v1.
},
},
},
}, ruleFileVolumes...)
{
Name: "rules",
VolumeSource: v1.VolumeSource{
EmptyDir: &v1.EmptyDirVolumeSource{},
},
},
})
promVolumeMounts := append([]v1.VolumeMount{
{
@ -243,12 +217,17 @@ func makeStatefulSetSpec(p v1alpha1.Prometheus, c *Config, ruleConfigMaps []*v1.
ReadOnly: true,
MountPath: "/etc/prometheus/config",
},
{
Name: "rules",
ReadOnly: true,
MountPath: "/etc/prometheus/rules",
},
{
Name: volumeName(p.Name),
MountPath: "/var/prometheus/data",
SubPath: subPathForStorage(p.Spec.Storage),
},
}, ruleFileVolumeMounts...)
})
configReloadVolumeMounts := append([]v1.VolumeMount{
{
@ -256,12 +235,17 @@ func makeStatefulSetSpec(p v1alpha1.Prometheus, c *Config, ruleConfigMaps []*v1.
ReadOnly: true,
MountPath: "/etc/prometheus/config",
},
}, ruleFileVolumeMounts...)
{
Name: "rules",
MountPath: "/etc/prometheus/rules",
},
})
configReloadArgs := append([]string{
fmt.Sprintf("-webhook-url=%s", localReloadURL),
"-volume-dir=/etc/prometheus/config",
}, ruleFileVolumeArgs...)
fmt.Sprintf("-reload-url=%s", localReloadURL),
"-config-volume-dir=/etc/prometheus/config",
"-rule-volume-dir=/etc/prometheus/rules",
})
return v1beta1.StatefulSetSpec{
ServiceName: governingServiceName,