---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: sdn
  annotations:
    networkoperator.openshift.io/ignore-errors: ""
  name: monitor-sdn
  namespace: openshift-sdn
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: sdn.openshift-sdn.svc
  jobLabel: app
  namespaceSelector:
    matchNames:
    - openshift-sdn
  selector:
    matchLabels:
      app: sdn
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.openshift.io/serving-cert-secret-name: sdn-metrics-certs
  labels:
    app: sdn
  name: sdn
  namespace: openshift-sdn
spec:
  selector:
    app: sdn
  clusterIP: None
  publishNotReadyAddresses: true
  ports:
  - name: metrics
    port: 9101
    protocol: TCP
    targetPort: 9101
  sessionAffinity: None
  type: ClusterIP
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: prometheus-k8s
  namespace: openshift-sdn
rules:
- apiGroups:
  - ""
  resources:
  - services
  - endpoints
  - pods
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: prometheus-k8s
  namespace: openshift-sdn
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: prometheus-k8s
subjects:
- kind: ServiceAccount
  name: prometheus-k8s
  namespace: openshift-monitoring
