mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 11:48:53 +00:00
feat: Make governing services port name configurable
Allow changing the port name to http, to be compatible with istio's port naming requirements
This commit is contained in:
parent
cc584ecfa0
commit
f7a3920e4a
9 changed files with 62 additions and 12 deletions
Documentation
example/prometheus-operator-crd
jsonnet/prometheus-operator
pkg
|
@ -143,6 +143,7 @@ AlertmanagerSpec is a specification of the desired behavior of the Alertmanager
|
|||
| containers | Containers allows injecting additional containers. This is meant to allow adding an authentication proxy to an Alertmanager pod. | []v1.Container | false |
|
||||
| priorityClassName | Priority class assigned to the Pods | string | false |
|
||||
| additionalPeers | AdditionalPeers allows injecting a set of additional Alertmanagers to peer with to form a highly available cluster. | []string | false |
|
||||
| portName | Port name used for the pods and governing service. This defaults to web | string | false |
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
|
@ -373,6 +374,7 @@ PrometheusSpec is a specification of the desired behavior of the Prometheus clus
|
|||
| apiserverConfig | APIServerConfig allows specifying a host and auth methods to access apiserver. If left empty, Prometheus is assumed to run inside of the cluster and will discover API servers automatically and use the pod's CA certificate and bearer token file at /var/run/secrets/kubernetes.io/serviceaccount/. | *[APIServerConfig](#apiserverconfig) | false |
|
||||
| thanos | Thanos configuration allows configuring various aspects of a Prometheus server in a Thanos environment.\n\nThis section is experimental, it may change significantly without deprecation notice in any release.\n\nThis is experimental and may change significantly without backward compatibility in any release. | *[ThanosSpec](#thanosspec) | false |
|
||||
| priorityClassName | Priority class assigned to the Pods | string | false |
|
||||
| portName | Port name used for the pods and governing service. This defaults to web | string | false |
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
|
|
|
@ -1844,6 +1844,10 @@ spec:
|
|||
Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids
|
||||
type: string
|
||||
type: object
|
||||
portName:
|
||||
description: Port name used for the pods and governing service. This
|
||||
defaults to web
|
||||
type: string
|
||||
priorityClassName:
|
||||
description: Priority class assigned to the Pods
|
||||
type: string
|
||||
|
|
|
@ -2130,6 +2130,10 @@ spec:
|
|||
are ANDed.
|
||||
type: object
|
||||
type: object
|
||||
portName:
|
||||
description: Port name used for the pods and governing service. This
|
||||
defaults to web
|
||||
type: string
|
||||
priorityClassName:
|
||||
description: Priority class assigned to the Pods
|
||||
type: string
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,7 @@ const (
|
|||
alertmanagerConfDir = "/etc/alertmanager/config"
|
||||
alertmanagerConfFile = alertmanagerConfDir + "/alertmanager.yaml"
|
||||
alertmanagerStorageDir = "/alertmanager"
|
||||
defaultPortName = "web"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -58,6 +59,9 @@ func makeStatefulSet(am *monitoringv1.Alertmanager, old *appsv1.StatefulSet, con
|
|||
if am.Spec.BaseImage == "" {
|
||||
am.Spec.BaseImage = config.AlertmanagerDefaultBaseImage
|
||||
}
|
||||
if am.Spec.PortName == "" {
|
||||
am.Spec.PortName = defaultPortName
|
||||
}
|
||||
if am.Spec.Version == "" {
|
||||
am.Spec.Version = DefaultVersion
|
||||
}
|
||||
|
@ -142,6 +146,11 @@ func makeStatefulSet(am *monitoringv1.Alertmanager, old *appsv1.StatefulSet, con
|
|||
}
|
||||
|
||||
func makeStatefulSetService(p *monitoringv1.Alertmanager, config Config) *v1.Service {
|
||||
|
||||
if p.Spec.PortName == "" {
|
||||
p.Spec.PortName = defaultPortName
|
||||
}
|
||||
|
||||
svc := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: governingServiceName,
|
||||
|
@ -161,7 +170,7 @@ func makeStatefulSetService(p *monitoringv1.Alertmanager, config Config) *v1.Ser
|
|||
ClusterIP: "None",
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Name: "web",
|
||||
Name: p.Spec.PortName,
|
||||
Port: 9093,
|
||||
TargetPort: intstr.FromInt(9093),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
|
@ -256,14 +265,14 @@ func makeStatefulSetSpec(a *monitoringv1.Alertmanager, config Config) (*appsv1.S
|
|||
livenessProbeHandler := v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: path.Clean(webRoutePrefix + "/-/healthy"),
|
||||
Port: intstr.FromString("web"),
|
||||
Port: intstr.FromString(a.Spec.PortName),
|
||||
},
|
||||
}
|
||||
|
||||
readinessProbeHandler := v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: path.Clean(webRoutePrefix + "/-/ready"),
|
||||
Port: intstr.FromString("web"),
|
||||
Port: intstr.FromString(a.Spec.PortName),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -325,7 +334,7 @@ func makeStatefulSetSpec(a *monitoringv1.Alertmanager, config Config) (*appsv1.S
|
|||
if !a.Spec.ListenLocal {
|
||||
ports = append([]v1.ContainerPort{
|
||||
{
|
||||
Name: "web",
|
||||
Name: a.Spec.PortName,
|
||||
ContainerPort: 9093,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
|
|
|
@ -783,6 +783,13 @@ func schema_pkg_apis_monitoring_v1_AlertmanagerSpec(ref common.ReferenceCallback
|
|||
},
|
||||
},
|
||||
},
|
||||
"portName": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Port name used for the pods and governing service. This defaults to web",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1918,6 +1925,13 @@ func schema_pkg_apis_monitoring_v1_PrometheusSpec(ref common.ReferenceCallback)
|
|||
Format: "",
|
||||
},
|
||||
},
|
||||
"portName": {
|
||||
SchemaProps: spec.SchemaProps{
|
||||
Description: "Port name used for the pods and governing service. This defaults to web",
|
||||
Type: []string{"string"},
|
||||
Format: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -268,6 +268,9 @@ type PrometheusSpec struct {
|
|||
Thanos *ThanosSpec `json:"thanos,omitempty"`
|
||||
// Priority class assigned to the Pods
|
||||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
// Port name used for the pods and governing service.
|
||||
// This defaults to web
|
||||
PortName string `json:"portName,omitempty"`
|
||||
}
|
||||
|
||||
// PrometheusStatus is the most recent observed status of the Prometheus cluster. Read-only. Not
|
||||
|
@ -813,6 +816,9 @@ type AlertmanagerSpec struct {
|
|||
PriorityClassName string `json:"priorityClassName,omitempty"`
|
||||
// AdditionalPeers allows injecting a set of additional Alertmanagers to peer with to form a highly available cluster.
|
||||
AdditionalPeers []string `json:"additionalPeers,omitempty"`
|
||||
// Port name used for the pods and governing service.
|
||||
// This defaults to web
|
||||
PortName string `json:"portName,omitempty"`
|
||||
}
|
||||
|
||||
// AlertmanagerList is a list of Alertmanagers.
|
||||
|
|
|
@ -47,6 +47,7 @@ const (
|
|||
configFilename = "prometheus.yaml.gz"
|
||||
configEnvsubstFilename = "prometheus.env.yaml"
|
||||
sSetInputHashName = "prometheus-operator-input-hash"
|
||||
defaultPortName = "web"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -121,6 +122,10 @@ func makeStatefulSet(
|
|||
p.Spec.Thanos.Version = &v
|
||||
}
|
||||
|
||||
if p.Spec.PortName == "" {
|
||||
p.Spec.PortName = defaultPortName
|
||||
}
|
||||
|
||||
versionStr := strings.TrimLeft(p.Spec.Version, "v")
|
||||
|
||||
version, err := semver.Parse(versionStr)
|
||||
|
@ -257,6 +262,12 @@ func makeConfigSecret(p *monitoringv1.Prometheus, config Config) *v1.Secret {
|
|||
}
|
||||
|
||||
func makeStatefulSetService(p *monitoringv1.Prometheus, config Config) *v1.Service {
|
||||
p = p.DeepCopy()
|
||||
|
||||
if p.Spec.PortName == "" {
|
||||
p.Spec.PortName = defaultPortName
|
||||
}
|
||||
|
||||
svc := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: governingServiceName,
|
||||
|
@ -276,9 +287,9 @@ func makeStatefulSetService(p *monitoringv1.Prometheus, config Config) *v1.Servi
|
|||
ClusterIP: "None",
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Name: "web",
|
||||
Name: p.Spec.PortName,
|
||||
Port: 9090,
|
||||
TargetPort: intstr.FromString("web"),
|
||||
TargetPort: intstr.FromString(p.Spec.PortName),
|
||||
},
|
||||
},
|
||||
Selector: map[string]string{
|
||||
|
@ -444,7 +455,7 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
|
|||
} else {
|
||||
ports = []v1.ContainerPort{
|
||||
{
|
||||
Name: "web",
|
||||
Name: p.Spec.PortName,
|
||||
ContainerPort: 9090,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
|
@ -579,13 +590,13 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
|
|||
livenessProbeHandler = v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: path.Clean(webRoutePrefix + "/-/healthy"),
|
||||
Port: intstr.FromString("web"),
|
||||
Port: intstr.FromString(p.Spec.PortName),
|
||||
},
|
||||
}
|
||||
readinessProbeHandler = v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: path.Clean(webRoutePrefix + "/-/ready"),
|
||||
Port: intstr.FromString("web"),
|
||||
Port: intstr.FromString(p.Spec.PortName),
|
||||
},
|
||||
}
|
||||
livenessFailureThreshold = 6
|
||||
|
@ -593,7 +604,7 @@ func makeStatefulSetSpec(p monitoringv1.Prometheus, c *Config, ruleConfigMapName
|
|||
livenessProbeHandler = v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: path.Clean(webRoutePrefix + "/status"),
|
||||
Port: intstr.FromString("web"),
|
||||
Port: intstr.FromString(p.Spec.PortName),
|
||||
},
|
||||
}
|
||||
readinessProbeHandler = livenessProbeHandler
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue