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
5 changes: 5 additions & 0 deletions jsonnet/components/cluster-monitoring-operator.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ function(params) {
resources: ['featuregates'],
verbs: ['get', 'list', 'watch'],
},
{
apiGroups: ['config.openshift.io'],
resources: ['clustermonitorings'],
verbs: ['get', 'list', 'watch'],
},
{
apiGroups: ['certificates.k8s.io'],
resources: ['certificatesigningrequests'],
Expand Down
8 changes: 8 additions & 0 deletions manifests/0000_50_cluster-monitoring-operator_02-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ rules:
- get
- list
- watch
- apiGroups:
- config.openshift.io
resources:
- clustermonitorings
verbs:
- get
- list
- watch
- apiGroups:
- certificates.k8s.io
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ status:
- group: monitoring.coreos.com
name: ''
resource: alertmanagerconfigs
- group: config.openshift.io
name: cluster
resource: clustermonitorings
13 changes: 13 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,19 @@ func (c *Client) ClusterOperatorListWatch(ctx context.Context, name string) *cac
}
}

func (c *Client) ClusterMonitoringListWatch(ctx context.Context) *cache.ListWatch {
clusterMonitoringInterface := c.oscclient.ConfigV1alpha1().ClusterMonitorings()

return &cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return clusterMonitoringInterface.List(ctx, metav1.ListOptions{})
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return clusterMonitoringInterface.Watch(ctx, options)
},
}
}

func (c *Client) HasRouteCapability(ctx context.Context) (bool, error) {
_, err := c.oscclient.ConfigV1().ClusterOperators().Get(ctx, "ingress", metav1.GetOptions{})
if apierrors.IsNotFound(err) {
Expand Down
37 changes: 30 additions & 7 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/blang/semver/v4"
configv1 "github.com/openshift/api/config/v1"
configv1alpha1 "github.com/openshift/api/config/v1alpha1"
"github.com/openshift/api/features"
configv1client "github.com/openshift/client-go/config/clientset/versioned"
configv1informers "github.com/openshift/client-go/config/informers/externalversions"
Expand Down Expand Up @@ -177,12 +178,13 @@ const (
type Operator struct {
namespace, namespaceUserWorkload string

configMapName string
userWorkloadConfigMapName string
images map[string]string
telemetryMatches []string
remoteWrite bool
CollectionProfilesEnabled bool
configMapName string
userWorkloadConfigMapName string
images map[string]string
telemetryMatches []string
remoteWrite bool
CollectionProfilesEnabled bool
ClusterMonitoringConfigEnabled bool

lastKnowInfrastructureConfig *InfrastructureConfig
lastKnowProxyConfig *ProxyConfig
Expand Down Expand Up @@ -452,10 +454,30 @@ func New(
return nil, err
}
o.CollectionProfilesEnabled = featureGates.Enabled(features.FeatureGateMetricsCollectionProfiles)
o.ClusterMonitoringConfigEnabled = featureGates.Enabled(features.FeatureGateClusterMonitoringConfig)
case <-time.After(1 * time.Minute):
return nil, fmt.Errorf("timed out waiting for FeatureGate detection")
}

// Watch the ClusterMonitoring config resource if the feature gate is enabled
if o.ClusterMonitoringConfigEnabled {
informer = cache.NewSharedIndexInformer(
o.client.ClusterMonitoringListWatch(ctx),
&configv1alpha1.ClusterMonitoring{},
resyncPeriod,
cache.Indexers{},
)
_, err = informer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: o.handleEvent,
UpdateFunc: func(_, newObj interface{}) { o.handleEvent(newObj) },
DeleteFunc: o.handleEvent,
})
if err != nil {
return nil, err
}
o.informers = append(o.informers, informer)
}

// csrController runs a controller that requests a client TLS certificate
// for Prometheus k8s. This certificate is used to authenticate against the
// /metrics endpoint of the targets.
Expand Down Expand Up @@ -630,7 +652,8 @@ func (o *Operator) handleEvent(obj interface{}) {
*configv1.APIServer,
*configv1.Console,
*configv1.ClusterOperator,
*configv1.ClusterVersion:
*configv1.ClusterVersion,
*configv1alpha1.ClusterMonitoring:
// Log GroupKind and Name of the obj
rtObj := obj.(k8sruntime.Object)
gk := rtObj.GetObjectKind().GroupVersionKind().GroupKind()
Expand Down