Skip to content

Commit

Permalink
publish helm chart for acceptance-tests cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
edevosc2c committed Nov 8, 2024
1 parent cfdcbf4 commit c81387a
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 0 deletions.
23 changes: 23 additions & 0 deletions acceptance-tests/.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/
24 changes: 24 additions & 0 deletions acceptance-tests/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: acceptance-tests
description: A Helm chart for launching "tests non regression"

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.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.
# It is recommended to use it with quotes.
appVersion: "1.0.0"
62 changes: 62 additions & 0 deletions acceptance-tests/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "acceptance-tests.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 "acceptance-tests.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 "acceptance-tests.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "acceptance-tests.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "acceptance-tests.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
88 changes: 88 additions & 0 deletions acceptance-tests/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{- $job := .Values.job -}}
{{- $jobConfiguration := .Values.configuration -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "acceptance-tests.fullname" . }}
labels:
{{- include "acceptance-tests.labels" . | nindent 4 }}
spec:
schedule: {{ $job.schedule | quote }}
successfulJobsHistoryLimit: {{ $job.successfulJobsHistoryLimit }}
jobTemplate:
spec:
ttlSecondsAfterFinished: 86400
template:
metadata:
labels:
{{- include "acceptance-tests.labels" . | nindent 12 }}
spec:
{{- with $job.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with $job.podSecurityContext }}
securityContext:
{{ toYaml . | nindent 10 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ $job.image.repository }}:{{ $job.image.tag }}"
imagePullPolicy: {{ $job.image.pullPolicy }}
{{- with .Values.podVolumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
- name: RENATER_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "acceptance-tests.fullname" . }}-job-secrets
key: renaterUsername
- name: RENATER_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "acceptance-tests.fullname" . }}-job-secrets
key: renaterPassword
- name: RENATER_IDP_ID
value: {{ $jobConfiguration.renater.idpId | quote }}
- name: BASE_URL
value: {{ $jobConfiguration.georchestra.baseUrl | quote }}
- name: LOCAL_ACCOUNT_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "acceptance-tests.fullname" . }}-job-secrets
key: georchestraLocalAccountUsername
- name: LOCAL_ACCOUNT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "acceptance-tests.fullname" . }}-job-secrets
key: georchestraLocalAccountPassword
{{- with $job.extraEnv }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $job.resources }}
resources:
{{ toYaml . | nindent 12 }}
{{- end }}
{{- with $job.securityContext }}
securityContext:
{{ toYaml . | nindent 12 }}
{{- end }}
restartPolicy: {{ $job.restartPolicy }}
{{- with .Values.podVolumeMounts }}
volumes:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with $job.nodeSelector }}
nodeSelector:
{{ toYaml . | nindent 10 }}
{{- end }}
{{- with $job.affinity }}
affinity:
{{ toYaml . | nindent 10 }}
{{- end }}
{{- with $job.tolerations }}
tolerations:
{{ toYaml . | nindent 10 }}
{{- end }}
13 changes: 13 additions & 0 deletions acceptance-tests/templates/job-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- $jobConfiguration := .Values.configuration -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "acceptance-tests.fullname" . }}-job-secrets
labels:
{{- include "acceptance-tests.labels" . | nindent 4 }}
type: Opaque
data:
georchestraLocalAccountUsername: {{ required ".Values.configuration.georchestra.localAccount.username is required." $jobConfiguration.georchestra.localAccount.username | b64enc | quote }}
georchestraLocalAccountPassword: {{ required ".Values.configuration.georchestra.localAccount.password is required" $jobConfiguration.georchestra.localAccount.password | b64enc | quote }}
renaterUsername: {{ required ".Values.configuration.renater.username is required." $jobConfiguration.renater.username | b64enc | quote }}
renaterPassword: {{ required ".Values.configuration.renater.password is required" $jobConfiguration.renater.password | b64enc | quote }}
59 changes: 59 additions & 0 deletions acceptance-tests/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
nameOverride: ""
fullnameOverride: ""

podVolumeMounts:
volumeMounts:
- name: reports-output
mountPath: /output
# the application will work in the folder /output/public/non-regression
# change it if needed
subPath: public/non-regression

volumes:
- name: "reports-output"
persistentVolumeClaim:
claimName: apache-nas

job:
image:
repository: ghcr.io/camptocamp/mel-docker-images/acceptance-tests
pullPolicy: Always
tag: "latest"
schedule: "0 13 * * *"
successfulJobsHistoryLimit: 3
restartPolicy: Never
nodeSelector: {}
tolerations: []
affinity: {}
extraEnv: {}
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: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
podSecurityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
securityContext: {}
imagePullSecrets: []

configuration:
renater:
username: testuser
password: testuser
idpId: "My IDP integration"
georchestra:
baseUrl: "http://mygeorchestra.com"
localAccount:
username: myusername
password: mypassword

0 comments on commit c81387a

Please sign in to comment.