diff --git a/charts/uptimerobot-prometheus/.helmignore b/charts/uptimerobot-prometheus/.helmignore new file mode 100644 index 00000000..a9fe7278 --- /dev/null +++ b/charts/uptimerobot-prometheus/.helmignore @@ -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 \ No newline at end of file diff --git a/charts/uptimerobot-prometheus/Chart.yaml b/charts/uptimerobot-prometheus/Chart.yaml new file mode 100644 index 00000000..d9b21144 --- /dev/null +++ b/charts/uptimerobot-prometheus/Chart.yaml @@ -0,0 +1,18 @@ +apiVersion: v2 +name: uptimerobot-prometheus +description: Prometheus Exporter for the official uptimerobot CLI +type: application +version: 1.0.0 +appVersion: 0.0.1 +keywords: +- uptimerobot +- prometheus +- grafana +home: https://github.com/billimek/billimek-charts/tree/master/charts/uptimerobot-prometheus +icon: https://cdn.foliovision.com/images/2019/03/icon-uptimerobot-1024.png +sources: +- https://github.com/lekpamartin/uptimerobot_exporter +- https://github.com/billimek/billimek-charts/tree/master/charts/uptimerobot-prometheus +maintainers: +- name: billimek + email: jeff@billimek.com diff --git a/charts/uptimerobot-prometheus/OWNERS b/charts/uptimerobot-prometheus/OWNERS new file mode 100644 index 00000000..51f88652 --- /dev/null +++ b/charts/uptimerobot-prometheus/OWNERS @@ -0,0 +1,4 @@ +approvers: +- billimek +reviewers: +- billimek \ No newline at end of file diff --git a/charts/uptimerobot-prometheus/README.md b/charts/uptimerobot-prometheus/README.md new file mode 100644 index 00000000..15d06f11 --- /dev/null +++ b/charts/uptimerobot-prometheus/README.md @@ -0,0 +1,52 @@ +# Prometheus Exporter using the Uptimerobot API + +![](https://raw.githubusercontent.com/lekpamartin/uptimerobot_exporter/master/dashboards/dashboard.PNG) + +This is a helm chart providing a prometheus exporter to query the uptimerobot API. Based on the [uptimerobot_exporter](https://github.com/lekpamartin/uptimerobot_exporter) container image. + +## TL;DR; + +```console +helm repo add billimek https://billimek.com/billimek-charts/ +helm install billimek/uptimerobot-prometheus +``` + +## Installing the Chart + +To install the chart with the release name `uptimerobot-prometheus`: + +```console +helm install --name uptimerobot-prometheus billimek/uptimerobot-prometheus +``` + +## Uninstalling the Chart + +To uninstall/delete the `uptimerobot-prometheus` deployment: + +```console +helm delete uptimerobot-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/uptimerobot-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 uptimerobot-prometheus \ + --set serviceMonitor.enabled=true \ + billimek/uptimerobot-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 uptimerobot-prometheus -f values.yaml billimek/uptimerobot-prometheus +``` + +## Grafana Dashboard + +You can find an [example grafana dashboard](https://github.com/lekpamartin/uptimerobot_exporter/blob/master/dashboards/grafana.json) as shown in the screenshot above. diff --git a/charts/uptimerobot-prometheus/templates/NOTES.txt b/charts/uptimerobot-prometheus/templates/NOTES.txt new file mode 100644 index 00000000..fafec45d --- /dev/null +++ b/charts/uptimerobot-prometheus/templates/NOTES.txt @@ -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 "uptimerobot-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 "uptimerobot-prometheus.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "uptimerobot-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 "uptimerobot-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 }} diff --git a/charts/uptimerobot-prometheus/templates/_helpers.tpl b/charts/uptimerobot-prometheus/templates/_helpers.tpl new file mode 100644 index 00000000..4759eb85 --- /dev/null +++ b/charts/uptimerobot-prometheus/templates/_helpers.tpl @@ -0,0 +1,52 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "uptimerobot-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 "uptimerobot-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 "uptimerobot-prometheus.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "uptimerobot-prometheus.labels" -}} +helm.sh/chart: {{ include "uptimerobot-prometheus.chart" . }} +{{ include "uptimerobot-prometheus.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "uptimerobot-prometheus.selectorLabels" -}} +app.kubernetes.io/name: {{ include "uptimerobot-prometheus.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/uptimerobot-prometheus/templates/deployment.yaml b/charts/uptimerobot-prometheus/templates/deployment.yaml new file mode 100644 index 00000000..5943299e --- /dev/null +++ b/charts/uptimerobot-prometheus/templates/deployment.yaml @@ -0,0 +1,49 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "uptimerobot-prometheus.fullname" . }} + labels: + {{- include "uptimerobot-prometheus.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "uptimerobot-prometheus.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "uptimerobot-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 }} + env: + - name: UPTIMEROBOT_API_KEY + value: "{{ .Values.uptimerobotApiKey }}" + ports: + - name: http + containerPort: 9705 + protocol: TCP + 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 }} diff --git a/charts/uptimerobot-prometheus/templates/service.yaml b/charts/uptimerobot-prometheus/templates/service.yaml new file mode 100644 index 00000000..d1807041 --- /dev/null +++ b/charts/uptimerobot-prometheus/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "uptimerobot-prometheus.fullname" . }} + labels: + {{- include "uptimerobot-prometheus.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "uptimerobot-prometheus.selectorLabels" . | nindent 4 }} diff --git a/charts/uptimerobot-prometheus/templates/servicemonitor.yaml b/charts/uptimerobot-prometheus/templates/servicemonitor.yaml new file mode 100644 index 00000000..d20e75a3 --- /dev/null +++ b/charts/uptimerobot-prometheus/templates/servicemonitor.yaml @@ -0,0 +1,23 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "uptimerobot-prometheus.fullname" . }} + labels: + {{- include "uptimerobot-prometheus.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "uptimerobot-prometheus.selectorLabels" . | nindent 6 }} + endpoints: + - port: http + interval: {{ .Values.serviceMonitor.interval }} + path: / + params: + script: + - uptimerobot + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} +{{- end }} diff --git a/charts/uptimerobot-prometheus/values.yaml b/charts/uptimerobot-prometheus/values.yaml new file mode 100644 index 00000000..9960ffd6 --- /dev/null +++ b/charts/uptimerobot-prometheus/values.yaml @@ -0,0 +1,56 @@ +# Default values for uptimerobot-prometheus. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: billimek/prometheus-uptimerobot-exporter + tag: 0.0.1 + pullPolicy: IfNotPresent + +uptimerobotApiKey: '' + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 9705 + +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: "5m" + scrapeTimeout: 90s + # namespace: default + additionalLabels: {}