-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from fbuchmeier-abi/master
fixed parsing of test data, added helm chart, added server port, updated logging
- Loading branch information
Showing
21 changed files
with
346 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
FROM python:3.7.4-alpine3.10 | ||
|
||
ADD exporter exporter/ | ||
add requirements.txt exporter/requirements.txt | ||
ADD requirements.txt exporter/requirements.txt | ||
|
||
WORKDIR exporter | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["python", "app.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Tiltfile_* | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
appVersion: latest | ||
description: Status Cake Prometheus Exporter | ||
keywords: | ||
- prometheus | ||
- statuscake | ||
maintainers: [] | ||
name: status-cake-exporter | ||
version: 1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Statuscake Prometheus Exporter Helm Chart | ||
|
||
This Helm chart deploys the StatusCake Prometheus exporter from [chelnak/status-cake-exporter](https://github.com/chelnak/status-cake-exporter). | ||
|
||
## Requirements | ||
|
||
* Statuscake `username` and `apiKey` defined in [values.yaml](values.yaml). | ||
|
||
## Usage | ||
|
||
Create your own `values.yaml` file and run: | ||
|
||
```bash | ||
helm install status-cake-exporter . --namespace default --values values.yaml | ||
``` | ||
|
||
## Testing | ||
|
||
```bash | ||
helm test ${releaseName} | ||
``` | ||
|
||
## Development | ||
|
||
This repository uses [Tilt](https://tilt.dev) for rapid development on Kubernetes. | ||
|
||
To use this, run: | ||
|
||
```sh | ||
tilt up | ||
``` | ||
|
||
Tilt will reload your environment when it detects changes to your code (see [Tiltfile](Tiltfile) for the list of paths watched). | ||
|
||
Note: You will need to provide valid credentials for StatusCake in your `Tiltfile` for this to work. To do so, you can copy the file to e.g. `Tiltfile_secret`, update it and then start tilt with: | ||
|
||
```sh | ||
tilt up -f Tiltfile_secret | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
docker_build('status-cake-exporter:dev', '../../') | ||
# If not using a standard local dev name, specify your k8s context here | ||
#allow_k8s_contexts('microk8s') | ||
k8s_yaml(helm('.', values='values.yaml', set=['statuscake.logLevel=debug', 'image.repository=status-cake-exporter', 'image.tag=dev', 'statuscake.username=', 'statuscake.apiKey=', 'statuscake.tags=firstTag,secondTag'])) | ||
watch_file('.') | ||
watch_file('../../Dockerfile') | ||
watch_file('../../exporter') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
*/}} | ||
{{- define "fullname" -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for deployment. | ||
*/}} | ||
{{- define "deployment.apiVersion" -}} | ||
{{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}} | ||
{{- print "extensions/v1beta1" -}} | ||
{{- else if semverCompare "^1.9-0" .Capabilities.KubeVersion.GitVersion -}} | ||
{{- print "apps/v1" -}} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
apiVersion: {{ template "deployment.apiVersion" . }} | ||
kind: Deployment | ||
metadata: | ||
name: "{{ .Release.Name }}" | ||
labels: | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
heritage: {{ .Release.Service | quote }} | ||
release: {{ .Release.Name | quote }} | ||
app: "{{ .Release.Name }}" | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: "{{ .Release.Name }}" | ||
template: | ||
metadata: | ||
labels: | ||
app: "{{ .Release.Name }}" | ||
spec: | ||
containers: | ||
- name: status-cake-exporter | ||
image: {{ .Values.image.repository }}:{{ .Values.image.tag }} | ||
ports: | ||
- containerPort: {{ .Values.service.port }} | ||
env: | ||
- name: USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Release.Name }}-api-token | ||
key: USERNAME | ||
- name: API_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Release.Name }}-api-token | ||
key: API_KEY | ||
{{- if .Values.statuscake.tags }} | ||
- name: TAGS | ||
value: {{ .Values.statuscake.tags }} | ||
{{- end }} | ||
{{- if .Values.statuscake.logLevel }} | ||
- name: LOG_LEVEL | ||
value: {{ .Values.statuscake.logLevel }} | ||
{{- end }} | ||
resources: | ||
{{ toYaml .Values.resources | indent 10 }} | ||
{{- if .Values.image.pullSecrets }} | ||
imagePullSecrets: | ||
{{- range .Values.image.pullSecrets }} | ||
- name: {{ . }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "{{ .Release.Name }}-api-token" | ||
labels: | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
heritage: {{ .Release.Service | quote }} | ||
release: {{ .Release.Name | quote }} | ||
app: "{{ .Release.Name }}" | ||
type: generic | ||
data: | ||
USERNAME: {{ .Values.statuscake.username | b64enc }} | ||
API_KEY: {{ .Values.statuscake.apiKey | b64enc }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "{{ .Release.Name }}" | ||
labels: | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" | ||
heritage: {{ .Release.Service | quote }} | ||
release: {{ .Release.Name | quote }} | ||
app: "{{ .Release.Name }}" | ||
spec: | ||
ports: | ||
- port: {{ .Values.service.port }} | ||
protocol: TCP | ||
selector: | ||
app: "{{ .Release.Name }}" |
43 changes: 43 additions & 0 deletions
43
chart/status-cake-exporter/templates/tests/status-cake-exporter-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: "{{ .Release.Name }}-test-{{ randAlphaNum 5 | lower }}" | ||
annotations: | ||
"helm.sh/hook": test-success | ||
spec: | ||
containers: | ||
- name: {{ .Release.Name }}-test | ||
image: {{ .Values.image.repository }}:{{ .Values.image.tag }} | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
set -x | ||
# run tests | ||
sh /tests/run.sh | ||
volumeMounts: | ||
- mountPath: /tests | ||
name: tests | ||
readOnly: true | ||
- mountPath: /tools | ||
name: tools | ||
resources: | ||
requests: | ||
cpu: "50m" | ||
memory: "128Mi" | ||
limits: | ||
cpu: "250m" | ||
memory: "256Mi" | ||
volumes: | ||
- name: tests | ||
configMap: | ||
name: {{ .Release.Name }}-tests | ||
- name: tools | ||
emptyDir: {} | ||
restartPolicy: Never | ||
{{- if .Values.image.pullSecrets }} | ||
imagePullSecrets: | ||
{{- range .Values.image.pullSecrets }} | ||
- name: {{ . }} | ||
{{- end }} | ||
{{- end }} |
12 changes: 12 additions & 0 deletions
12
chart/status-cake-exporter/templates/tests/test-config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ .Release.Name }}-tests | ||
data: | ||
run.sh: |- | ||
for i in $(seq 1 48) ; do | ||
wget -T 10 http://{{ .Release.Name }}:{{ .Values.service.port }}/metrics && exit 0 | ||
sleep 5 | ||
done | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
image: | ||
repository: chelnak/status-cake-exporter | ||
tag: latest | ||
# A list of ImagePullSecrets to use for the containers in this Chart | ||
pullSecrets: [] | ||
|
||
statuscake: | ||
# REQUIRED: username to use when connecting to statuscake | ||
username: "" | ||
# REQUIRED: apikey to use when connecting to statuscake | ||
apiKey: "" | ||
# optional: a comma separated list of tags to filter for | ||
# tags: | ||
# optional: debug, info, warn, error | ||
# logLevel: | ||
|
||
service: | ||
port: 8000 | ||
|
||
resources: | ||
requests: | ||
cpu: "250m" | ||
memory: "256Mi" | ||
limits: | ||
cpu: "250m" | ||
memory: "256Mi" |
Oops, something went wrong.