Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,146 @@ tests:
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
expectedError: "Duplicate value"
- name: Should accept valid MonitoringPluginConfig with resources
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
resources:
- name: "cpu"
request: "10m"
- name: "memory"
request: "50Mi"
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
resources:
- name: "cpu"
request: "10m"
- name: "memory"
request: "50Mi"
- name: Should accept valid MonitoringPluginConfig with tolerations
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
tolerations:
- key: "node-role.kubernetes.io/infra"
operator: "Exists"
effect: "NoSchedule"
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
tolerations:
- key: "node-role.kubernetes.io/infra"
operator: "Exists"
effect: "NoSchedule"
- name: Should accept valid MonitoringPluginConfig with topologySpreadConstraints
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
- name: Should reject empty MonitoringPluginConfig object
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig: {}
expectedError: "spec.monitoringPluginConfig: Invalid value"
- name: Should reject MonitoringPluginConfig with too many resources
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
resources:
- name: "cpu"
request: "10m"
- name: "memory"
request: "50Mi"
- name: "hugepages-2Mi"
request: "100Mi"
- name: "hugepages-1Gi"
request: "2Gi"
- name: "ephemeral-storage"
request: "1Gi"
- name: "res6"
request: "1"
- name: "res7"
request: "1"
- name: "res8"
request: "1"
- name: "res9"
request: "1"
- name: "res10"
request: "1"
- name: "res11"
request: "1"
expectedError: "spec.monitoringPluginConfig.resources: Too many"
- name: Should reject MonitoringPluginConfig with duplicate resource names
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
resources:
- name: "cpu"
request: "100m"
- name: "cpu"
request: "200m"
expectedError: 'spec.monitoringPluginConfig.resources[1]: Duplicate value: map[string]interface {}{"name":"cpu"}'
- name: Should reject MonitoringPluginConfig with limit less than request
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
resources:
- name: "cpu"
request: "200m"
limit: "100m"
expectedError: "limit must be greater than or equal to request"
- name: Should reject MonitoringPluginConfig with empty resources array
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
resources: []
expectedError: 'spec.monitoringPluginConfig.resources: Invalid value: 0: spec.monitoringPluginConfig.resources in body should have at least 1 items'
- name: Should reject MonitoringPluginConfig with empty tolerations
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
tolerations: []
expectedError: 'spec.monitoringPluginConfig.tolerations: Invalid value: 0: spec.monitoringPluginConfig.tolerations in body should have at least 1 items'
- name: Should reject MonitoringPluginConfig with empty topologySpreadConstraints
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: ClusterMonitoring
spec:
monitoringPluginConfig:
topologySpreadConstraints: []
expectedError: 'spec.monitoringPluginConfig.topologySpreadConstraints: Invalid value: 0: spec.monitoringPluginConfig.topologySpreadConstraints in body should have at least 1 items'
76 changes: 76 additions & 0 deletions config/v1alpha1/types_cluster_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ type ClusterMonitoringSpec struct {
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
// +optional
OpenShiftStateMetricsConfig OpenShiftStateMetricsConfig `json:"openShiftStateMetricsConfig,omitempty,omitzero"`
// monitoringPluginConfig is an optional field that can be used to configure the monitoring plugin
// that runs as a dynamic plugin of the OpenShift web console. The monitoring plugin provides
// the monitoring UI in the OpenShift web console for visualizing metrics, alerts, and dashboards.
// When omitted, this means no opinion and the platform is left to choose a reasonable default, which is subject to change over time.
// The current default deploys the monitoring-plugin as a single-replica Deployment
// on linux nodes with 10m CPU and 50Mi memory requests, and no custom tolerations
// or topology spread constraints.
// When set, at least one field must be specified within monitoringPluginConfig.
// +optional
MonitoringPluginConfig MonitoringPluginConfig `json:"monitoringPluginConfig,omitempty,omitzero"`
}

// OpenShiftStateMetricsConfig provides configuration options for the openshift-state-metrics agent
Expand Down Expand Up @@ -201,6 +211,72 @@ type OpenShiftStateMetricsConfig struct {
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

// MonitoringPluginConfig provides configuration options for the monitoring plugin
// that runs as a dynamic plugin of the OpenShift web console.
// The monitoring plugin provides the monitoring UI in the OpenShift web console
// for visualizing metrics, alerts, and dashboards.
// At least one field must be specified; an empty monitoringPluginConfig object is not allowed.
// +kubebuilder:validation:MinProperties=1
type MonitoringPluginConfig struct {
// nodeSelector defines the nodes on which the Pods are scheduled.
// nodeSelector is optional.
//
// When omitted, this means the user has no opinion and the platform is left
// to choose reasonable defaults. These defaults are subject to change over time.
// The current default value is `kubernetes.io/os: linux`.
// When specified, nodeSelector must contain at least 1 entry and must not contain more than 10 entries.
// +optional
// +kubebuilder:validation:MinProperties=1
// +kubebuilder:validation:MaxProperties=10
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// resources defines the compute resource requests and limits for the monitoring-plugin container.
// This includes CPU, memory and HugePages constraints to help control scheduling and resource usage.
// When not specified, defaults are used by the platform. Requests cannot exceed limits.
// This field is optional.
// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
// This is a simplified API that maps to Kubernetes ResourceRequirements.
// The current default values are:
// resources:
// - name: cpu
// request: 10m
// - name: memory
// request: 50Mi
//
// ---
// maxItems is set to 10 based on the typical number of Kubernetes resource types
// (cpu, memory, ephemeral-storage, and up to 7 HugePages sizes).
// When specified, resources must contain at least 1 entry.
// +optional
// +listType=map
// +listMapKey=name
// +kubebuilder:validation:MaxItems=10
// +kubebuilder:validation:MinItems=1
Resources []ContainerResource `json:"resources,omitempty"`
// tolerations defines the tolerations required for the monitoring-plugin Pods.
// This field is optional.
//
// When omitted, the monitoring-plugin Pods will not have any tolerations, which
// means they will only be scheduled on nodes with no taints.
// When specified, tolerations must contain at least 1 entry and must not contain more than 10 entries.
// +optional
// +listType=atomic
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=10
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
// topologySpreadConstraints defines how the monitoring-plugin Pods are spread across nodes.
// This field is optional.
//
// When omitted, the monitoring-plugin Pods will use the default scheduling
// constraints.
// When specified, topologySpreadConstraints must contain at least 1 entry and
// must not contain more than 10 entries.
// +optional
// +listType=atomic
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=10
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
}

// UserDefinedMonitoring config for user-defined projects.
type UserDefinedMonitoring struct {
// mode defines the different configurations of UserDefinedMonitoring
Expand Down
Loading