ceph: ability to set external services ports
When the cluster is external we want to expose manager service port along with the endpoints. This allows us to connect but Rook will keep on using 9283 as a facing port for Prometheus and more. ``` monitoring: enabled: true ... ... externalMgrPrometheusPort: 9283 ``` Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
1 parent
c10bf1c044
commit
8aaff235bb
10 files changed
+50
-21
No files matched your search
@@ -187,6 +187,8 @@ If this value is empty, each pod will get an ephemeral directory to store their
|
||||
* `ssl`: Whether to serve the dashboard via SSL, ignored on Ceph versions older than `13.2.2`
|
||||
* `monitoring`: Settings for monitoring Ceph using Prometheus. To enable monitoring on your cluster see the [monitoring guide](ceph-monitoring.md#prometheus-alerts).
|
||||
* `enabled`: Whether to enable prometheus based monitoring for this cluster
|
||||
* `externalMgrEndpoints`: external cluster manager endpoints
|
||||
* `externalMgrPrometheusPort`: external prometheus manager module port. See [external cluster configuration](#external-cluster) for more details.
|
||||
* `rulesNamespace`: Namespace to deploy prometheusRule. If empty, namespace of the cluster will be used.
|
||||
Recommended:
|
||||
* If you have a single Rook Ceph cluster, set the `rulesNamespace` to the same namespace as the cluster or keep it empty.
|
||||
@@ -1238,6 +1240,7 @@ spec:
|
||||
#rulesNamespace: rook-ceph
|
||||
#externalMgrEndpoints:
|
||||
#- ip: 192.168.39.182
|
||||
#externalMgrPrometheusPort: 9283
|
||||
```
|
||||
|
||||
Choose the namespace carefully, if you have an existing cluster managed by Rook, you have likely already injected `common.yaml`.
|
||||
|
||||
@@ -282,6 +282,10 @@ spec:
|
||||
properties:
|
||||
ip:
|
||||
type: string
|
||||
externalMgrPrometheusPort:
|
||||
type: integer
|
||||
minimum: 0
|
||||
maximum: 65535
|
||||
removeOSDsIfOutAndSafeToRemove:
|
||||
type: boolean
|
||||
external:
|
||||
|
||||
@@ -30,3 +30,4 @@ spec:
|
||||
# rulesNamespace: rook-ceph
|
||||
# externalMgrEndpoints:
|
||||
#- ip: ip
|
||||
# externalMgrPrometheusPort: 9283
|
||||
@@ -284,6 +284,10 @@ spec:
|
||||
properties:
|
||||
ip:
|
||||
type: string
|
||||
externalMgrPrometheusPort:
|
||||
type: integer
|
||||
minimum: 0
|
||||
maximum: 65535
|
||||
removeOSDsIfOutAndSafeToRemove:
|
||||
type: boolean
|
||||
external:
|
||||
|
||||
@@ -206,6 +206,9 @@ type MonitoringSpec struct {
|
||||
|
||||
// ExternalMgrEndpoints points to an existing Ceph prometheus exporter endpoint
|
||||
ExternalMgrEndpoints []v1.EndpointAddress `json:"externalMgrEndpoints,omitempty"`
|
||||
|
||||
// ExternalMgrPrometheusPort Prometheus exporter port
|
||||
ExternalMgrPrometheusPort uint16 `json:"externalMgrPrometheusPort,omitempty"`
|
||||
}
|
||||
|
||||
type ClusterStatus struct {
|
||||
|
||||
@@ -183,11 +183,17 @@ func validateExternalClusterSpec(cluster *cluster) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Validate external services port
|
||||
if cluster.Spec.Monitoring.Enabled {
|
||||
if cluster.Spec.Monitoring.ExternalMgrPrometheusPort == 0 {
|
||||
cluster.Spec.Monitoring.ExternalMgrPrometheusPort = mgr.DefaultMetricsPort
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ClusterController) configureExternalClusterMonitoring(cluster *cluster) error {
|
||||
ctx := context.TODO()
|
||||
// Initialize manager object
|
||||
manager := mgr.New(
|
||||
c.context,
|
||||
@@ -199,18 +205,14 @@ func (c *ClusterController) configureExternalClusterMonitoring(cluster *cluster)
|
||||
// Create external monitoring Service
|
||||
service := manager.MakeMetricsService(mgr.ExternalMgrAppName, mgr.ServiceExternalMetricName)
|
||||
logger.Info("creating mgr external monitoring service")
|
||||
_, err := c.context.Clientset.CoreV1().Services(c.namespacedName.Namespace).Create(ctx, service, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
if !kerrors.IsAlreadyExists(err) {
|
||||
return errors.Wrap(err, "failed to create mgr service")
|
||||
}
|
||||
logger.Debug("mgr external metrics service already exists")
|
||||
} else {
|
||||
logger.Info("mgr external metrics service created")
|
||||
_, err := k8sutil.CreateOrUpdateService(c.context.Clientset, cluster.Namespace, service)
|
||||
if err != nil && !kerrors.IsAlreadyExists(err) {
|
||||
return errors.Wrap(err, "failed to create or update mgr service")
|
||||
}
|
||||
logger.Info("mgr external metrics service created")
|
||||
|
||||
// Create external monitoring Endpoints
|
||||
endpoint := mgr.CreateExternalMetricsEndpoints(cluster.Namespace, cluster.Spec.Monitoring.ExternalMgrEndpoints, cluster.ownerRef)
|
||||
endpoint := mgr.CreateExternalMetricsEndpoints(cluster.Namespace, cluster.Spec.Monitoring, cluster.ownerRef)
|
||||
logger.Info("creating mgr external monitoring endpoints")
|
||||
_, err = k8sutil.CreateOrUpdateEndpoint(c.context.Clientset, c.namespacedName.Namespace, endpoint)
|
||||
if err != nil {
|
||||
|
||||
@@ -36,4 +36,11 @@ func TestValidateExternalClusterSpec(t *testing.T) {
|
||||
c.Spec.DataDirHostPath = "path"
|
||||
err = validateExternalClusterSpec(c)
|
||||
assert.NoError(t, err, err)
|
||||
assert.Equal(t, uint16(0), c.Spec.Monitoring.ExternalMgrPrometheusPort)
|
||||
|
||||
c.Spec.Monitoring.Enabled = true
|
||||
err = validateExternalClusterSpec(c)
|
||||
assert.NoError(t, err, err)
|
||||
assert.Equal(t, uint16(9283), c.Spec.Monitoring.ExternalMgrPrometheusPort)
|
||||
|
||||
}
|
||||
@@ -53,16 +53,17 @@ const (
|
||||
// AppName is the ceph mgr application name
|
||||
AppName = "rook-ceph-mgr"
|
||||
serviceAccountName = "rook-ceph-mgr"
|
||||
prometheusModuleName = "prometheus"
|
||||
PrometheusModuleName = "prometheus"
|
||||
crashModuleName = "crash"
|
||||
PgautoscalerModuleName = "pg_autoscaler"
|
||||
balancerModuleName = "balancer"
|
||||
balancerModuleMode = "upmap"
|
||||
metricsPort = 9283
|
||||
monitoringPath = "/etc/ceph-monitoring/"
|
||||
serviceMonitorFile = "service-monitor.yaml"
|
||||
// minimum amount of memory in MB to run the pod
|
||||
cephMgrPodMinimumMemory uint64 = 512
|
||||
// DefaultMetricsPort prometheus exporter port
|
||||
DefaultMetricsPort uint16 = 9283
|
||||
)
|
||||
|
||||
// Cluster represents the Rook and environment configuration settings needed to set up Ceph mgrs.
|
||||
@@ -231,7 +232,7 @@ func startModuleConfiguration(description string, configureModules func() error)
|
||||
|
||||
// Ceph docs about the prometheus module: http://docs.ceph.com/docs/master/mgr/prometheus/
|
||||
func (c *Cluster) enablePrometheusModule() error {
|
||||
if err := client.MgrEnableModule(c.context, c.clusterInfo, prometheusModuleName, true); err != nil {
|
||||
if err := client.MgrEnableModule(c.context, c.clusterInfo, PrometheusModuleName, true); err != nil {
|
||||
return errors.Wrap(err, "failed to enable mgr prometheus module")
|
||||
}
|
||||
return nil
|
||||
@@ -331,7 +332,7 @@ func (c *Cluster) moduleMeetsMinVersion(name string) (*cephver.CephVersion, bool
|
||||
}
|
||||
|
||||
func wellKnownModule(name string) bool {
|
||||
knownModules := []string{dashboardModuleName, prometheusModuleName, crashModuleName}
|
||||
knownModules := []string{dashboardModuleName, PrometheusModuleName, crashModuleName}
|
||||
for _, known := range knownModules {
|
||||
if name == known {
|
||||
return true
|
||||
|
||||
@@ -238,7 +238,7 @@ func (c *Cluster) makeMgrDaemonContainer(mgrConfig *mgrConfig) v1.Container {
|
||||
},
|
||||
{
|
||||
Name: "http-metrics",
|
||||
ContainerPort: int32(metricsPort),
|
||||
ContainerPort: int32(DefaultMetricsPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
{
|
||||
@@ -275,7 +275,7 @@ func getDefaultMgrLivenessProbe() *v1.Probe {
|
||||
Handler: v1.Handler{
|
||||
HTTPGet: &v1.HTTPGetAction{
|
||||
Path: "/",
|
||||
Port: intstr.FromInt(metricsPort),
|
||||
Port: intstr.FromInt(int(DefaultMetricsPort)),
|
||||
},
|
||||
},
|
||||
InitialDelaySeconds: 60,
|
||||
@@ -296,7 +296,7 @@ func (c *Cluster) MakeMetricsService(name, servicePortMetricName string) *v1.Ser
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Name: servicePortMetricName,
|
||||
Port: int32(metricsPort),
|
||||
Port: int32(DefaultMetricsPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
@@ -351,7 +351,7 @@ func (c *Cluster) applyPrometheusAnnotations(objectMeta *metav1.ObjectMeta) {
|
||||
if len(cephv1.GetMgrAnnotations(c.spec.Annotations)) == 0 {
|
||||
t := rookv1.Annotations{
|
||||
"prometheus.io/scrape": "true",
|
||||
"prometheus.io/port": strconv.Itoa(metricsPort),
|
||||
"prometheus.io/port": strconv.Itoa(int(DefaultMetricsPort)),
|
||||
}
|
||||
|
||||
t.ApplyToObjectMeta(objectMeta)
|
||||
@@ -370,7 +370,7 @@ func (c *Cluster) cephMgrOrchestratorModuleEnvs() []v1.EnvVar {
|
||||
}
|
||||
|
||||
// CreateExternalMetricsEndpoints creates external metric endpoint
|
||||
func CreateExternalMetricsEndpoints(namespace string, externalMgrEndpoints []v1.EndpointAddress, ownerRef metav1.OwnerReference) *v1.Endpoints {
|
||||
func CreateExternalMetricsEndpoints(namespace string, monitoringSpec cephv1.MonitoringSpec, ownerRef metav1.OwnerReference) *v1.Endpoints {
|
||||
labels := controller.AppLabels(AppName, namespace)
|
||||
|
||||
endpoints := &v1.Endpoints{
|
||||
@@ -381,11 +381,11 @@ func CreateExternalMetricsEndpoints(namespace string, externalMgrEndpoints []v1.
|
||||
},
|
||||
Subsets: []v1.EndpointSubset{
|
||||
{
|
||||
Addresses: externalMgrEndpoints,
|
||||
Addresses: monitoringSpec.ExternalMgrEndpoints,
|
||||
Ports: []v1.EndpointPort{
|
||||
{
|
||||
Name: ServiceExternalMetricName,
|
||||
Port: int32(metricsPort),
|
||||
Port: int32(monitoringSpec.ExternalMgrPrometheusPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -377,6 +377,10 @@ spec:
|
||||
properties:
|
||||
ip:
|
||||
type: string
|
||||
externalMgrPrometheusPort:
|
||||
type: integer
|
||||
minimum: 0
|
||||
maximum: 65535
|
||||
removeOSDsIfOutAndSafeToRemove:
|
||||
type: boolean
|
||||
external:
|
||||
|
||||
Reference in new issue
Block a user