Skip to content
Merged
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
28 changes: 28 additions & 0 deletions api/v1alpha1/operatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,27 @@ func (c *WorkspacesConfig) GetAutoPauseTimeoutMinutes() int32 {
return DefaultAutoPauseTimeoutMinutes
}

// MonitoringConfig defines configuration for Prometheus metrics collection
type MonitoringConfig struct {
// Enabled determines if a ServiceMonitor should be deployed for Prometheus scraping
// +kubebuilder:default=false
Enabled bool `json:"enabled"`

// Interval defines the Prometheus scrape interval
// Default: "30s"
// +optional
// +kubebuilder:validation:Pattern=`^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$`
Comment thread
bennyz marked this conversation as resolved.
Interval string `json:"interval,omitempty"`
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

// GetInterval returns the scrape interval, falling back to "30s"
func (c *MonitoringConfig) GetInterval() string {
if c != nil && c.Interval != "" {
return c.Interval
}
return "30s"
}

// OperatorConfigSpec defines the desired state of OperatorConfig
type OperatorConfigSpec struct {
// OSBuilds defines the configuration for OS build operations
Expand All @@ -461,6 +482,10 @@ type OperatorConfigSpec struct {
// Workspaces defines configuration for developer workspaces
// +optional
Workspaces *WorkspacesConfig `json:"workspaces,omitempty"`

// Monitoring defines configuration for Prometheus metrics collection
// +optional
Monitoring *MonitoringConfig `json:"monitoring,omitempty"`
}

// OSBuildsConfig defines configuration for OS build operations
Expand Down Expand Up @@ -642,6 +667,9 @@ type OperatorConfigStatus struct {
// UserNamespacesSupported indicates if the cluster supports user namespaces in pods
// (SCC userNamespaceLevel field). When false, workspace pods use privileged mode.
UserNamespacesSupported bool `json:"userNamespacesSupported,omitempty"`

// MonitoringEnabled indicates if the ServiceMonitor is currently deployed
MonitoringEnabled bool `json:"monitoringEnabled,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
20 changes: 20 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,24 @@ spec:
exporter configurations
type: object
type: object
monitoring:
description: Monitoring defines configuration for Prometheus metrics
collection
properties:
enabled:
default: false
description: Enabled determines if a ServiceMonitor should be
deployed for Prometheus scraping
type: boolean
interval:
description: |-
Interval defines the Prometheus scrape interval
Default: "30s"
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
required:
- enabled
type: object
osBuilds:
description: OSBuilds defines the configuration for OS build operations
properties:
Expand Down Expand Up @@ -1065,6 +1083,10 @@ spec:
message:
description: Message provides detail about the current phase
type: string
monitoringEnabled:
description: MonitoringEnabled indicates if the ServiceMonitor is
currently deployed
type: boolean
observedGeneration:
description: ObservedGeneration is the most recent generation observed
by the controller.
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ rules:
- imagestreamtags
verbs:
- delete
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- networking.k8s.io
resources:
Expand Down
7 changes: 7 additions & 0 deletions config/samples/automotive_v1_operatorconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ spec:
# value: "automotive"
# effect: "NoExecute"

# Monitoring configuration for Prometheus ServiceMonitor
# Requires user-workload-monitoring enabled on the cluster
# monitoring:
# enabled: true
# # Optional: scrape interval (default: 30s)
# # interval: "15s"

# BuildAPI configuration for the Build API server
buildAPI:
# Optional: Authentication configuration for OIDC/JWT providers
Expand Down
Loading
Loading