Skip to content

Commit

Permalink
Add Helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Nov 21, 2023
1 parent 1225be3 commit 84af351
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 0 deletions.
23 changes: 23 additions & 0 deletions deploy/helm/gitlab-clickhouse-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/
9 changes: 9 additions & 0 deletions deploy/helm/gitlab-clickhouse-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: v2
name: gitlab-clickhouse-exporter
description: A ClickHouse exporter for GitLab CI analytics.
type: application

version: 0.1.0
appVersion: "v0.4.1"

57 changes: 57 additions & 0 deletions deploy/helm/gitlab-clickhouse-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "gitlab-clickhouse-exporter.name" -}}
{{- .Chart.Name | 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 "gitlab-clickhouse-exporter.fullname" -}}
{{- if contains .Chart.Name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "gitlab-clickhouse-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "gitlab-clickhouse-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gitlab-clickhouse-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "gitlab-clickhouse-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "gitlab-clickhouse-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions deploy/helm/gitlab-clickhouse-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "gitlab-clickhouse-exporter.fullname" . }}
labels:
{{- include "gitlab-clickhouse-exporter.labels" . | nindent 4 }}
data:
config.yaml: |
{{- toYaml .Values.config | nindent 4 }}

67 changes: 67 additions & 0 deletions deploy/helm/gitlab-clickhouse-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "gitlab-clickhouse-exporter.fullname" . }}
labels:
{{- include "gitlab-clickhouse-exporter.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "gitlab-clickhouse-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "gitlab-clickhouse-exporter.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "gitlab-clickhouse-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/gitlab-clickhouse-exporter/
ports:
- name: http
{{- $serverConfig := .Values.config.server | default dict }}
containerPort: {{ $serverConfig.port | default "8080" }}
protocol: TCP
livenessProbe:
httpGet:
path: /healthz/live
port: http
readinessProbe:
httpGet:
path: /healthz/ready
port: http
env:
{{- toYaml .Values.env | nindent 12 }}
args: ["run", "--config", "/etc/gitlab-clickhouse-exporter/config.yaml"]
volumes:
- name: config
configMap:
name: {{ include "gitlab-clickhouse-exporter.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

16 changes: 16 additions & 0 deletions deploy/helm/gitlab-clickhouse-exporter/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "gitlab-clickhouse-exporter.fullname" . }}
labels:
{{- include "gitlab-clickhouse-exporter.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "gitlab-clickhouse-exporter.selectorLabels" . | nindent 4 }}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "gitlab-clickhouse-exporter.serviceAccountName" . }}
labels:
{{- include "gitlab-clickhouse-exporter.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

57 changes: 57 additions & 0 deletions deploy/helm/gitlab-clickhouse-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Default values for gitlab-clickhouse-exporter.

image:
registry: docker.io
repository: cluttrdev/gitlab-clickhouse-exporter
# Overrides the image tag whose default is the chart appVersion.
tag: ""
pullPolicy: Always

podAnnotations: {}

podSecurityContext:
seccompProfile:
type: RuntimeDefault

securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000

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

service:
type: ClusterIP
port: 80

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

nodeSelector: {}

tolerations: []

affinity: {}

env: []

# ---

config: {}

0 comments on commit 84af351

Please sign in to comment.