Skip to content

Commit

Permalink
add github-actions-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreZiviani committed Apr 1, 2022
1 parent 8747ffe commit cc6ef6d
Show file tree
Hide file tree
Showing 8 changed files with 315 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/github-actions-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
14 changes: 14 additions & 0 deletions charts/github-actions-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: github-actions-exporter
description: github-actions exporter for prometheus
type: application

# 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.4

# 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: 1.8.1
Empty file.
52 changes: 52 additions & 0 deletions charts/github-actions-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "github-actions-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 "github-actions-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 "github-actions-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "github-actions-exporter.labels" -}}
helm.sh/chart: {{ include "github-actions-exporter.chart" . }}
{{ include "github-actions-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "github-actions-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "github-actions-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
89 changes: 89 additions & 0 deletions charts/github-actions-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "github-actions-exporter.fullname" . }}
labels:
{{ include "github-actions-exporter.labels" . | nindent 4 }}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
{{ include "github-actions-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app: {{ template "github-actions-exporter.name" . }}
release: {{ .Release.Name }}
{{ include "github-actions-exporter.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 }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
env:
{{- range $name, $value := .Values.env }}
{{- if not (empty $value) }}
- name: {{ $name | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: github_token
optional: true
- name: GITHUB_APP_ID
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: github_app_id
optional: true
- name: GITHUB_APP_INSTALLATION_ID
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: github_app_installation_id
optional: true
- name: GITHUB_APP_PRIVATE_KEY
value: /etc/actions-exporter/github_app_private_key
volumeMounts:
- name: actions-exporter
mountPath: "/etc/actions-exporter"
readOnly: true
ports:
- name: http
containerPort: {{ .Values.env.PORT }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: actions-exporter
secret:
secretName: {{ .Values.secret.name }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/github-actions-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "github-actions-exporter.fullname" . }}
labels:
app: {{ template "github-actions-exporter.name" . }}
release: {{ .Release.Name }}
{{- include "github-actions-exporter.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.env.PORT }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "github-actions-exporter.selectorLabels" . | nindent 4 }}
43 changes: 43 additions & 0 deletions charts/github-actions-exporter/templates/serviceMonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if $.Values.serviceMonitor }}
{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- if .Values.serviceMonitor.labels }}
labels:
{{ toYaml .Values.serviceMonitor.labels | indent 4}}
{{- end }}
name: {{ template "github-actions-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
spec:
endpoints:
- targetPort: {{ .Values.service.port }}
{{- if .Values.serviceMonitor.interval }}
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
path: /metrics
{{- if .Values.serviceMonitor.timeout }}
scrapeTimeout: {{ .Values.serviceMonitor.timeout }}
{{- end }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ toYaml .Values.serviceMonitor.metricRelabelings | indent 4 }}
{{- end }}
jobLabel: {{ template "github-actions-exporter.fullname" . }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: {{ template "github-actions-exporter.name" . }}
release: {{ .Release.Name }}
{{- if .Values.serviceMonitor.targetLabels }}
targetLabels:
{{- range .Values.serviceMonitor.targetLabels }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
77 changes: 77 additions & 0 deletions charts/github-actions-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Default values for github-actions-exporter.

image:
repository: spendeskplatform/github-actions-exporter
pullPolicy: IfNotPresent
tag: "v1.8.1"

nameOverride: ""
fullnameOverride: ""

env:
GITHUB_REFRESH: 30 # Refresh time Github Actions status in sec
GITHUB_ORGAS: "" # List all organisations you want get informations. <orga>,<orgb>,<orgc>
GITHUB_REPOS: "" # List all repositories you want get informations. <orga>/<repo>,<orga>/<repo2>,<orga>/<repo3> (like test/test)
PORT: 9999 # Exporter port
GITHUB_API_URL: api.github.com
# ENTERPRISE_NAME: "" # Needed for enterprise endpoints (/enterprises/{ENTERPRISE_NAME}/*)
# EXPORT_FIELDS: "repo,id,node_id,head_branch,head_sha,run_number,workflow_id,workflow,event,status" # A comma separated list of fields for workflow metrics that should be exported
# For the github authentications need to create a secret by default called actions-exporter
# for authentication via github personal token
# key: github_token
# for authentication via github app authentication
# key: github_app_id
# key: github_app_installation_id
# key: github_app_private_key
secret:
name: "actions-exporter"

serviceMonitor:
enabled: yes
labels:
release: prometheus
# Set how frequently Prometheus should scrape
interval: 30s
# Set the namespace the ServiceMonitor should be deployed
# namespace: monitoring
# Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
# labels:
# Set timeout for scrape
# timeout: 10s
# Set of labels to transfer on the Kubernetes Service onto the target.
# targetLabels: []
# metricRelabelings: []

imagePullSecrets: []

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 9999


resources: {}
# limits:
# cpu: 300m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit cc6ef6d

Please sign in to comment.