Skip to content

Commit 4a67cf2

Browse files
committed
MON-4036: Add NodeExporterConfig to ClusterMonitoring API
Add NodeExporterConfig to ClusterMonitoringSpec with support for nodeSelector, resources, tolerations, collectors (10 individual toggles with per-collector options), maxProcs, and ignoredNetworkDevices. Signed-off-by: Daniel Mellado <[email protected]>
1 parent 5c75e62 commit 4a67cf2

File tree

9 files changed

+2197
-53135
lines changed

9 files changed

+2197
-53135
lines changed

config/v1alpha1/tests/clustermonitorings.config.openshift.io/ClusterMonitoringConfig.yaml

Lines changed: 120 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,12 @@ tests:
577577
prometheusOperatorAdmissionWebhookConfig:
578578
resources: []
579579
expectedError: 'spec.prometheusOperatorAdmissionWebhookConfig.resources: Invalid value: 0: spec.prometheusOperatorAdmissionWebhookConfig.resources in body should have at least 1 items'
580-
- name: Should be able to create OpenShiftStateMetricsConfig with valid resources
580+
- name: Should be able to create NodeExporterConfig with valid resources
581581
initial: |
582582
apiVersion: config.openshift.io/v1alpha1
583583
kind: ClusterMonitoring
584584
spec:
585-
openShiftStateMetricsConfig:
585+
nodeExporterConfig:
586586
resources:
587587
- name: "cpu"
588588
request: "50m"
@@ -594,109 +594,128 @@ tests:
594594
apiVersion: config.openshift.io/v1alpha1
595595
kind: ClusterMonitoring
596596
spec:
597-
openShiftStateMetricsConfig:
597+
nodeExporterConfig:
598598
resources:
599599
- name: "cpu"
600600
request: "50m"
601601
limit: "200m"
602602
- name: "memory"
603603
request: "50Mi"
604604
limit: "200Mi"
605-
- name: Should be able to create OpenShiftStateMetricsConfig with valid topologySpreadConstraints
605+
- name: Should be able to create NodeExporterConfig with valid tolerations
606606
initial: |
607607
apiVersion: config.openshift.io/v1alpha1
608608
kind: ClusterMonitoring
609609
spec:
610-
openShiftStateMetricsConfig:
611-
topologySpreadConstraints:
612-
- maxSkew: 1
613-
topologyKey: topology.kubernetes.io/zone
614-
whenUnsatisfiable: DoNotSchedule
615-
labelSelector:
616-
matchLabels:
617-
app: openshift-state-metrics
618-
- maxSkew: 2
619-
topologyKey: kubernetes.io/hostname
620-
whenUnsatisfiable: ScheduleAnyway
621-
labelSelector:
622-
matchLabels:
623-
app: openshift-state-metrics
610+
nodeExporterConfig:
611+
tolerations:
612+
- operator: "Exists"
624613
expected: |
625614
apiVersion: config.openshift.io/v1alpha1
626615
kind: ClusterMonitoring
627616
spec:
628-
openShiftStateMetricsConfig:
629-
topologySpreadConstraints:
630-
- maxSkew: 1
631-
topologyKey: topology.kubernetes.io/zone
632-
whenUnsatisfiable: DoNotSchedule
633-
labelSelector:
634-
matchLabels:
635-
app: openshift-state-metrics
636-
- maxSkew: 2
637-
topologyKey: kubernetes.io/hostname
638-
whenUnsatisfiable: ScheduleAnyway
639-
labelSelector:
640-
matchLabels:
641-
app: openshift-state-metrics
642-
- name: Should be able to create OpenShiftStateMetricsConfig with all fields
617+
nodeExporterConfig:
618+
tolerations:
619+
- operator: "Exists"
620+
- name: Should be able to create NodeExporterConfig with collectors
621+
initial: |
622+
apiVersion: config.openshift.io/v1alpha1
623+
kind: ClusterMonitoring
624+
spec:
625+
nodeExporterConfig:
626+
collectors:
627+
cpuFreq:
628+
enabled: Enabled
629+
tcpStat:
630+
enabled: Disabled
631+
netDev:
632+
enabled: Enabled
633+
netClass:
634+
enabled: Enabled
635+
useNetlink: Enabled
636+
systemd:
637+
enabled: Enabled
638+
units:
639+
- "kubelet.service"
640+
- "crio.service"
641+
expected: |
642+
apiVersion: config.openshift.io/v1alpha1
643+
kind: ClusterMonitoring
644+
spec:
645+
nodeExporterConfig:
646+
collectors:
647+
cpuFreq:
648+
enabled: Enabled
649+
tcpStat:
650+
enabled: Disabled
651+
netDev:
652+
enabled: Enabled
653+
netClass:
654+
enabled: Enabled
655+
useNetlink: Enabled
656+
systemd:
657+
enabled: Enabled
658+
units:
659+
- "kubelet.service"
660+
- "crio.service"
661+
- name: Should be able to create NodeExporterConfig with all fields
643662
initial: |
644663
apiVersion: config.openshift.io/v1alpha1
645664
kind: ClusterMonitoring
646665
spec:
647-
openShiftStateMetricsConfig:
666+
nodeExporterConfig:
648667
nodeSelector:
649668
kubernetes.io/os: linux
650669
resources:
651670
- name: "cpu"
652671
request: "50m"
653672
limit: "200m"
654673
tolerations:
655-
- key: "node-role.kubernetes.io/infra"
656-
operator: "Exists"
657-
effect: "NoSchedule"
658-
topologySpreadConstraints:
659-
- maxSkew: 1
660-
topologyKey: topology.kubernetes.io/zone
661-
whenUnsatisfiable: DoNotSchedule
662-
labelSelector:
663-
matchLabels:
664-
app: openshift-state-metrics
674+
- operator: "Exists"
675+
collectors:
676+
cpuFreq:
677+
enabled: Enabled
678+
buddyInfo:
679+
enabled: Disabled
680+
maxProcs: 4
681+
ignoredNetworkDevices:
682+
- "^veth.*$"
683+
- "^docker.*$"
665684
expected: |
666685
apiVersion: config.openshift.io/v1alpha1
667686
kind: ClusterMonitoring
668687
spec:
669-
openShiftStateMetricsConfig:
688+
nodeExporterConfig:
670689
nodeSelector:
671690
kubernetes.io/os: linux
672691
resources:
673692
- name: "cpu"
674693
request: "50m"
675694
limit: "200m"
676695
tolerations:
677-
- key: "node-role.kubernetes.io/infra"
678-
operator: "Exists"
679-
effect: "NoSchedule"
680-
topologySpreadConstraints:
681-
- maxSkew: 1
682-
topologyKey: topology.kubernetes.io/zone
683-
whenUnsatisfiable: DoNotSchedule
684-
labelSelector:
685-
matchLabels:
686-
app: openshift-state-metrics
687-
- name: Should reject OpenShiftStateMetricsConfig with empty object
696+
- operator: "Exists"
697+
collectors:
698+
cpuFreq:
699+
enabled: Enabled
700+
buddyInfo:
701+
enabled: Disabled
702+
maxProcs: 4
703+
ignoredNetworkDevices:
704+
- "^veth.*$"
705+
- "^docker.*$"
706+
- name: Should reject NodeExporterConfig with empty object
688707
initial: |
689708
apiVersion: config.openshift.io/v1alpha1
690709
kind: ClusterMonitoring
691710
spec:
692-
openShiftStateMetricsConfig: {}
693-
expectedError: 'spec.openShiftStateMetricsConfig: Invalid value: 0: spec.openShiftStateMetricsConfig in body should have at least 1 properties'
694-
- name: Should reject OpenShiftStateMetricsConfig with too many resources
711+
nodeExporterConfig: {}
712+
expectedError: 'spec.nodeExporterConfig: Invalid value: 0: spec.nodeExporterConfig in body should have at least 1 properties'
713+
- name: Should reject NodeExporterConfig with too many resources
695714
initial: |
696715
apiVersion: config.openshift.io/v1alpha1
697716
kind: ClusterMonitoring
698717
spec:
699-
openShiftStateMetricsConfig:
718+
nodeExporterConfig:
700719
resources:
701720
- name: "cpu"
702721
request: "100m"
@@ -720,98 +739,72 @@ tests:
720739
request: "1"
721740
- name: "example.com/quux"
722741
request: "1"
723-
expectedError: 'spec.openShiftStateMetricsConfig.resources: Too many: 11: must have at most 10 items'
724-
- name: Should reject OpenShiftStateMetricsConfig with limit less than request
742+
expectedError: 'spec.nodeExporterConfig.resources: Too many: 11: must have at most 10 items'
743+
- name: Should reject NodeExporterConfig with duplicate resource names
725744
initial: |
726745
apiVersion: config.openshift.io/v1alpha1
727746
kind: ClusterMonitoring
728747
spec:
729-
openShiftStateMetricsConfig:
748+
nodeExporterConfig:
749+
resources:
750+
- name: "cpu"
751+
request: "100m"
752+
- name: "cpu"
753+
request: "200m"
754+
expectedError: 'spec.nodeExporterConfig.resources[1]: Duplicate value: map[string]interface {}{"name":"cpu"}'
755+
- name: Should reject NodeExporterConfig with limit less than request
756+
initial: |
757+
apiVersion: config.openshift.io/v1alpha1
758+
kind: ClusterMonitoring
759+
spec:
760+
nodeExporterConfig:
730761
resources:
731762
- name: "cpu"
732763
request: "500m"
733764
limit: "200m"
734-
expectedError: 'spec.openShiftStateMetricsConfig.resources[0]: Invalid value: "object": limit must be greater than or equal to request'
735-
- name: Should reject OpenShiftStateMetricsConfig with too many topologySpreadConstraints
765+
expectedError: 'spec.nodeExporterConfig.resources[0]: Invalid value: "object": limit must be greater than or equal to request'
766+
- name: Should reject NodeExporterConfig with empty resources array
736767
initial: |
737768
apiVersion: config.openshift.io/v1alpha1
738769
kind: ClusterMonitoring
739770
spec:
740-
openShiftStateMetricsConfig:
741-
topologySpreadConstraints:
742-
- maxSkew: 1
743-
topologyKey: "zone1"
744-
whenUnsatisfiable: DoNotSchedule
745-
- maxSkew: 1
746-
topologyKey: "zone2"
747-
whenUnsatisfiable: DoNotSchedule
748-
- maxSkew: 1
749-
topologyKey: "zone3"
750-
whenUnsatisfiable: DoNotSchedule
751-
- maxSkew: 1
752-
topologyKey: "zone4"
753-
whenUnsatisfiable: DoNotSchedule
754-
- maxSkew: 1
755-
topologyKey: "zone5"
756-
whenUnsatisfiable: DoNotSchedule
757-
- maxSkew: 1
758-
topologyKey: "zone6"
759-
whenUnsatisfiable: DoNotSchedule
760-
- maxSkew: 1
761-
topologyKey: "zone7"
762-
whenUnsatisfiable: DoNotSchedule
763-
- maxSkew: 1
764-
topologyKey: "zone8"
765-
whenUnsatisfiable: DoNotSchedule
766-
- maxSkew: 1
767-
topologyKey: "zone9"
768-
whenUnsatisfiable: DoNotSchedule
769-
- maxSkew: 1
770-
topologyKey: "zone10"
771-
whenUnsatisfiable: DoNotSchedule
772-
- maxSkew: 1
773-
topologyKey: "zone11"
774-
whenUnsatisfiable: DoNotSchedule
775-
expectedError: 'spec.openShiftStateMetricsConfig.topologySpreadConstraints: Too many: 11: must have at most 10 items'
776-
- name: Should reject OpenShiftStateMetricsConfig with empty resources array
771+
nodeExporterConfig:
772+
resources: []
773+
expectedError: 'spec.nodeExporterConfig.resources: Invalid value: 0: spec.nodeExporterConfig.resources in body should have at least 1 items'
774+
- name: Should reject NodeExporterConfig with empty collectors object
777775
initial: |
778776
apiVersion: config.openshift.io/v1alpha1
779777
kind: ClusterMonitoring
780778
spec:
781-
openShiftStateMetricsConfig:
782-
resources: []
783-
expectedError: 'spec.openShiftStateMetricsConfig.resources: Invalid value: 0: spec.openShiftStateMetricsConfig.resources in body should have at least 1 items'
784-
- name: Should reject OpenShiftStateMetricsConfig with empty topologySpreadConstraints array
779+
nodeExporterConfig:
780+
collectors: {}
781+
expectedError: 'spec.nodeExporterConfig.collectors: Invalid value: 0: spec.nodeExporterConfig.collectors in body should have at least 1 properties'
782+
- name: Should accept NodeExporterConfig with empty ignoredNetworkDevices list
785783
initial: |
786784
apiVersion: config.openshift.io/v1alpha1
787785
kind: ClusterMonitoring
788786
spec:
789-
openShiftStateMetricsConfig:
790-
topologySpreadConstraints: []
791-
expectedError: 'spec.openShiftStateMetricsConfig.topologySpreadConstraints: Invalid value: 0: spec.openShiftStateMetricsConfig.topologySpreadConstraints in body should have at least 1 items'
792-
- name: Should reject OpenShiftStateMetricsConfig with duplicate resource names
787+
nodeExporterConfig:
788+
ignoredNetworkDevices: []
789+
expected: |
790+
apiVersion: config.openshift.io/v1alpha1
791+
kind: ClusterMonitoring
792+
spec:
793+
nodeExporterConfig:
794+
ignoredNetworkDevices: []
795+
- name: Should reject NodeExporterConfig with maxProcs below minimum
793796
initial: |
794797
apiVersion: config.openshift.io/v1alpha1
795798
kind: ClusterMonitoring
796799
spec:
797-
openShiftStateMetricsConfig:
798-
resources:
799-
- name: "cpu"
800-
request: "100m"
801-
- name: "cpu"
802-
request: "200m"
803-
expectedError: 'spec.openShiftStateMetricsConfig.resources[1]: Duplicate value: map[string]interface {}{"name":"cpu"}'
804-
- name: Should reject OpenShiftStateMetricsConfig with duplicate topologySpreadConstraints
800+
nodeExporterConfig:
801+
maxProcs: -1
802+
expectedError: 'spec.nodeExporterConfig.maxProcs'
803+
- name: Should reject NodeExporterConfig with maxProcs exceeding maximum
805804
initial: |
806805
apiVersion: config.openshift.io/v1alpha1
807806
kind: ClusterMonitoring
808807
spec:
809-
openShiftStateMetricsConfig:
810-
topologySpreadConstraints:
811-
- maxSkew: 1
812-
topologyKey: topology.kubernetes.io/zone
813-
whenUnsatisfiable: DoNotSchedule
814-
- maxSkew: 2
815-
topologyKey: topology.kubernetes.io/zone
816-
whenUnsatisfiable: DoNotSchedule
817-
expectedError: "Duplicate value"
808+
nodeExporterConfig:
809+
maxProcs: 1025
810+
expectedError: 'spec.nodeExporterConfig.maxProcs'

0 commit comments

Comments
 (0)