Skip to content

Commit

Permalink
crd: Add capability to disable usage of Prometheus resources
Browse files Browse the repository at this point in the history
Change-Id: If52e78ca8d65274d6c55f025a2643c14ccd06b2f
  • Loading branch information
morucci authored and danpawlik committed Aug 26, 2024
1 parent 9d53825 commit b77a9ec
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions api/v1/softwarefactory_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions controllers/logserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion controllers/nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions controllers/softwarefactory_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion controllers/zuul.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions doc/reference/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions doc/reference/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | -|
Expand Down

0 comments on commit b77a9ec

Please sign in to comment.