adding speedtest

This commit is contained in:
Jeff Billimek 2018-06-23 18:54:10 -04:00
parent c3d0415192
commit f8539965dc
9 changed files with 255 additions and 0 deletions

23
speedtest/.helmignore Normal file
View File

@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
# OWNERS file for Kubernetes
OWNERS

15
speedtest/Chart.yaml Normal file
View File

@ -0,0 +1,15 @@
apiVersion: v1
name: speedtest
version: 1.0.2
appVersion: 1.0.0
description: periodic speedtest and save the results to InfluxDB
keywords:
- speedtest
- influxdb
home: https://github.com/billimek/Speedtest-for-InfluxDB-and-Grafana
sources:
- https://github.com/billimek/Speedtest-for-InfluxDB-and-Grafana
- https://github.com/billimek/billimek-charts
maintainers:
- name: billimek
email: jeff@billimek.com

4
speedtest/OWNERS Normal file
View File

@ -0,0 +1,4 @@
approvers:
- billimek
reviewers:
- billimek

69
speedtest/README.md Normal file
View File

@ -0,0 +1,69 @@
# Speedtest.net Collector For InfluxDB and Grafana
![Screenshot](https://camo.githubusercontent.com/c652a6685bcb5a8cec6a47c92e57d159b28e47e7/68747470733a2f2f7075752e73682f746d664f412f623535373665383864652e706e67)
This tool is a wrapper for speedtest-cli which allows you to run periodic speedtets and save the results to Influxdb
## TL;DR;
```console
$ helm repo add billimek https://raw.githubusercontent.com/billimek/helm-repo/master
$ helm install billimek/speedtest
```
## Installing the Chart
To install the chart with the release name `my-release`:
```console
$ helm install --name my-release billimek/speedtest
```
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```console
$ helm delete my-release --purge
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The configuration is set as a block of text through a configmap and mouted as a file in /src/config.ini Any value in this text block should match the defined speedtest configuration. There are several values here that will have to match our kubernetes configuration.
## Configuration
The following tables lists the configurable parameters of the Sentry chart and their default values.
| Parameter | Description | Default |
| ------------------------------- | ------------------------------- | ---------------------------------------------------------- |
| `image.repository` | speedtest image | `billimek/speedtestusage-for-influxdb` |
| `image.tag` | speedtest image tag | `latest` |
| `image.pullPolicy` | speedtest image pull policy | `IfNotPresent` |
| `debug` | Display debugging output | `false` |
| `config.delay` | how many seconds to wait between checks | `3600` |
| `config.influxdb.host` | InfluxDB hostname | `influxdb-influxdb` |
| `config.influxdb.port` | InfluxDB port | `8086` |
| `config.influxdb.database` | InfluxDB database | `speedtests` |
| `config.influxdb.username` | InfluxDB username | `` |
| `config.influxdb.password` | InfluxDB password | `` |
| `config.influxdb.ssl` | InfluxDB connection using SSL | `false` |
| `config.speedtest.server` | server to use for speedtest - leave blank to auto-pick | `` |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
$ helm install --name my-release \
--set config.influxdb.host=some-influx-host \
billimek/speedtest
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
$ helm install --name my-release -f values.yaml billimek/speedtest
```
Read through the [values.yaml](values.yaml) file. It has several commented out suggested values.

View File

@ -0,0 +1,7 @@
You can connect to the container running speedtest. To open a shell session in the pod run the following:
- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "speedtest.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh
To trail the logs for the speedtest pod run the following:
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "speedtest.fullname" . }} -o jsonpath='{ .items[0].metadata.name }')

View File

@ -0,0 +1,27 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "speedtest.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "speedtest.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

View File

@ -0,0 +1,32 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "speedtest.fullname" . }}
labels:
app: {{ template "speedtest.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
config.ini: |
[GENERAL]
Delay = {{ .Values.config.delay }}
{{- if .Values.debug }}
Output = True
{{- else }}
Output = False
{{- end }}
[INFLUXDB]
Address = {{ .Values.config.influxdb.host }}
Port = {{ .Values.config.influxdb.port }}
Database = {{ .Values.config.influxdb.database }}
Username = {{ .Values.config.influxdb.username }}
Password = {{ .Values.config.influxdb.password }}
{{- if .Values.config.influxdb.ssl }}
Verify_SSL = True
{{- else }}
Verify_SSL = False
{{- end }}
[SPEEDTEST]
Server = {{ .Values.config.speedtest.server }}

View File

@ -0,0 +1,43 @@
apiVersion: extensions/v1beta1
#apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "speedtest.fullname" . }}
labels:
app: {{ template "speedtest.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
selector:
matchLabels:
app: {{ template "speedtest.name" . }}
release: {{ .Release.Name }}
replicas: {{ default 1 .Values.replicas }}
template:
metadata:
labels:
app: {{ template "speedtest.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{ toYaml .Values.resources | indent 12 }}
volumeMounts:
- name: {{ template "speedtest.name" . }}
mountPath: /src/config.ini
subPath: config.ini
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
volumes:
- name: {{ template "speedtest.name" . }}
configMap:
name: {{ template "speedtest.fullname" . }}
items:
- key: config.ini
path: config.ini

35
speedtest/values.yaml Normal file
View File

@ -0,0 +1,35 @@
# Default values for speedtest.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: atribe/speedtest-for-influxdb-and-grafana
tag: latest
pullPolicy: IfNotPresent
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
debug: false
config:
# how many seconds to wait between checks
delay: 3600
influxdb:
# host/port/database are mandatory - change as needed
host: influxdb-influxdb
port: 8086
database: speedtests
# username:
# password:
ssl: false
speedtest:
# Leave blank to auto pick server
server: