---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: ovnkube-master
  annotations:
    networkoperator.openshift.io/ignore-errors: ""
  name: monitor-ovn-master-metrics
  namespace: openshift-ovn-kubernetes
spec:
  endpoints:
  - interval: 30s
    port: metrics
    bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: ovn-kubernetes-master.openshift-ovn-kubernetes.svc
  jobLabel: app
  namespaceSelector:
    matchNames:
    - openshift-ovn-kubernetes
  selector:
    matchLabels:
      app: ovnkube-master
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: ovnkube-master
  name: ovn-kubernetes-master
  namespace: openshift-ovn-kubernetes
  annotations:
    service.beta.openshift.io/serving-cert-secret-name: ovn-master-metrics-cert
spec:
  selector:
    app: ovnkube-master
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
  - name: metrics
    port: 9102
    protocol: TCP
    targetPort: 9102
  sessionAffinity: None
  type: ClusterIP
---

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: ovnkube-node
  annotations:
    networkoperator.openshift.io/ignore-errors: ""
  name: monitor-ovn-node
  namespace: openshift-ovn-kubernetes
spec:
  endpoints:
  - interval: 30s
    port: metrics
    bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
    scheme: https
    tlsConfig:
      caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
      serverName: ovn-kubernetes-node.openshift-ovn-kubernetes.svc
  jobLabel: app
  namespaceSelector:
    matchNames:
    - openshift-ovn-kubernetes
  selector:
    matchLabels:
      app: ovnkube-node
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: ovnkube-node
  name: ovn-kubernetes-node
  namespace: openshift-ovn-kubernetes
  annotations:
    service.beta.openshift.io/serving-cert-secret-name: ovn-node-metrics-cert
spec:
  selector:
    app: ovnkube-node
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
  - name: metrics
    port: 9103
    protocol: TCP
    targetPort: 9103
  sessionAffinity: None
  type: ClusterIP
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: prometheus-k8s
  namespace: openshift-ovn-kubernetes
rules:
- apiGroups:
  - ""
  resources:
  - services
  - endpoints
  - pods
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: prometheus-k8s
  namespace: openshift-ovn-kubernetes
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: prometheus-k8s
subjects:
- kind: ServiceAccount
  name: prometheus-k8s
  namespace: openshift-monitoring
