Skip to content

Instantly share code, notes, and snippets.

@bfleming-ciena
Last active March 19, 2018 19:50
Show Gist options
  • Save bfleming-ciena/018882175ffa8efb57a7d594385cd6c7 to your computer and use it in GitHub Desktop.
Save bfleming-ciena/018882175ffa8efb57a7d594385cd6c7 to your computer and use it in GitHub Desktop.
K8s Prometheus CoreOS Operator - Adding external nodes to be monitored.
-- My need was to include nodes outside of my k8s cluster for monitoring.
-- Thanks to @amalucelli for originally posting this.
-- https://github.com/coreos/prometheus-operator/issues/834
--
-- This is tested with k8s 1.9, and .17 prometheus operator, using the pre-built deployment at
-- https://github.com/coreos/prometheus-operator/blob/master/contrib/kube-prometheus/README.md
-- Steps: Deploy per the script above, and then apply these objects. Should appear in granfa after a short time.
kind: Service
apiVersion: v1
metadata:
name: my-internal-server
labels:
k8s-app: node-exporter
spec:
type: ExternalName
externalName: 172.20.58.243
ports:
- name: metrics
port: 9100
protocol: TCP
targetPort: 9100
apiVersion: v1
kind: Endpoints
metadata:
name: my-internal-server
labels:
k8s-app: node-exporter
subsets:
- addresses:
- ip: 172.20.58.243
ports:
- name: metrics
port: 9100
protocol: TCP
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: internal-servers
labels:
k8s-app: node-exporter
spec:
selector:
matchLabels:
k8s-app: node-exporter
namespaceSelector:
matchNames:
- monitoring
endpoints:
- port: metrics
interval: 10s
honorLabels: true
path: /metrics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment