diff --git a/api/v1/softwarefactory_types.go b/api/v1/softwarefactory_types.go index 4e13092..5d94332 100644 --- a/api/v1/softwarefactory_types.go +++ b/api/v1/softwarefactory_types.go @@ -594,6 +594,10 @@ type SoftwareFactorySpec struct { // Whether you need to add extra labels on all managed resources ExtraLabels map[string]string `json:"extraLabels,omitempty"` + // Set to true to disable deployment of PodMonitors and related Prometheus resource + // +kubebuilder:default:=false + PrometheusMonitorsDisabled bool `json:"prometheusMonitorsDisabled,omitempty"` + // Config repository spec ConfigRepositoryLocation ConfigRepositoryLocationSpec `json:"config-location,omitempty"` diff --git a/config/crd/bases/sf.softwarefactory-project.io_softwarefactories.yaml b/config/crd/bases/sf.softwarefactory-project.io_softwarefactories.yaml index 56cfb92..c6fbe25 100644 --- a/config/crd/bases/sf.softwarefactory-project.io_softwarefactories.yaml +++ b/config/crd/bases/sf.softwarefactory-project.io_softwarefactories.yaml @@ -363,6 +363,11 @@ spec: in the form "host:port" type: string type: object + prometheusMonitorsDisabled: + default: false + description: Set to true to disable deployment of PodMonitors and + related Prometheus resource + type: boolean storageDefault: description: Default setting to use by Persistent Volume Claims properties: diff --git a/controllers/logserver.go b/controllers/logserver.go index 485abfc..e74659f 100644 --- a/controllers/logserver.go +++ b/controllers/logserver.go @@ -290,8 +290,10 @@ func (r *SFController) DeployLogserver() bool { // TODO(mhu) We may want to open an ingress to port 9100 for an external prometheus instance. // TODO(mhu) we may want to include monitoring objects' status in readiness computation - r.ensureLogserverPodMonitor() - r.ensureLogserverPromRule() + if !r.cr.Spec.PrometheusMonitorsDisabled { + r.ensureLogserverPodMonitor() + r.ensureLogserverPromRule() + } isReady := r.IsStatefulSetReady(current) && !stsUpdated && pvcReadiness conds.UpdateConditions(&r.cr.Status.Conditions, logserverIdent, isReady) diff --git a/controllers/nodepool.go b/controllers/nodepool.go index 883d278..add4809 100644 --- a/controllers/nodepool.go +++ b/controllers/nodepool.go @@ -829,7 +829,9 @@ func (r *SFController) DeployNodepool() map[string]bool { statsdVolume := base.MkVolumeCM("statsd-config", "np-statsd-config-map") // Ensure monitoring - TODO add to condition - r.ensureNodepoolPromRule(cloudsYaml) + if !r.cr.Spec.PrometheusMonitorsDisabled { + r.ensureNodepoolPromRule(cloudsYaml) + } deployments[LauncherIdent] = r.DeployNodepoolLauncher( statsdVolume, nodepoolStatsdMappingConfig, volumeMounts, nodepoolProvidersSecrets, providerSecretsResourceExists) diff --git a/controllers/softwarefactory_controller.go b/controllers/softwarefactory_controller.go index 5cfdade..a85e338 100644 --- a/controllers/softwarefactory_controller.go +++ b/controllers/softwarefactory_controller.go @@ -281,8 +281,10 @@ func (r *SFController) deploySFStep(services map[string]bool) map[string]bool { }, } // TODO? we could add this to the readiness computation. - r.EnsureSFPodMonitor(monitoredPorts, podMonitorSelector) - r.EnsureDiskUsagePromRule(DURuleGroups) + if !r.cr.Spec.PrometheusMonitorsDisabled { + r.EnsureSFPodMonitor(monitoredPorts, podMonitorSelector) + r.EnsureDiskUsagePromRule(DURuleGroups) + } return services } diff --git a/controllers/zuul.go b/controllers/zuul.go index 950aa5b..3ef3b36 100644 --- a/controllers/zuul.go +++ b/controllers/zuul.go @@ -774,7 +774,9 @@ func (r *SFController) EnsureZuulComponents() bool { return false } - r.ensureZuulPromRule() + if !r.cr.Spec.PrometheusMonitorsDisabled { + r.ensureZuulPromRule() + } // Install Services resources r.EnsureZuulComponentsFrontServices() diff --git a/doc/reference/CHANGELOG.md b/doc/reference/CHANGELOG.md index a75ddcc..3fb54a2 100644 --- a/doc/reference/CHANGELOG.md +++ b/doc/reference/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file. - crd: add capability to set extra labels on all managed resources - crd: add capability to set extra annotations on PVC +- crd: capability disable Prometheus related resources like `PodMonitor` to enable `SoftwareFactory` deployment without + Prometheus Operator installed on the cluster. ### Changed diff --git a/doc/reference/api/index.md b/doc/reference/api/index.md index 24ac628..0b1bb54 100644 --- a/doc/reference/api/index.md +++ b/doc/reference/api/index.md @@ -420,6 +420,7 @@ _Appears in:_ | `FluentBitLogForwarding` _[FluentBitForwarderSpec](#fluentbitforwarderspec)_ | Enable log forwarding to a [Fluent Bit HTTP input](https://docs.fluentbit.io/manual/pipeline/inputs/http) | -| | `storageDefault` _[StorageDefaultSpec](#storagedefaultspec)_ | Default setting to use by Persistent Volume Claims | -| | `extraLabels` _object (keys:string, values:string)_ | Whether you need to add extra labels on all managed resources | -| +| `prometheusMonitorsDisabled` _boolean_ | Set to true to disable deployment of PodMonitors and related Prometheus resource | {false}| | `config-location` _[ConfigRepositoryLocationSpec](#configrepositorylocationspec)_ | Config repository spec | -| | `zuul` _[ZuulSpec](#zuulspec)_ | Zuul service spec | -| | `nodepool` _[NodepoolSpec](#nodepoolspec)_ | Nodepool services spec | -|