Skip to content

Instantly share code, notes, and snippets.

@rmb938
Created September 13, 2019 15:36
Show Gist options
  • Save rmb938/79c3b50967781eadfde33adefd2a471b to your computer and use it in GitHub Desktop.
Save rmb938/79c3b50967781eadfde33adefd2a471b to your computer and use it in GitHub Desktop.
prom operator examples
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus
rules:
- apiGroups:
- ""
resources:
- nodes
- services
- endpoints
- pods
verbs:
- get
- list
- watch
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- apiGroups:
- ""
resources:
- nodes/metrics
verbs:
- get
- nonResourceURLs:
- /metrics
verbs:
- get
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: prometheus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus
namespace: prometheus
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
name: my-namespace # change this to your namespace name
namespace: prometheus
spec:
podMetadata:
labels:
app: prometheus
replicas: 2
resources:
limits:
cpu: 400m
memory: 2Gi
requests:
cpu: 200m
memory: 1Gi
serviceAccountName: prometheus
serviceMonitorNamespaceSelector:
matchLabels: # your namespace should have a label of name: $namespace-name on it
name: my-namespace # change this to your namespace name
serviceMonitorSelector:
matchLabels:
prometheus: prometheus
storage: # change this to an actual storage backend if you are not using thanos or whatever
emptyDir:
sizeLimit: 5Gi
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
generation: 1
labels:
prometheus: prometheus # must have this label
name: my-service-monitor
namespace: my-namespace # change this to your namespace
spec:
endpoints:
- port: exporter # this must be the name of the port defined in your service
selector:
matchLabels: # this must match your service's labels
app: my-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment