Skip to content

Instantly share code, notes, and snippets.

@brb
Last active November 4, 2016 13:38
Show Gist options
  • Save brb/435d940a15b4443f5353aa7424ff469e to your computer and use it in GitHub Desktop.
Save brb/435d940a15b4443f5353aa7424ff469e to your computer and use it in GitHub Desktop.
Prometheus + Kubernetes + WeaveCloud

HOWTO

  1. Get a token from Weave Cloud and set it in prometheus.yaml.
  2. Install Prometheus on Kubernetes: kubectl apply -f prometheus.yaml
  3. Goto http://NODE_IP:30900/targets to check status.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus
data:
prometheus.yml: |-
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'kubernetes-weave'
kubernetes_sd_configs:
- api_server:
role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace,__meta_kubernetes_pod_label_name]
action: keep
regex: ^kube-system;weave-net$
- source_labels: [__meta_kubernetes_pod_container_name,__address__]
action: replace
target_label: __address__
regex: ^weave;(.+)$
replacement: $1:6782
- source_labels: [__meta_kubernetes_pod_container_name,__address__]
action: replace
target_label: __address__
regex: ^weave-npc;(.+)$
replacement: $1:6781
remote_write:
url: http://frontend.dev.weave.works/api/prom/push
basic_auth:
password: REPLACE_ME-WEAVE_CLOUD_TOKEN
---
apiVersion: v1
kind: Service
metadata:
labels:
name: prometheus
name: prometheus
spec:
selector:
app: prometheus
type: NodePort
ports:
- name: prometheus
protocol: TCP
port: 9090
nodePort: 30900
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
name: prometheus
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:v1.3.0
args:
- '-config.file=/etc/prometheus/prometheus.yml'
ports:
- name: web
containerPort: 9090
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus
volumes:
- name: config-volume
configMap:
name: prometheus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment