apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    include.release.openshift.io/single-node-production-edge: "true"
    release.openshift.io/create-only: "true"
  labels:
    config.openshift.io/inject-trusted-cabundle: "true"
  name: trusted-ca
  namespace: openshift-cluster-node-tuning-operator
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    include.release.openshift.io/single-node-production-edge: "true"
    service.beta.openshift.io/serving-cert-secret-name: node-tuning-operator-tls
  labels:
    name: node-tuning-operator
  name: node-tuning-operator
  namespace: openshift-cluster-node-tuning-operator
spec:
  clusterIP: None
  ports:
  - port: 60000
    protocol: TCP
    targetPort: 60000
  selector:
    name: cluster-node-tuning-operator
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    include.release.openshift.io/single-node-production-edge: "true"
  name: prometheus-k8s
  namespace: openshift-cluster-node-tuning-operator
rules:
- apiGroups:
  - ""
  resources:
  - services
  - endpoints
  - pods
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    include.release.openshift.io/single-node-production-edge: "true"
  name: prometheus-k8s
  namespace: openshift-cluster-node-tuning-operator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: prometheus-k8s
subjects:
- kind: ServiceAccount
  name: prometheus-k8s
  namespace: openshift-monitoring
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    include.release.openshift.io/single-node-production-edge: "true"
  name: node-tuning-operator
  namespace: openshift-cluster-node-tuning-operator
spec:
  endpoints:
  - targetPort: 60000
    interval: 60s
    scheme: https
    path: /metrics
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: node-tuning-operator.openshift-cluster-node-tuning-operator.svc
  selector:
    name: node-tuning-operator
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  annotations:
    include.release.openshift.io/ibm-cloud-managed: "true"
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    include.release.openshift.io/single-node-production-edge: "true"
  labels:
    role: alert-rules
  name: node-tuning-operator
  namespace: openshift-cluster-node-tuning-operator
spec:
  groups:
  - name: node-tuning-operator.rules
    rules:
    - alert: NTOPodsNotReady
      annotations:
        message: Pod {{ $labels.pod }} on node {{ $labels.node }} is not ready.
      expr: |
        kube_pod_status_ready{namespace='openshift-cluster-node-tuning-operator', condition='true'} == 0
      for: 30m
      labels:
        severity: warning
    - alert: NTODegraded
      annotations:
        message: |
          The Node Tuning Operator is degraded. Review the "node-tuning" ClusterOperator object for further details.
      expr: nto_degraded_info == 1
      for: 2h
      labels:
        severity: warning
