[speedtest-prometheus] - adding speedtest-prometheus chart (#214)

* adding speedtest-prometheus chart

Signed-off-by: Jeff Billimek <jeff@billimek.com>

* fixup readme

* use charts apiVersion v1

* chart now needs to be v2

* use charts apiVersion v1

* chart now needs to be v2
This commit is contained in:
Jeff Billimek 2020-04-29 18:58:57 -04:00 committed by GitHub
parent 3e599d2138
commit ebf44ef9dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 303 additions and 0 deletions

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

View File

@ -0,0 +1,17 @@
apiVersion: v2
name: speedtest-prometheus
description: Prometheus Exporter for the official Speedtest CLI
type: application
version: 1.0.0
appVersion: 1.1.0
keywords:
- speedtest
- influxdb
- grafana
home: https://github.com/billimek/billimek-charts/tree/master/charts/speedtest-prometheus
icon: https://img.favpng.com/12/7/24/speedtest-net-logo-internet-access-png-favpng-yVPchiKuhWWAXA41Vpak0NUvx.jpg
sources:
- https://github.com/billimek/prometheus-speedtest-exporter
maintainers:
- name: billimek
email: jeff@billimek.com

View File

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

View File

@ -0,0 +1,46 @@
# Prometheus Exporter using the Speedtest CLI
This is a helm chart provising a prometheus exporter (with optional ServiceMontor) to conduct speedtests using the official speedtest CLI. Based on the [prometheus-speedtest-exporter](https://github.com/billimek/prometheus-speedtest-exporter) multi-arch container image.
## TL;DR;
```console
helm repo add billimek https://billimek.com/billimek-charts/
helm install billimek/speedtest-prometheus
```
## Installing the Chart
To install the chart with the release name `speedtest-prometheus`:
```console
helm install --name speedtest-prometheus billimek/speedtest-prometheus
```
## Uninstalling the Chart
To uninstall/delete the `speedtest-prometheus` deployment:
```console
helm delete speedtest-prometheus
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
Read through the [values.yaml](https://github.com/billimek/billimek-charts/blob/master/charts/speedtest-prometheus/values.yaml) file. It has several commented out suggested values.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
helm install --name speedtest-prometheus \
--set serviceMonitor.enabled=true \
billimek/speedtest-prometheus
```
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 speedtest-prometheus -f values.yaml billimek/speedtest-prometheus
```

View File

@ -0,0 +1,15 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "speedtest-prometheus.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "speedtest-prometheus.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "speedtest-prometheus.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "speedtest-prometheus.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}

View File

@ -0,0 +1,52 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "speedtest-prometheus.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-prometheus.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 -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "speedtest-prometheus.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels
*/}}
{{- define "speedtest-prometheus.labels" -}}
helm.sh/chart: {{ include "speedtest-prometheus.chart" . }}
{{ include "speedtest-prometheus.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels
*/}}
{{- define "speedtest-prometheus.selectorLabels" -}}
app.kubernetes.io/name: {{ include "speedtest-prometheus.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

View File

@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "speedtest-prometheus.fullname" . }}
labels:
{{- include "speedtest-prometheus.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "speedtest-prometheus.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "speedtest-prometheus.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 9469
protocol: TCP
livenessProbe:
httpGet:
path: /metrics
port: http
readinessProbe:
httpGet:
path: /metrics
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "speedtest-prometheus.fullname" . }}
labels:
{{- include "speedtest-prometheus.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "speedtest-prometheus.selectorLabels" . | nindent 4 }}

View File

@ -0,0 +1,23 @@
{{- if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "speedtest-prometheus.fullname" . }}
labels:
{{- include "speedtest-prometheus.labels" . | nindent 4 }}
{{- with .Values.serviceMonitor.additionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "speedtest-prometheus.selectorLabels" . | nindent 6 }}
endpoints:
- port: http
interval: {{ .Values.serviceMonitor.interval }}
path: /probe
params:
script:
- speedtest
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}

View File

@ -0,0 +1,54 @@
# Default values for speedtest-prometheus.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: billimek/prometheus-speedtest-exporter
tag: 1.1.0
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 9469
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: {}
tolerations: []
affinity: {}
serviceMonitor:
enabled: false
interval: "60m"
scrapeTimeout: 90s
# namespace: default
additionalLabels: {}