From 245c5df162d2c84f563090e40442b3fbf32ba3e0 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Mon, 17 May 2021 10:17:03 +0200 Subject: [PATCH 1/3] Add: Speedtest exporter Signed-off-by: Nicolas Lamirault --- charts/speedtest-exporter/.helmignore | 23 +++ charts/speedtest-exporter/Chart.yaml | 53 +++++ charts/speedtest-exporter/LICENSE | 195 ++++++++++++++++++ charts/speedtest-exporter/README.md | 59 ++++++ charts/speedtest-exporter/ci/test-values.yaml | 23 +++ charts/speedtest-exporter/templates/NOTES.txt | 4 + .../speedtest-exporter/templates/_helpers.tpl | 68 ++++++ .../templates/deployment.yaml | 90 ++++++++ .../speedtest-exporter/templates/service.yaml | 27 +++ .../templates/serviceaccount.yaml | 18 ++ .../templates/servicemonitor.yaml | 35 ++++ charts/speedtest-exporter/values.schema.json | 22 ++ charts/speedtest-exporter/values.yaml | 91 ++++++++ 13 files changed, 708 insertions(+) create mode 100644 charts/speedtest-exporter/.helmignore create mode 100644 charts/speedtest-exporter/Chart.yaml create mode 100644 charts/speedtest-exporter/LICENSE create mode 100644 charts/speedtest-exporter/README.md create mode 100644 charts/speedtest-exporter/ci/test-values.yaml create mode 100644 charts/speedtest-exporter/templates/NOTES.txt create mode 100644 charts/speedtest-exporter/templates/_helpers.tpl create mode 100644 charts/speedtest-exporter/templates/deployment.yaml create mode 100644 charts/speedtest-exporter/templates/service.yaml create mode 100644 charts/speedtest-exporter/templates/serviceaccount.yaml create mode 100644 charts/speedtest-exporter/templates/servicemonitor.yaml create mode 100644 charts/speedtest-exporter/values.schema.json create mode 100644 charts/speedtest-exporter/values.yaml diff --git a/charts/speedtest-exporter/.helmignore b/charts/speedtest-exporter/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/speedtest-exporter/.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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/speedtest-exporter/Chart.yaml b/charts/speedtest-exporter/Chart.yaml new file mode 100644 index 00000000..ba287ba2 --- /dev/null +++ b/charts/speedtest-exporter/Chart.yaml @@ -0,0 +1,53 @@ +# Copyright (C) 2021 Nicolas Lamirault +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v2 +name: speedtest-exporter +description: A Helm chart for Prometheus Speedtest exporter +home: https://charts.portefaix.xyz +icon: https://raw.githubusercontent.com/thanos-io/thanos/master/docs/img/Thanos-logo_fullmedium.png +sources: + - https://github.com/nlamirault/portefaix-hub/tree/master/charts/speedtest-exporter +type: application +keywords: + - speedtest + - prometheus-exporter + - portefaix + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: 0.0.4 + +maintainers: + - name: nlamirault + email: nicolas.lamirault@gmail.com + +# https://artifacthub.io/docs/topics/repositories/ +annotations: + artifacthub.io/changes: | + - Artifact Hub informations + artifacthub.io/links: | + - name: Speedtest exporter + url: https://github.com/danopstech/speedtest_exporter + - name: Portefaix + url: https://portefaix.xyz + artifacthub.io/maintainers: | + - name: nlamirault + email: nicolas.lamirault@gmail.com diff --git a/charts/speedtest-exporter/LICENSE b/charts/speedtest-exporter/LICENSE new file mode 100644 index 00000000..70a865f1 --- /dev/null +++ b/charts/speedtest-exporter/LICENSE @@ -0,0 +1,195 @@ + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + diff --git a/charts/speedtest-exporter/README.md b/charts/speedtest-exporter/README.md new file mode 100644 index 00000000..99270db5 --- /dev/null +++ b/charts/speedtest-exporter/README.md @@ -0,0 +1,59 @@ +# speedtest-exporter + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.0.4](https://img.shields.io/badge/AppVersion-0.0.4-informational?style=flat-square) + +A Helm chart for Prometheus Speedtest exporter + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| nlamirault | nicolas.lamirault@gmail.com | | + +## Source Code + +* + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| additionalAnnotations | object | `{}` | Additional annotations to add to the Prometheus rules | +| additionalLabels | object | `{}` | Additional labels to add to the Prometheus rules | +| affinity | object | `{}` | | +| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources | +| hostNetwork | bool | `false` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.pullSecret | string | `""` | | +| image.repository | string | `"danopstech/speedtest_exporter"` | | +| image.tag | string | `"v0.0.4"` | | +| imagePullSecrets | list | `[]` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | | +| prometheus.monitor.additionalLabels | object | `{}` | | +| prometheus.monitor.enabled | bool | `false` | | +| prometheus.monitor.honorLabels | bool | `false` | | +| prometheus.monitor.namespace | string | `""` | | +| readOnlyRootFilesystem | bool | `true` | | +| replicas | int | `1` | | +| resources | object | `{}` | | +| runAsNonRoot | bool | `true` | | +| runAsUser | int | `1000` | | +| securityContext.enabled | bool | `true` | | +| securityContext.runAsGroup | int | `65534` | | +| securityContext.runAsUser | int | `65534` | | +| service.annotations | object | `{}` | | +| service.loadBalancerIP | string | `""` | | +| service.nodePort | int | `0` | | +| service.port | int | `9090` | | +| service.type | string | `"ClusterIP"` | | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.imagePullSecrets | list | `[]` | | +| serviceAccount.name | string | `nil` | | +| tolerations | list | `[]` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/charts/speedtest-exporter/ci/test-values.yaml b/charts/speedtest-exporter/ci/test-values.yaml new file mode 100644 index 00000000..51e21e22 --- /dev/null +++ b/charts/speedtest-exporter/ci/test-values.yaml @@ -0,0 +1,23 @@ +# Values for CI +# + +additionalLabels: + prometheus: k8s + exporter: speedtest + +additionalAnnotations: + made-by: portefaix + +resources: + limits: + cpu: 100m + memory: 64Mi + requests: + cpu: 10m + memory: 32Mi + +prometheus: + monitor: + enabled: true + additionalLabels: + release: kube-prometheus-stack diff --git a/charts/speedtest-exporter/templates/NOTES.txt b/charts/speedtest-exporter/templates/NOTES.txt new file mode 100644 index 00000000..4d61b09e --- /dev/null +++ b/charts/speedtest-exporter/templates/NOTES.txt @@ -0,0 +1,4 @@ +speedtest-exporter is a Prometheus exporter that generates metrics about the Speedtest API. + +The metrics are exported on the HTTP endpoint /metrics on the listening port. +In your case, {{ template "speedtest-exporter.fullname" . }}.{{ template "speedtest-exporter.namespace" . }}.svc.cluster.local:{{ .Values.service.port }}/metrics diff --git a/charts/speedtest-exporter/templates/_helpers.tpl b/charts/speedtest-exporter/templates/_helpers.tpl new file mode 100644 index 00000000..051b9e80 --- /dev/null +++ b/charts/speedtest-exporter/templates/_helpers.tpl @@ -0,0 +1,68 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* +Expand the name of the chart. +*/}} +{{- define "speedtest-exporter.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-exporter.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-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "speedtest-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "speedtest-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* Generate basic labels */}} +{{- define "speedtest-exporter.labels" }} +app.kubernetes.io/name: {{ template "speedtest-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/version: "{{ .Chart.Version }}" +app.kubernetes.io/part-of: {{ template "speedtest-exporter.name" . }} +helm.sh/chart: {{ template "speedtest-exporter.chart" . }} +{{- if .Values.additionalLabels }} +{{ toYaml .Values.additionalLabels }} +{{- end }} +{{- end }} + +{{/* +Allow the release namespace to be overridden +*/}} +{{- define "speedtest-exporter.namespace" -}} + {{- if .Values.namespaceOverride -}} + {{- .Values.namespaceOverride -}} + {{- else -}} + {{- .Release.Namespace -}} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/speedtest-exporter/templates/deployment.yaml b/charts/speedtest-exporter/templates/deployment.yaml new file mode 100644 index 00000000..ec2c4560 --- /dev/null +++ b/charts/speedtest-exporter/templates/deployment.yaml @@ -0,0 +1,90 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "speedtest-exporter.fullname" . }} + namespace: {{ template "speedtest-exporter.namespace" . }} +{{- if .Values.additionalAnnotations }} + annotations: +{{ toYaml .Values.additionalAnnotations | indent 4 }} +{{- end }} + labels: + app: {{ template "speedtest-exporter.name" . }} +{{- include "speedtest-exporter.labels" . | indent 4 }} +spec: + selector: + matchLabels: + app: speedtest-exporter + replicas: {{ .Values.replicas }} + template: + metadata: + labels: + app: speedtest-exporter + {{- include "speedtest-exporter.labels" . | indent 8 }} + {{- range $key, $value := .Values.podLabels }} + {{ $key }}: {{ $value }} + {{- end }} + {{- with .Values.podAnnotations }} + annotations: {{ tpl (toYaml .) $ | nindent 8 }} + {{- end }} + spec: + {{- with .Values.image.pullSecrets }} + imagePullSecrets: {{ tpl (toYaml .) $ | nindent 8 }} + {{- end }} + {{- if .Values.securityContext.enabled }} + securityContext: + runAsGroup: {{ .Values.securityContext.runAsGroup }} + runAsUser: {{ .Values.securityContext.runAsUser }} + {{- end }} + serviceAccountName: {{ template "speedtest-exporter.serviceAccountName" . }} + {{- if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName | quote }} + {{- end }} + {{- if .Values.hostNetwork }} + hostNetwork: {{ .Values.hostNetwork }} + {{- end }} + {{- if .Values.dnsPolicy }} + dnsPolicy: {{ .Values.dnsPolicy }} + {{- end }} + containers: + - name: speedtest-exporter + image: {{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.extraArgs }} + args: {{ tpl (toYaml .) $ | nindent 12 }} + {{- end }} +{{- if .Values.resources }} + resources: +{{ toYaml .Values.resources | indent 10 }} +{{- end }} + ports: + - containerPort: 9090 + name: https + protocol: TCP + livenessProbe: + httpGet: + path: /health + port: 9090 + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: / + port: 9090 + initialDelaySeconds: 5 + timeoutSeconds: 5 +{{- if .Values.imagePullSecrets }} + imagePullSecrets: +{{ toYaml .Values.imagePullSecrets | indent 8 }} +{{- end }} +{{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 8 }} +{{- end }} +{{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} +{{- end }} +{{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} +{{- end }} \ No newline at end of file diff --git a/charts/speedtest-exporter/templates/service.yaml b/charts/speedtest-exporter/templates/service.yaml new file mode 100644 index 00000000..f105b060 --- /dev/null +++ b/charts/speedtest-exporter/templates/service.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Service +metadata: +{{- if .Values.additionalAnnotations }} + annotations: +{{ toYaml .Values.additionalAnnotations | indent 4 }} +{{- end }} + labels: + app: {{ template "speedtest-exporter.name" . }} + {{- include "speedtest-exporter.labels" . | indent 4 }} + name: {{ template "speedtest-exporter.fullname" . }} + namespace: {{ template "speedtest-exporter.namespace" . }} +spec: + type: "{{ .Values.service.type }}" + ports: + - name: "http" + protocol: TCP + port: {{ .Values.service.port }} + {{- if .Values.service.nodePort }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + targetPort: 9090 + {{- if .Values.service.loadBalancerIP }} + loadBalancerIP: "{{ .Values.service.loadBalancerIP }}" + {{- end }} + selector: + app: {{ template "speedtest-exporter.name" . }} diff --git a/charts/speedtest-exporter/templates/serviceaccount.yaml b/charts/speedtest-exporter/templates/serviceaccount.yaml new file mode 100644 index 00000000..6ab2b61e --- /dev/null +++ b/charts/speedtest-exporter/templates/serviceaccount.yaml @@ -0,0 +1,18 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: +{{- if .Values.additionalAnnotations }} + annotations: +{{ toYaml .Values.additionalAnnotations | indent 4 }} +{{- end }} + labels: + app: {{ template "speedtest-exporter.name" . }} +{{- include "speedtest-exporter.labels" . | indent 4 }} + name: {{ template "speedtest-exporter.fullname" . }} + namespace: {{ template "speedtest-exporter.namespace" . }} +{{- if .Values.serviceAccount.annotations }} + annotations: +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} +{{- end }} +{{- end -}} diff --git a/charts/speedtest-exporter/templates/servicemonitor.yaml b/charts/speedtest-exporter/templates/servicemonitor.yaml new file mode 100644 index 00000000..470b2199 --- /dev/null +++ b/charts/speedtest-exporter/templates/servicemonitor.yaml @@ -0,0 +1,35 @@ +{{- if .Values.prometheus.monitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: +{{- if or .Values.additionalAnnotations .Values.serviceAccount.annotations }} + annotations: +{{ toYaml .Values.additionalAnnotations | indent 4 }} +{{- if .Values.serviceAccount.annotations }} +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} +{{- end }} +{{- end }} + labels: + app: {{ template "speedtest-exporter.name" . }} +{{- include "speedtest-exporter.labels" . | indent 4 }} +{{- if .Values.prometheus.monitor.additionalLabels }} +{{ toYaml .Values.prometheus.monitor.additionalLabels | indent 4 }} +{{- end }} + name: {{ template "speedtest-exporter.fullname" . }} + namespace: {{ template "speedtest-exporter.namespace" . }} +spec: + selector: + matchLabels: + app: {{ template "speedtest-exporter.name" . }} + endpoints: + - port: http + {{- if .Values.prometheus.monitor.honorLabels }} + honorLabels: true + {{- end }} + {{ if .Values.prometheus.monitor.enabled }} + - port: metrics + {{- if .Values.prometheus.monitor.honorLabels }} + honorLabels: true + {{- end }} + {{ end }} +{{- end }} diff --git a/charts/speedtest-exporter/values.schema.json b/charts/speedtest-exporter/values.schema.json new file mode 100644 index 00000000..0b69fddb --- /dev/null +++ b/charts/speedtest-exporter/values.schema.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/schema#", + "title": "Speedtest exporter Chart JSON Schema", + "type": "object", + "properties": { + "fullnameOverride": { + "type": "string", + "default": "" + }, + "additionalLabels": { + "title": "Additional labels to add to the Prometheus rules", + "type": "object", + "default": {} + }, + "additionalAnnotations": { + "title": "Additional annotations to add to the Prometheus rules", + "type": "object", + "default": {} + } + }, + "required": [] +} \ No newline at end of file diff --git a/charts/speedtest-exporter/values.yaml b/charts/speedtest-exporter/values.yaml new file mode 100644 index 00000000..d35141be --- /dev/null +++ b/charts/speedtest-exporter/values.yaml @@ -0,0 +1,91 @@ +# Default values for speedtest-exporter. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# -- Provide a name to substitute for the full names of resources +fullnameOverride: "" + +# -- Additional labels to add to the Prometheus rules +additionalLabels: {} + +# -- Additional annotations to add to the Prometheus rules +additionalAnnotations: {} + +replicas: 1 + +image: + repository: danopstech/speedtest_exporter + tag: v0.0.4 + pullPolicy: IfNotPresent + pullSecret: "" + +imagePullSecrets: [] +# - name: "image-pull-secret" + +hostNetwork: false + +serviceAccount: + # Specifies whether a ServiceAccount should be created, require rbac true + create: true + # The name of the ServiceAccount to use. + # If not set and create is true, a name is generated using the fullname template + name: + # Reference to one or more secrets to be used when pulling images + # ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ + imagePullSecrets: [] + # ServiceAccount annotations. + # Use case: AWS EKS IAM roles for service accounts + # ref: https://docs.aws.amazon.com/eks/latest/userguide/specify-service-account-role.html + annotations: {} + +service: + port: 9090 + # Default to clusterIP for backward compatibility + type: ClusterIP + nodePort: 0 + loadBalancerIP: "" + annotations: {} + +# Annotations to be added to the pod +podAnnotations: {} + +securityContext: + enabled: true + runAsGroup: 65534 + runAsUser: 65534 + +runAsUser: 1000 +readOnlyRootFilesystem: true +runAsNonRoot: true + +## Node labels for pod assignment +## Ref: https://kubernetes.io/docs/user-guide/node-selection/ +nodeSelector: {} + +## Affinity settings for pod assignment +## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ +affinity: {} + +## Tolerations for pod assignment +## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +tolerations: [] + +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: 64Mi + # requests: + # cpu: 10m + # memory: 32Mi + +prometheus: + monitor: + enabled: false + additionalLabels: {} + # release: kube-prometheus-stack + namespace: "" + honorLabels: false From 169d098ff817e100d129c191d2d52f28728af2c0 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Mon, 17 May 2021 10:51:10 +0200 Subject: [PATCH 2/3] Update: typo and scrape configuration Signed-off-by: Nicolas Lamirault --- charts/speedtest-exporter/README.md | 2 ++ charts/speedtest-exporter/ci/test-values.yaml | 3 ++- charts/speedtest-exporter/templates/deployment.yaml | 2 +- charts/speedtest-exporter/templates/service.yaml | 2 +- charts/speedtest-exporter/templates/servicemonitor.yaml | 8 ++------ charts/speedtest-exporter/values.yaml | 2 ++ 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/charts/speedtest-exporter/README.md b/charts/speedtest-exporter/README.md index 99270db5..08718812 100644 --- a/charts/speedtest-exporter/README.md +++ b/charts/speedtest-exporter/README.md @@ -35,7 +35,9 @@ A Helm chart for Prometheus Speedtest exporter | prometheus.monitor.additionalLabels | object | `{}` | | | prometheus.monitor.enabled | bool | `false` | | | prometheus.monitor.honorLabels | bool | `false` | | +| prometheus.monitor.interval | string | `"60m"` | | | prometheus.monitor.namespace | string | `""` | | +| prometheus.monitor.scrapeTimeout | string | `"60s"` | | | readOnlyRootFilesystem | bool | `true` | | | replicas | int | `1` | | | resources | object | `{}` | | diff --git a/charts/speedtest-exporter/ci/test-values.yaml b/charts/speedtest-exporter/ci/test-values.yaml index 51e21e22..ec157c82 100644 --- a/charts/speedtest-exporter/ci/test-values.yaml +++ b/charts/speedtest-exporter/ci/test-values.yaml @@ -2,7 +2,6 @@ # additionalLabels: - prometheus: k8s exporter: speedtest additionalAnnotations: @@ -19,5 +18,7 @@ resources: prometheus: monitor: enabled: true + interval: 15m + scrapeTimeout: 60s additionalLabels: release: kube-prometheus-stack diff --git a/charts/speedtest-exporter/templates/deployment.yaml b/charts/speedtest-exporter/templates/deployment.yaml index ec2c4560..a5f1a910 100644 --- a/charts/speedtest-exporter/templates/deployment.yaml +++ b/charts/speedtest-exporter/templates/deployment.yaml @@ -58,7 +58,7 @@ spec: {{- end }} ports: - containerPort: 9090 - name: https + name: http protocol: TCP livenessProbe: httpGet: diff --git a/charts/speedtest-exporter/templates/service.yaml b/charts/speedtest-exporter/templates/service.yaml index f105b060..a5ab8fa1 100644 --- a/charts/speedtest-exporter/templates/service.yaml +++ b/charts/speedtest-exporter/templates/service.yaml @@ -13,7 +13,7 @@ metadata: spec: type: "{{ .Values.service.type }}" ports: - - name: "http" + - name: http protocol: TCP port: {{ .Values.service.port }} {{- if .Values.service.nodePort }} diff --git a/charts/speedtest-exporter/templates/servicemonitor.yaml b/charts/speedtest-exporter/templates/servicemonitor.yaml index 470b2199..594ae994 100644 --- a/charts/speedtest-exporter/templates/servicemonitor.yaml +++ b/charts/speedtest-exporter/templates/servicemonitor.yaml @@ -23,13 +23,9 @@ spec: app: {{ template "speedtest-exporter.name" . }} endpoints: - port: http + interval: {{ .Values.prometheus.monitor.interval }} + scrapeTimeout: {{ .Values.prometheus.monitor.scrapeTimeout }} {{- if .Values.prometheus.monitor.honorLabels }} honorLabels: true {{- end }} - {{ if .Values.prometheus.monitor.enabled }} - - port: metrics - {{- if .Values.prometheus.monitor.honorLabels }} - honorLabels: true - {{- end }} - {{ end }} {{- end }} diff --git a/charts/speedtest-exporter/values.yaml b/charts/speedtest-exporter/values.yaml index d35141be..e655ee8c 100644 --- a/charts/speedtest-exporter/values.yaml +++ b/charts/speedtest-exporter/values.yaml @@ -85,6 +85,8 @@ resources: {} prometheus: monitor: enabled: false + interval: 60m + scrapeTimeout: 60s additionalLabels: {} # release: kube-prometheus-stack namespace: "" From f4fc66bcbe924830b9d010f3514e25611eb646e1 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Mon, 17 May 2021 11:25:47 +0200 Subject: [PATCH 3/3] Fix: typo Signed-off-by: Nicolas Lamirault --- charts/speedtest-exporter/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/speedtest-exporter/Chart.yaml b/charts/speedtest-exporter/Chart.yaml index ba287ba2..2ca7ceda 100644 --- a/charts/speedtest-exporter/Chart.yaml +++ b/charts/speedtest-exporter/Chart.yaml @@ -16,7 +16,7 @@ apiVersion: v2 name: speedtest-exporter description: A Helm chart for Prometheus Speedtest exporter home: https://charts.portefaix.xyz -icon: https://raw.githubusercontent.com/thanos-io/thanos/master/docs/img/Thanos-logo_fullmedium.png +# icon: htt sources: - https://github.com/nlamirault/portefaix-hub/tree/master/charts/speedtest-exporter type: application