Skip to content

Commit

Permalink
feat: add charts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderBabel committed Aug 19, 2022
1 parent 5483e85 commit 9aac6b4
Show file tree
Hide file tree
Showing 32 changed files with 1,998 additions and 0 deletions.
26 changes: 26 additions & 0 deletions charts/matomo/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
# OWNERS file for Kubernetes
OWNERS

package.json
.releaserc.json
69 changes: 69 additions & 0 deletions charts/matomo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# [matomo-v1.5.0](https://github.com/MakairaIO/helm-charts/compare/matomo-v1.4.0...matomo-v1.5.0) (2021-12-19)


### Features

* add CoreVue plugin ([94bd10e](https://github.com/MakairaIO/helm-charts/commit/94bd10e72073ecca80ed012e2db42c87f2ea90fa))

# [matomo-v1.4.0](https://github.com/MakairaIO/helm-charts/compare/matomo-v1.3.1...matomo-v1.4.0) (2021-10-14)


### Features

* **ingress:** add support for networking.k8s.io/v1 ([832ae57](https://github.com/MakairaIO/helm-charts/commit/832ae579ce7b2bee88f95e96a6ce60a31d8313bd))

# [matomo-v1.3.1](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.3.0...matomo-v1.3.1) (2021-05-11)


### Bug Fixes

* **plugin-download:** add missing plugin name split ([f475d24](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/f475d24dfc36acc1efc91a60e300eec889e299ab))

# [matomo-v1.3.0](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.2.3...matomo-v1.3.0) (2021-05-11)


### Features

* **plugin-download:** add support for plugin version pinning ([e6bb2a7](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/e6bb2a7a82e0fe962e95b6c0f6ca7f08177872b7))

# [matomo-v1.2.3](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.2.2...matomo-v1.2.3) (2021-03-10)


### Bug Fixes

* **hpa:** change order of metrics ([422c77e](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/422c77ef03f2d830005601026b1e81791d784644))

# [matomo-v1.2.2](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.2.1...matomo-v1.2.2) (2021-03-10)


### Bug Fixes

* **hpa:** update yaml format ([b82d1f7](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/b82d1f7baa9d2e418ffce9f79f3bd8de16a69924))

# [matomo-v1.2.1](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.2.0...matomo-v1.2.1) (2021-03-10)


### Bug Fixes

* **hpa:** switch memory to percentage based ([0eabdf8](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/0eabdf88e7a68ac21a0a17b5165a7d03e044ad6c))

# [matomo-v1.2.0](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.1.0...matomo-v1.2.0) (2021-03-10)


### Features

* **hpa:** add support for memory based scaling ([8bd7efb](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/8bd7efb0e8020e10534f2921b72d5a2da74e735d))

# [matomo-v1.1.0](https://gitlab.marmalade.de/makaira/kubernetes/charts/compare/matomo-v1.0.0...matomo-v1.1.0) (2021-03-08)


### Features

* **matomo:** add description ([38376e3](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/38376e36d008b6a6244d69215c39c43a228ead27))

# matomo-v1.0.0 (2021-03-08)


### Features

* **ci:** add release pipeline ([3fe8eab](https://gitlab.marmalade.de/makaira/kubernetes/charts/commit/3fe8eabb75746ae75be826cc79b64c210acefef0))
10 changes: 10 additions & 0 deletions charts/matomo/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: matomo
version: 1.5.0
appVersion: 4.0.5
description: Matomo is an Analytics Tools for Online Shops.
dependencies:
- name: mysql
version: ^0.1.0
repository: https://storage.googleapis.com/t3n-helm-charts/
condition: mysql.enabled
15 changes: 15 additions & 0 deletions charts/matomo/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Source: [t3n/helm-charts](https://github.com/t3n/helm-charts/tree/master/matomo) Commit: [cf1c7d2](https://github.com/t3n/helm-charts/commit/cf1c7d2b166c5d52caed6e4e96619aab710aa824)

Changes made to original chart:
- Add `plugin-download.sh` in [scripts](scripts)
- Add `plugins` and `config` section in [values.yaml](values.yaml)
- Add `config.ini.php` in [templates/secret-config.yaml](templates/secret-config.yaml)
- Add `initContainers` in [templates/deployment.yaml](templates/deployment.yaml), [templates/cronjob-archive.yaml](templates/cronjob-archive.yaml) and [templates/_pod.tpl](templates/_pod.tpl)
- Add additional `volumes` and `volumeMounts` in [templates/deployment.yaml](templates/deployment.yaml), [templates/cronjob-archive.yaml](templates/cronjob-archive.yaml) and [templates/_pod.tpl](templates/_pod.tpl)
- Add `license_key` to values.yaml and [templates/secret.yaml](templates/secret.yaml)
- Edit `update-ipdb.sh` in [scripts](scripts) to support the maxmind database
- Add `geoip` section to values.yaml
- Add `MATOMO_MAXMIND_LICENSE` to [templates/secret.yaml](templates/secret.yaml)
- Add `backoffLimit` and `activeDeadlineSeconds` for archive job [templates/cronjob-archive.yaml](templates/cronjob-archive.yaml)
- Add `_pod.tpl` in order to make code more reusable for [templates/deployment.yaml](templates/deployment.yaml), [templates/cronjob-archive.yaml](templates/cronjob-archive.yaml)
- Update [templates/horizontalpodautoscaler.yaml](templates/horizontalpodautoscaler.yaml) to `v2beta2` and add memory based scaling
32 changes: 32 additions & 0 deletions charts/matomo/scripts/matomo-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

echo ""
echo "------------------------------"
echo ""
echo "Running: matomo-init.sh"

echo "Copy config.ini.php into place"

cp /var/www/html/config/config.ini.php /config/config.ini.php

echo "Adjusting config permissions..."

chown 82:82 /config/config.ini.php
chmod 440 /config/config.ini.php

echo "Checking misc items"

if [ -f "/files/favicon.png" ]; then
echo "Copying favicon..."
base64 -d /files/favicon.png > /config/favicon.png
fi

if [ -f "/files/logo.png" ]; then
echo "Copying logo..."
base64 -d /files/logo.png > /config/logo.png
fi

if [ -f "/files/logo-header.png" ]; then
echo "Copying logo-header..."
base64 -d /files/logo-header.png > /config/logo-header.png
fi
52 changes: 52 additions & 0 deletions charts/matomo/scripts/plugin-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

echo ""
echo "------------------------------"
echo ""
echo "Running: plugin-download.sh"

# Get your license key @ https://shop.matomo.org/my-account/

if [ -z "$MATOMO_LICENSE_KEY" ]; then
echo "Please check your Matomo Marketplace license key is correct, and try again." >&2
exit 1
fi

if [ -z "$MATOMO_VERSION" ]; then
echo "No version supplied. Please supply a Matomo version an try again." >&2
exit 1
else
MATOMO_CORE_VERSION=$1
fi

PLUGINS_TO_DOWNLOAD="{{ join " " .Values.plugins.custom.plugins }}"

for PLUGIN in $PLUGINS_TO_DOWNLOAD; do
IFS=':' read -r PLUGIN_NAME PLUGIN_VERSION <<EOF
$PLUGIN
EOF

echo "Downloading plugin $PLUGIN_NAME..."
if curl -f -sS --data "access_token=$MATOMO_LICENSE_KEY" "https://plugins.matomo.org/api/2.0/plugins/$PLUGIN_NAME/download/${PLUGIN_VERSION:-latest}?matomo=$MATOMO_CORE_VERSION" >"plugins-$PLUGIN_NAME.zip"; then
echo "OK"
else
echo "Please check your Matomo Marketplace license key is correct, and try again." >&2
exit 1
fi
done

echo "Extract all packages in the /custom-plugins/ directory..."

for PLUGIN in $PLUGINS_TO_DOWNLOAD; do
IFS=':' read -r PLUGIN_NAME PLUGIN_VERSION <<EOF
$PLUGIN
EOF

unzip -q -o "plugins-$PLUGIN_NAME" -d /custom-plugins/
done

echo "Adjusting permissions..."

chown -R 82:82 /custom-plugins

echo "Done extracting files!"
19 changes: 19 additions & 0 deletions charts/matomo/scripts/update-ipdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

echo ""
echo "------------------------------"
echo ""
echo "Running: update-ipdb.sh"

databases="{{ join " " .Values.geoip.databases }}"
for database in $databases; do
printf "Downloading MaxMind %s Database\\n" "$database"
wget -O download.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=$database&license_key=$MATOMO_MAXMIND_LICENSE&suffix=tar.gz"
printf "Unzipping...\\n"
tar -xf download.tar.gz
printf "Moving file...\\n"
mv "$database""_*/$database." "/geoip/$database."
printf "Setting permission for %s\\n" "$database"
chown 82:82 "/geoip/$database."
done

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

{{/*
Common labels
*/}}
{{- define "matomo.labels" -}}
app.kubernetes.io/name: matomo
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "matomo.chart" . }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "matomo.selector" -}}
app.kubernetes.io/name: matomo
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "matomo.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "matomo.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}


{{/*
Create the name of the database host to use
*/}}
{{- define "matomo.databaseHost" -}}
{{- if .Values.mysql.enabled -}}
{{- if .Values.mysql.fullnameOverride -}}
{{- .Values.mysql.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default "mysql" .Values.mysql.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- printf .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{ .Values.database.host }}
{{- end -}}
{{- end -}}
Loading

0 comments on commit 9aac6b4

Please sign in to comment.