In our Private Managed Clusters Prometheus will automatically scan all Deployments, DaemonSets and StatefulSets for a scraping port or ServiceMonitors. If you want to use scraping, you need to add the following annotations, example:
apiVersion: apps/v1
kind: DaemonSet
metadata:
annotations:
prometheus.io/port: 7472
prometheus.io/scrape: true
...
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
k8s-app: coredns
name: coredns
namespace: monitoring
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 15s
port: http-metrics
jobLabel: k8s-app
namespaceSelector:
matchNames:
- kube-system
selector:
matchLabels:
component: metrics
k8s-app: coredns