From 871729f41968b4d79b698c5b1cf11c4c05d9dc65 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 20 May 2020 17:26:59 +0200 Subject: [PATCH 1/8] Add tests --- charts/docker-hub-exporter/Chart.yaml | 2 +- .../templates/tests/test-connection.yaml | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 charts/docker-hub-exporter/templates/tests/test-connection.yaml diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index c649627..f1d21af 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.0 +version: 0.1.1 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/tests/test-connection.yaml b/charts/docker-hub-exporter/templates/tests/test-connection.yaml new file mode 100644 index 0000000..1eb7442 --- /dev/null +++ b/charts/docker-hub-exporter/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include ".helm.fullname" . }}-test-connection" + labels: +{{ include ".helm.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include ".helm.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never From b4621cfa91c90bab9f20c3f4b75626380f949264 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 20 May 2020 22:29:37 +0200 Subject: [PATCH 2/8] Hard code port --- charts/docker-hub-exporter/Chart.yaml | 2 +- charts/docker-hub-exporter/templates/deployment.yaml | 6 +++--- charts/docker-hub-exporter/templates/service.yaml | 4 ++-- .../templates/tests/test-connection.yaml | 2 +- charts/docker-hub-exporter/values.yaml | 3 --- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index f1d21af..09ff7e2 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.1 +version: 0.1.2 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/deployment.yaml b/charts/docker-hub-exporter/templates/deployment.yaml index 921a12c..63c625d 100644 --- a/charts/docker-hub-exporter/templates/deployment.yaml +++ b/charts/docker-hub-exporter/templates/deployment.yaml @@ -15,7 +15,7 @@ spec: metadata: annotations: prometheus.io/scrape: "true" - prometheus.io/port: {{ .Values.service.port | quote}} + prometheus.io/port: "9170" labels: app: {{ include ".helm.fullname" . }} release: {{ include ".helm.fullname" . }} @@ -31,8 +31,8 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: metrics - containerPort: {{ .Values.service.port }} + containerPort: 9170 protocol: TCP args: - - -listen-address=:{{ .Values.service.port }} + - -listen-address=:9170 - -organisations={{ .Values.organisations }} diff --git a/charts/docker-hub-exporter/templates/service.yaml b/charts/docker-hub-exporter/templates/service.yaml index 141456a..c1468db 100644 --- a/charts/docker-hub-exporter/templates/service.yaml +++ b/charts/docker-hub-exporter/templates/service.yaml @@ -7,8 +7,8 @@ metadata: spec: type: ClusterIP ports: - - port: {{ .Values.service.port }} - targetPort: {{ .Values.service.port }} + - port: 9170 + targetPort: 9170 protocol: TCP name: metrics selector: diff --git a/charts/docker-hub-exporter/templates/tests/test-connection.yaml b/charts/docker-hub-exporter/templates/tests/test-connection.yaml index 1eb7442..cacfe6c 100644 --- a/charts/docker-hub-exporter/templates/tests/test-connection.yaml +++ b/charts/docker-hub-exporter/templates/tests/test-connection.yaml @@ -11,5 +11,5 @@ spec: - name: wget image: busybox command: ['wget'] - args: ['{{ include ".helm.fullname" . }}:{{ .Values.service.port }}'] + args: ['{{ include ".helm.fullname" . }}:9170'] restartPolicy: Never diff --git a/charts/docker-hub-exporter/values.yaml b/charts/docker-hub-exporter/values.yaml index 6959e00..da0190c 100644 --- a/charts/docker-hub-exporter/values.yaml +++ b/charts/docker-hub-exporter/values.yaml @@ -8,6 +8,3 @@ organisations: YOUR_USER_OR_ORG grafana: influxdb: false prometheus: false - -service: - port: 9170 From 462ab6b43a09b69a31860975451170e61a276481 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 21 May 2020 12:16:43 +0200 Subject: [PATCH 3/8] Use named port for metrics in service --- charts/docker-hub-exporter/Chart.yaml | 2 +- charts/docker-hub-exporter/templates/service.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index 09ff7e2..e160027 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.2 +version: 0.1.3 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/service.yaml b/charts/docker-hub-exporter/templates/service.yaml index c1468db..9387b67 100644 --- a/charts/docker-hub-exporter/templates/service.yaml +++ b/charts/docker-hub-exporter/templates/service.yaml @@ -8,7 +8,7 @@ spec: type: ClusterIP ports: - port: 9170 - targetPort: 9170 + targetPort: metrics protocol: TCP name: metrics selector: From 3addecebb20f125554c6a94565da2f7765a2b282 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 21 May 2020 12:23:39 +0200 Subject: [PATCH 4/8] Add notes --- charts/docker-hub-exporter/Chart.yaml | 2 +- charts/docker-hub-exporter/templates/NOTES.txt | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 charts/docker-hub-exporter/templates/NOTES.txt diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index e160027..5ff697d 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.3 +version: 0.1.4 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/NOTES.txt b/charts/docker-hub-exporter/templates/NOTES.txt new file mode 100644 index 0000000..a279e47 --- /dev/null +++ b/charts/docker-hub-exporter/templates/NOTES.txt @@ -0,0 +1,7 @@ +Congratulations, your prometheus compatible scraped Docker hub metrics are now available for scraping. + +You can access them by using a port forward: +kubectl port-forward svc/{{ include ".helm.fullname" . }} 9170:9170 -n {{ .Release.Namespace }} + +And then point your browser to: +http://localhost:9170/ \ No newline at end of file From 11ca5bd059ca90094b00da922a40535f7925f4ec Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 21 May 2020 12:27:36 +0200 Subject: [PATCH 5/8] Fix escaping in prometheus dashbaord --- charts/docker-hub-exporter/Chart.yaml | 2 +- .../templates/grafana-dashboard-docker-hub-prometheus.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index 5ff697d..fba1b35 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.4 +version: 0.1.5 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/grafana-dashboard-docker-hub-prometheus.yaml b/charts/docker-hub-exporter/templates/grafana-dashboard-docker-hub-prometheus.yaml index 3b3d0c8..0c4705f 100644 --- a/charts/docker-hub-exporter/templates/grafana-dashboard-docker-hub-prometheus.yaml +++ b/charts/docker-hub-exporter/templates/grafana-dashboard-docker-hub-prometheus.yaml @@ -75,7 +75,7 @@ data: "hide": false, "instant": false, "interval": "", - "legendFormat": "\{\{image}} (\{\{user\}\})", + "legendFormat": "{{"{{"}}image{{"}}"}} ({{"{{"}}user{{"}}"}})", "refId": "A" } ], @@ -271,7 +271,7 @@ data: { "expr": "sum(docker_hub_image_stars_gauge{user=~\"$user\"}) by (image, user)", "interval": "", - "legendFormat": "\{\{image}} (\{\{user\}\})", + "legendFormat": "{{"{{"}}image{{"}}"}} ({{"{{"}}user{{"}}"}})", "refId": "A" } ], From f1120ee3c0a3237da6ddc79d096e3b92e76d9c81 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 21 May 2020 12:33:48 +0200 Subject: [PATCH 6/8] Add readiness and liveness probes --- charts/docker-hub-exporter/Chart.yaml | 2 +- charts/docker-hub-exporter/templates/deployment.yaml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index fba1b35..bb717f0 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.5 +version: 0.1.6 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/deployment.yaml b/charts/docker-hub-exporter/templates/deployment.yaml index 63c625d..2a87433 100644 --- a/charts/docker-hub-exporter/templates/deployment.yaml +++ b/charts/docker-hub-exporter/templates/deployment.yaml @@ -33,6 +33,16 @@ spec: - name: metrics containerPort: 9170 protocol: TCP + livenessProbe: + initialDelaySeconds: 5 + httpGet: + path: / + port: metrics + readinessProbe: + initialDelaySeconds: 5 + httpGet: + path: / + port: metrics args: - -listen-address=:9170 - -organisations={{ .Values.organisations }} From 4343bb0ea525b28a6bbb39f7ab4599139fdb24cf Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 21 May 2020 12:52:40 +0200 Subject: [PATCH 7/8] Drop deadbit about pull secrets --- charts/docker-hub-exporter/Chart.yaml | 2 +- charts/docker-hub-exporter/templates/deployment.yaml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index bb717f0..d1cabf0 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.6 +version: 0.1.7 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/templates/deployment.yaml b/charts/docker-hub-exporter/templates/deployment.yaml index 2a87433..19ed7cd 100644 --- a/charts/docker-hub-exporter/templates/deployment.yaml +++ b/charts/docker-hub-exporter/templates/deployment.yaml @@ -21,10 +21,6 @@ spec: release: {{ include ".helm.fullname" . }} {{- include ".helm.selectorLabels" . | nindent 8 }} spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} containers: - name: docker-hub-exporter image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" From c7b32ec42d7993609f790fb7f77edcab300fd3ad Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Thu, 21 May 2020 12:57:26 +0200 Subject: [PATCH 8/8] Add readme and bump everything in this PR as 0.2 --- charts/docker-hub-exporter/Chart.yaml | 2 +- charts/docker-hub-exporter/README.md | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 charts/docker-hub-exporter/README.md diff --git a/charts/docker-hub-exporter/Chart.yaml b/charts/docker-hub-exporter/Chart.yaml index d1cabf0..319e5b5 100644 --- a/charts/docker-hub-exporter/Chart.yaml +++ b/charts/docker-hub-exporter/Chart.yaml @@ -4,7 +4,7 @@ description: Docker Hub exporter home: https://github.com/jessestuart/docker-hub-exporter icon: https://helm.wyrihaximus.net/images/charts/docker-hub-exporter.png type: application -version: 0.1.7 +version: 0.2.0 appVersion: d05df48 maintainers: - name: WyriHaximus diff --git a/charts/docker-hub-exporter/README.md b/charts/docker-hub-exporter/README.md new file mode 100644 index 0000000..1063103 --- /dev/null +++ b/charts/docker-hub-exporter/README.md @@ -0,0 +1,22 @@ +# Docker Hub Exporter + +Opinionated helm chart for [`jessestuart/docker-hub-exporter`](https://github.com/jessestuart/docker-hub-exporter). + +## Configuration + +While the underlying docker image supports specific docker images this helm chart only lets you configure +`organisations`. There are also two dashboards included, one for InfluxDB and one for Prometheus. + +### Sample configuration + +```yaml +organisations: wyrihaximusnet + +grafana: + prometheus: true +``` + +## Opinionated decisions + +* Port is hardcoded to `9170` for the metrics. +* Only gather metrics for full organizations and users.