Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
315 lines (307 sloc) 7.43 KB
apiVersion: v1
kind: Template
metadata:
name: prometheus-grafana-discovery
parameters:
- description: The namespace where to deploy the services.
name: NAMESPACE
required: true
- description: The discovery scan period, in seconds.
name: SCAN_PERIOD
value: "15"
required: true
objects:
####### ROLE AND SERVICE ACCOUNT #######
- apiVersion: v1
kind: Role
metadata:
name: prom-discover-pods
rules:
- apiGroups: [""]
resources: ["pods"]
verbs:
- get
- list
- watch
- apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus
- apiVersion: v1
kind: RoleBinding
metadata:
name: prom-discover-pods
roleRef:
name: prom-discover-pods
namespace: "${NAMESPACE}"
subjects:
- kind: ServiceAccount
name: prometheus
namespace: "${NAMESPACE}"
####### PROMETHEUS #######
- apiVersion: v1
kind: DeploymentConfig
metadata:
generation: 1
labels:
app: discomon
name: prometheus
spec:
replicas: 1
selector:
app: discomon
deploymentconfig: prometheus
template:
metadata:
labels:
app: discomon
deploymentconfig: prometheus
spec:
volumes:
- name: prometheus-volume-1
emptyDir: {}
- name: prom-config-volume
configMap:
name: prom-config
defaultMode: 420
containers:
- image: >-
prom/prometheus:v2.0.0
imagePullPolicy: Always
name: prometheus
ports:
- containerPort: 9090
protocol: TCP
resources: {}
volumeMounts:
- name: prometheus-volume-1
mountPath: /prometheus
- name: prom-config-volume
mountPath: /etc/prometheus/
terminationMessagePath: /dev/termination-log
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
serviceAccount: prometheus
- apiVersion: v1
kind: Service
metadata:
labels:
app: discomon
name: prometheus
spec:
ports:
- name: 9090-tcp
port: 9090
protocol: TCP
targetPort: 9090
selector:
deploymentconfig: prometheus
type: ClusterIP
- apiVersion: v1
kind: Route
metadata:
name: prometheus
spec:
to:
kind: Service
name: prometheus
- apiVersion: v1
kind: ConfigMap
metadata:
name: prom-config
data:
prometheus.yml: |
global:
scrape_interval: 10s
scrape_timeout: 10s
scrape_configs:
- job_name: k8s-pods
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- ${NAMESPACE}
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: drop
regex: false
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name
####### GRAFANA #######
- apiVersion: v1
kind: DeploymentConfig
metadata:
generation: 1
labels:
app: discomon
name: grafana
spec:
replicas: 1
selector:
app: discomon
deploymentconfig: grafana
template:
metadata:
annotations:
prometheus.io/scrape: 'false'
labels:
app: discomon
deploymentconfig: grafana
spec:
containers:
- image: hawkular/hawkular-grafana-datasource:1.0.10
imagePullPolicy: Always
name: grafana
ports:
- containerPort: 3000
protocol: TCP
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
- apiVersion: v1
kind: Service
metadata:
labels:
app: discomon
name: grafana
spec:
ports:
- name: 3000-tcp
port: 3000
protocol: TCP
targetPort: 3000
selector:
deploymentconfig: grafana
type: ClusterIP
- apiVersion: v1
kind: Route
metadata:
name: grafana
spec:
to:
kind: Service
name: grafana
####### DISCOMON #######
- apiVersion: v1
kind: DeploymentConfig
metadata:
generation: 1
labels:
app: discomon
name: discomon
spec:
replicas: 1
selector:
app: discomon
deploymentconfig: discomon
template:
metadata:
annotations:
prometheus.io/scrape: 'false'
labels:
app: discomon
deploymentconfig: discomon
spec:
volumes:
- name: discomon-config-volume
configMap:
name: discomon-config
defaultMode: 420
containers:
- image: jotak/discomon:latest
imagePullPolicy: Always
name: discomon
ports:
- containerPort: 8080
protocol: TCP
resources: {}
volumeMounts:
- name: discomon-config-volume
mountPath: /etc/discomon/
env:
- name: SCAN_PERIOD
value: "${SCAN_PERIOD}"
initContainers:
- name: wait-grafana
image: yauritux/busybox-curl
command: ['sh', '-c', 'until curl --connect-timeout 2 -u admin:admin http://grafana:3000/api/datasources; do echo waiting for Grafana; sleep 1; done;']
dnsPolicy: ClusterFirst
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
- apiVersion: v1
kind: Service
metadata:
labels:
app: discomon
name: discomon
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
deploymentconfig: discomon
type: ClusterIP
- apiVersion: v1
kind: Route
metadata:
name: discomon
spec:
to:
kind: Service
name: discomon
- apiVersion: v1
kind: ConfigMap
metadata:
name: discomon-config
data:
config.yml: |
descriptors:
- pattern: "^apache*"
name: "apache"
category: "http-server"
- pattern: "^jvm.*"
name: "jvm"
category: "jvm"
- pattern: "^prometheus.*"
name: "prometheus"
category: "monitoring"
- pattern: "^vertx.*"
name: "vertx"
category: "framework"
- pattern: "^span_count.*"
name: "opentracing"
category: "monitoring"
- pattern: "^Tomcat.*"
name: "tomcat"
category: "server"
- pattern: "^pg_.*"
name: "postgres"
category: "database"
- pattern: "^base:jvm_uptime_seconds"
name: "microprofile"
category: "jvm"