Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add a Helm Chart for Vigilo #21

Merged
merged 9 commits into from
Jan 19, 2024
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist
bin
.env
lh-config.js
urls.json
urls.json
helm
23 changes: 23 additions & 0 deletions helm/vigilo/.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 helm/vigilo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: vigilo
description: A Helm chart for Kubernetes

# 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.1.0"
46 changes: 46 additions & 0 deletions helm/vigilo/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "vigilo.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 "vigilo.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 }}

{{/* Generate a default name for the Lighthouse Config ConfigMap */}}
{{- define "vigilo.lighthouseConfigCM.name" -}}
{{- default (printf "%s-lighthouse-cm" (include "vigilo.fullname" .)) .Values.configs.lighthouse.configMapName | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/* Generate a default name for the Urls ConfigMap */}}
{{- define "vigilo.urlsCM.name" -}}
{{- default (printf "%s-urls-cm" (include "vigilo.fullname" .)) .Values.configs.urls.configMapName | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/* Generate a default name for the DataDog Secret */}}
{{- define "vigilo.datadogSecret.name" -}}
{{- default (printf "%s-datadog-secret" (include "vigilo.fullname" .)) .Values.configs.datadogSecret.name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "vigilo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
39 changes: 39 additions & 0 deletions helm/vigilo/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "vigilo.fullname" . }}-cronjob
spec:
schedule: "{{ .Values.cronjob.schedule }}"
concurrencyPolicy: {{ .Values.cronjob.concurrencyPolicy }}
successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }}
failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }}
jobTemplate:
spec:
template:
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: urls-volume
configMap:
name: {{ include "vigilo.urlsCM.name" . }}
- name: lighthouse-config-volume
configMap:
name: {{ include "vigilo.lighthouseConfigCM.name" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default "latest" }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- name: urls-volume
mountPath: ./app/dist/urls.json
subPath: urls.json
- name: lighthouse-config-volume
mountPath: ./app/dist/lh-config.js
subPath: lh-config.js
envFrom:
- secretRef:
name: {{ include "vigilo.datadogSecret.name" . }}
restartPolicy: OnFailure
7 changes: 7 additions & 0 deletions helm/vigilo/templates/lighthouse-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "vigilo.lighthouseConfigCM.name" . }}
data:
lh-config.js: |
{{ .Values.configs.lighthouse.lighthouseConfig | nindent 6 }}
14 changes: 14 additions & 0 deletions helm/vigilo/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.configs.datadogSecret.create }}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ include "vigilo.datadogSecret.name" . }}
data:
{{- with .Values.configs.datadogSecret.keys.apiKey }}
DD_API_KEY: {{ . | b64enc | quote }}
{{- end }}
{{- with .Values.configs.datadogSecret.keys.appKey }}
DD_APP_KEY: {{ . | b64enc | quote }}
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions helm/vigilo/templates/urls-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "vigilo.urlsCM.name" . }}
data:
urls.json: |
{{- toJson .Values.configs.urls.pages | nindent 6 }}
56 changes: 56 additions & 0 deletions helm/vigilo/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
nameOverride: ""
fullnameOverride: ""

image:
# Vigilo is not currently available on Docker Hub
# You will need to build and push your own image to a registry
repository: ""
pullPolicy: Always
# Overrides the image tag whose default is latest
tag: ""

imagePullSecrets:
- name: ""

cronjob:
schedule: "*/10 * * * *" # Every 10 minutes
concurrencyPolicy: Forbid # skip if previous job is still running
successfulJobsHistoryLimit: 0 # keep no history of successful jobs
failedJobsHistoryLimit: 1 # keep only one failed job

configs:
datadogSecret:
# The name of the secret containing the Datadog API keys
name: ""
# If the secret already exists, then disable create
create: true
keys:
apiKey: ""
appKey: ""

urls:
configMapName: ""
# Represents the content of the urls.json file
pages:
Test: ["https://www.wikipedia.org"]

lighthouse:
configMapName: ""
# Represents the content of the lh-config.js file
lighthouseConfig: |
export default {
extends: 'lighthouse:default',
settings: {
onlyAudits: [
"largest-contentful-paint",
"first-contentful-paint",
"cumulative-layout-shift",
"total-blocking-time",
"speed-index",
"total-byte-weight",
"server-response-time",
"is-crawlable",
"screenshot-thumbnails"
]
}
}