Skip to content

Commit

Permalink
Add AlertmanagerMainConfig to monitoring API
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Fernandez <[email protected]>
  • Loading branch information
marioferh committed Jan 15, 2025
1 parent c1a063b commit c35227f
Show file tree
Hide file tree
Showing 12 changed files with 5,593 additions and 6 deletions.
87 changes: 87 additions & 0 deletions config/v1/types_cluster_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1

import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -77,6 +78,9 @@ type ClusterMonitoringSpec struct {
// userDefined set the deployment mode for user-defined monitoring in addition to the default platform monitoring.
// +required
UserDefined UserDefinedMonitoring `json:"userDefined"`
// alertmanagerMainConfig defines settings for the Alertmanager component in the `openshift-monitoring` namespace.
// +required
AlertmanagerMainConfig AlertmanagerMainConfig `json:"alertmanagerMainConfig"`
}

// UserDefinedMonitoring config for user-defined projects.
Expand All @@ -101,3 +105,86 @@ const (
// UserDefinedNamespaceIsolated enables monitoring for user-defined projects with namespace-scoped tenancy. This ensures that metrics, alerts, and monitoring data are isolated at the namespace level.
UserDefinedNamespaceIsolated UserDefinedMode = "NamespaceIsolated"
)

// The `AlertmanagerMainConfig` resource defines settings for the
// Alertmanager component in the `openshift-monitoring` namespace.
type AlertmanagerMainConfig struct {
// mode enables or disables the main Alertmanager instance. in the `openshift-monitoring` namespace
// Allowed values are "Enabled", "Disabled".
// +kubebuilder:validation:Enum:=Enabled;Disabled;""
// +required
Mode AlertManagerMode `json:"mode"`
// userMode enables or disables user-defined namespaces
// to be selected for `AlertmanagerConfig` lookups. This setting only
// applies if the user workload monitoring instance of Alertmanager
// is not enabled.
// +required
UserMode UserAlertManagerMode `json:"userMode"`
// logLevel Defines the log level setting for Alertmanager.
// The possible values are: `Error`, `Warn`, `Info`, `Debug`.
// The default value is `Info`.
// +optional
// +kubebuilder:default=Info
LogLevel string `json:"logLevel,omitempty"`
// nodeSelector Defines the nodes on which the Pods are scheduled.
// +optional
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// resources Defines resource requests and limits for the Alertmanager container.
// +optional
Resources *v1.ResourceRequirements `json:"resources,omitempty"`
// secrets Defines a list of secrets that need to be mounted into the Alertmanager.
// The secrets must reside within the same namespace as the Alertmanager object.
// They will be added as volumes named secret-<secret-name> and mounted at
// /etc/alertmanager/secrets/<secret-name> within the 'alertmanager' container of
// the Alertmanager Pods.
// +optional
Secrets []string `json:"secrets,omitempty"`
// tolerations Defines tolerations for the pods.
// +optional
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
// topologySpreadConstraints Defines a pod's topology spread constraints.
// +optional
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// volumeClaimTemplate Defines persistent storage for Alertmanager. Use this setting to
// configure the persistent volume claim, including storage class, volume
// size, and name.
// +optional
VolumeClaimTemplate v1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"`
}

// AlertmanagerMode defines mode for AlertManager instance
// +kubebuilder:validation:Enum="";Enabled;Disabled
type AlertManagerMode string

const (
// AlertManagerEnable enables the main Alertmanager instance. in the `openshift-monitoring` namespace
AlertManagerEnabled AlertManagerMode = "Enabled"
// AlertManagerDisabled enables the main Alertmanager instance. in the `openshift-monitoring` namespace
AlertManagerDisabled AlertManagerMode = "Disabled"
)

// UserAlertManagerMode defines mode for user-defines namespaced
// +kubebuilder:validation:Enum="";Enabled;Disabled
type UserAlertManagerMode string

const (
// AlertManagerEnabled enables user-defined namespaces to be selected for `AlertmanagerConfig` lookups. This setting only
// applies if the user workload monitoring instance of Alertmanager is not enabled.
UserAlertManagerEnabled UserAlertManagerMode = "Enabled"
// AlertManagerDisabled disables user-defined namespaces to be selected for `AlertmanagerConfig` lookups. This setting only
// applies if the user workload monitoring instance of Alertmanager is not enabled.
UserAlertManagerDisabled UserAlertManagerMode = "Disabled"
)

// +kubebuilder:validation:Enum="";Error;Warn;Info;Debug
type LogLevel string

var (
Error LogLevel = "error"

Warn LogLevel = "warn"

Info LogLevel = "info"

Debug LogLevel = "debug"
)
Loading

0 comments on commit c35227f

Please sign in to comment.