# define ServiceMontior and Service resources for ovnkube-master
# and ovnkube-node (required for prometheus monitoring)

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    k8s-app: ovnkube-master
  name: monitor-ovnkube-master
  namespace: ovn-kubernetes
spec:
  endpoints:
  - interval: 30s
    port: http-metrics
    scheme: http
    path: /metrics
  jobLabel: k8s-app
  namespaceSelector:
    matchNames:
    - ovn-kubernetes
  selector:
    matchLabels:
      k8s-app: ovnkube-master
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: ovnkube-master
  name: ovn-kubernetes-master-prometheus-discovery
  namespace: ovn-kubernetes
spec:
  selector:
    name: ovnkube-master
  type: ClusterIP
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
  - name: http-metrics
    port: 9409
    protocol: TCP
    targetPort: 9409
---

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    k8s-app: ovnkube-node
  name: monitor-ovnkube-node
  namespace: ovn-kubernetes
spec:
  endpoints:
  - interval: 30s
    port: http-metrics
    path: /metrics
    scheme: http
  jobLabel: k8s-app
  namespaceSelector:
    matchNames:
    - ovn-kubernetes
  selector:
    matchLabels:
      k8s-app: ovnkube-node
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: ovnkube-node
  name: ovn-kubernetes-node-prometheus-discovery
  namespace: ovn-kubernetes
spec:
  selector:
    name: ovnkube-node
  type: ClusterIP
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
  - name: http-metrics
    port: 9410
    protocol: TCP
    targetPort: 9410
