Skip to content

Commit

Permalink
Implementing DaemonSet for Telegraf
Browse files Browse the repository at this point in the history
  • Loading branch information
fmdlc committed Oct 23, 2020
1 parent cc7c92e commit de2d87e
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 134 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ repos:
- id: check-symlinks
- id: check-yaml
exclude: kubernetes/yaml/network-dashboard.yaml|kubernetes/ISP-Checker-deploy.yaml
args: ["--allow-multiple-documents"]
- id: detect-aws-credentials
- id: detect-private-key
- id: double-quote-string-fixer
Expand Down
185 changes: 118 additions & 67 deletions kubernetes/ISP-Checker-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,48 @@ spec:
storage: 1Gi
---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: isp-checker-secrets-rw
type: Opaque
stringData:
INFLUXDB_DB: telegraf
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: VerySecurePassword

---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: isp-checker-secrets-ro
type: Opaque
stringData:
INFLUXDB_DB: telegraf
INFLUXDB_READ_USER: grafana
INFLUXDB_READ_PASSWORD: VerySecurePassword

---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: grafana-datasource
stringData:
datasource.yaml: |-
datasources:
- name: InfluxDB
type: influxdb
access: proxy
orgId: 1
url: http://influxdb-svc.monitoring.svc.cluster.local:8086/
user: grafana
database: telegraf
isDefault: true
editable: true
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: monitoring
Expand Down Expand Up @@ -74,17 +116,18 @@ data:
telegraf.conf: |+
[global_tags]
[agent]
interval = "10s"
interval = "60s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = ""
hostname = "$HOSTNAME"
omit_hostname = false
debug = false
quiet = true
[[outputs.influxdb]]
urls = ["http://influxdb-svc.monitoring.svc.cluster.local:8086/"]
Expand All @@ -95,30 +138,38 @@ data:
user_agent = "telegraf"
skip_database_creation = false
[[inputs.net]]
[[inputs.netstat]]
[[inputs.diskio]]
[[inputs.linux_sysctl_fs]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
ignore_fs = ["tmpfs",
"devtmpfs",
"devfs",
"iso9660",
"overlay",
"aufs",
"squashfs"
]
[[inputs.dns_query]]
servers = ["4.2.2.1", "8.8.8.8"]
domains = ["www.google.com", "www.twitter.com", "www.amazon.com", "www.wikipedia.org"]
domains = ["www.google.com",
"www.twitter.com",
"www.amazon.com",
"www.wikipedia.org"
]
record_type = "A"
port = 53
timeout = 3
Expand All @@ -137,12 +188,6 @@ data:
[[inputs.internal]]
collect_memstats = true
[[inputs.linux_sysctl_fs]]
[[inputs.net]]
[[inputs.netstat]]
[[inputs.ping]]
urls = [
"google.com",
Expand Down Expand Up @@ -174,51 +219,22 @@ data:
timeout = "3m"
interval = "15m"
data_format = "csv"
csv_column_names = ['Server ID','Sponsor','Server Name','Timestamp','Distance','Ping','Download','Upload','Share','IP Address']
csv_column_names = ['Server ID',
'Sponsor',
'Server Name',
'Timestamp',
'Distance',
'Ping',
'Download',
'Upload',
'Share',
'IP Address'
]
csv_timestamp_column = "Timestamp"
csv_timestamp_format = "2006-01-02T15:04:05Z07:00"
---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: isp-checker-secrets-rw
type: Opaque
stringData:
INFLUXDB_DB: telegraf
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: VerySecurePassword

---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: isp-checker-secrets-ro
type: Opaque
stringData:
INFLUXDB_DB: telegraf
INFLUXDB_READ_USER: grafana
INFLUXDB_READ_PASSWORD: VerySecurePassword
---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: grafana-datasource
stringData:
datasource.yaml: |-
datasources:
- name: InfluxDB
type: influxdb
access: proxy
orgId: 1
url: http://influxdb-svc.monitoring.svc.cluster.local:8086/
user: grafana
database: telegraf
isDefault: true
editable: true
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
---
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -3983,33 +3999,55 @@ spec:
secretName: grafana-datasource
---
apiVersion: apps/v1
kind: Deployment
kind: DaemonSet
metadata:
namespace: monitoring
name: telegraf
labels:
app: telegraf
spec:
replicas: 1
selector:
matchLabels:
app: telegraf
template:
metadata:
labels:
name: telegraf
app: telegraf
spec:
containers:
- name: telegraf
image: tty0/isp_telegraf:1.15.3
imagePullPolicy: IfNotPresent
envFrom:
- secretRef:
name: isp-checker-secrets-rw
imagePullPolicy: IfNotPresent
env:
- name: "KUBE_API"
value: "https://node2:6443/"
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: "HOST_PROC"
value: "/rootfs/proc"
- name: "HOST_SYS"
value: "/rootfs/sys"
volumeMounts:
- name: telegraf-config-volume
mountPath: /etc/telegraf/
readOnly: true
- name: sys
mountPath: /sys/
readOnly: true
- name: proc
mountPath: /proc/
readOnly: true
- name: docker-socket
mountPath: /var/run/docker.sock
- name: utmp
mountPath: /var/run/utmp
readOnly: true
resources:
requests:
memory: "100Mi"
Expand All @@ -4021,7 +4059,20 @@ spec:
- name: wait-for-influxdb
image: curlimages/curl:7.72.0
command: ['sh', '-c', "until curl -XGET http://influxdb-svc.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local:8086/; do echo Waiting\ for\ InfluxDB; sleep 2; done"]
terminationGracePeriodSeconds: 30
volumes:
- name: telegraf-config-volume
configMap:
name: telegraf-config
- name: sys
hostPath:
path: /sys
- name: docker-socket
hostPath:
path: /var/run/docker.sock
- name: proc
hostPath:
path: /proc
- name: utmp
hostPath:
path: /var/run/utmp
62 changes: 39 additions & 23 deletions kubernetes/yaml/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ data:
telegraf.conf: |+
[global_tags]
[agent]
interval = "10s"
interval = "60s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = ""
hostname = "$HOSTNAME"
omit_hostname = false
debug = false
quiet = true
[[outputs.influxdb]]
urls = ["http://influxdb-svc.monitoring.svc.cluster.local:8086/"]
Expand All @@ -62,30 +63,38 @@ data:
user_agent = "telegraf"
skip_database_creation = false
[[inputs.net]]
[[inputs.netstat]]
[[inputs.diskio]]
[[inputs.linux_sysctl_fs]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
ignore_fs = ["tmpfs",
"devtmpfs",
"devfs",
"iso9660",
"overlay",
"aufs",
"squashfs"
]
[[inputs.dns_query]]
servers = ["4.2.2.1", "8.8.8.8"]
domains = ["www.google.com", "www.twitter.com", "www.amazon.com", "www.wikipedia.org"]
domains = ["www.google.com",
"www.twitter.com",
"www.amazon.com",
"www.wikipedia.org"
]
record_type = "A"
port = 53
timeout = 3
Expand All @@ -104,12 +113,6 @@ data:
[[inputs.internal]]
collect_memstats = true
[[inputs.linux_sysctl_fs]]
[[inputs.net]]
[[inputs.netstat]]
[[inputs.ping]]
urls = [
"google.com",
Expand Down Expand Up @@ -141,6 +144,19 @@ data:
timeout = "3m"
interval = "15m"
data_format = "csv"
csv_column_names = ['Server ID','Sponsor','Server Name','Timestamp','Distance','Ping','Download','Upload','Share','IP Address']
csv_column_names = ['Server ID',
'Sponsor',
'Server Name',
'Timestamp',
'Distance',
'Ping',
'Download',
'Upload',
'Share',
'IP Address'
]
csv_timestamp_column = "Timestamp"
csv_timestamp_format = "2006-01-02T15:04:05Z07:00"
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
Loading

0 comments on commit de2d87e

Please sign in to comment.