Skip to content

Instantly share code, notes, and snippets.

@XciD
Last active March 6, 2019 14:36
Show Gist options
  • Save XciD/68b8cc7a77eddf8d857fff43b6607787 to your computer and use it in GitHub Desktop.
Save XciD/68b8cc7a77eddf8d857fff43b6607787 to your computer and use it in GitHub Desktop.
k8s ovh metrics
# This will configure Beamium to scrap noderig
# And push metrics to warp 10
# We also add the HOSTNAME to the labels of the metrics pushed
apiVersion: v1
kind: ConfigMap
metadata:
name: beamium-config
namespace: metrics
data:
config.yaml: |
scrapers:
nodering:
url: http://0.0.0.0:9100/metrics
period: 30000
format: sensision
labels:
app: nodering
sinks:
warp:
url: https://warp10.gra1.metrics.ovh.net/api/v0/update
token: $METRICS_TOKEN
labels:
host: $HOSTNAME
---
# This is a custom collector that report the uptime of the node
apiVersion: v1
kind: ConfigMap
metadata:
name: noderig-collector
namespace: metrics
data:
uptime.sh: |
#!/bin/sh
echo 'os.uptime' `date +%s%N | cut -b1-10` `awk '{print $1}' /proc/uptime`
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
name: metrics-daemon
namespace: metrics
spec:
selector:
matchLabels:
name: metrics-daemon
template:
metadata:
labels:
name: metrics-daemon
spec:
terminationGracePeriodSeconds: 10
volumes:
- name: config
configMap:
name: beamium-config
- name: noderig-collector
configMap:
name: noderig-collector
containers:
- image: ovhcom/beamium:latest
imagePullPolicy: Always
name: beamium
env:
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: TEMPLATE_CONFIG
value: /config/config.yaml
envFrom:
- secretRef:
name: w10-credentials
optional: false
resources:
limits:
cpu: "0.05"
memory: 128Mi
requests:
cpu: "0.01"
memory: 128Mi
volumeMounts:
- mountPath: /config
name: config
- image: ovhcom/noderig:latest
imagePullPolicy: Always
name: noderig
args: ["-c", "/collectors", "--net", "3"]
lifecycle:
postStart:
exec:
# As config maps are read only, we need to copy the collector path and make the script executable
# The 60 says to noderig to run the script every minutes
command: ["bash", "-c", "mkdir -p /collectors/60 && cp -r /_collectors/uptime.sh /collectors/60/uptime.sh && chmod +x /collectors/60/uptime.sh"]
volumeMounts:
- mountPath: /_collectors/uptime.sh
name: noderig-collector
subPath: uptime.sh
resources:
limits:
cpu: "0.05"
memory: 128Mi
requests:
cpu: "0.01"
memory: 128Mi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment