Skip to content

Commit

Permalink
Merge pull request #1 from MammatusPHP/initial-set-up
Browse files Browse the repository at this point in the history
Initial set up
  • Loading branch information
WyriHaximus authored Jun 8, 2024
2 parents 1126c07 + d37a6eb commit da24f12
Show file tree
Hide file tree
Showing 15 changed files with 387 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: WyriHaximus
8 changes: 8 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", ":widenPeerDependencies", ":rebaseStalePrs"],
"labels": [ "Dependencies 📦"],
"recreateClosed": true,
"allowScripts": true,
"allowPlugins": true
}
33 changes: 33 additions & 0 deletions .github/workflows/helm-charts-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "helm-charts/release"

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch history
run: git fetch --prune --unshallow

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# See https://github.com/helm/chart-releaser-action/issues/6
- name: Install Helm
run: |
curl -fsSLo get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
env:
CR_TOKEN: "${{ secrets.CR_TOKEN }}"
46 changes: 46 additions & 0 deletions .github/workflows/helm-charts-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "helm-charts/test"

on: pull_request

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch history
run: git fetch --prune --unshallow
- name: Install Chart Tester
uses: helm/chart-testing-action@v2.6.1
- name: Lint charts
id: lint
run: ct lint --all

test:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
k8s:
- "1.28"
- "1.29"
- "1.30"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch history
run: git fetch --prune --unshallow

- name: Create kind cluster
uses: helm/kind-action@v1.8.0
with:
installLocalPathProvisioner: true # Only build a kind cluster if there are chart changes to test.
node_image: "kindest/node:v${{ matrix.k8s }}.0"
config: etc/kind.yaml
- run: kubectl get nodes
- name: Install Chart Tester
uses: helm/chart-testing-action@v2.6.1
- name: Test charts
run: ct install
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/**/charts
22 changes: 22 additions & 0 deletions charts/mammatus/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
.vscode/
10 changes: 10 additions & 0 deletions charts/mammatus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: mammatus
description: MammatusPHP Chart
type: application
version: 0.0.1
appVersion: 0.0.1
maintainers:
- name: WyriHaximus
email: helm@ceesjankiewiet.nl
url: https://wyrihaximus.net/
64 changes: 64 additions & 0 deletions charts/mammatus/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mammatus.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 "mammatus.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 "mammatus.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

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

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

72 changes: 72 additions & 0 deletions charts/mammatus/templates/_pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{/* vim: set filetype=mustache: */}}
{{- define "mammatus.pod" -}}
containers:
- name: {{ .name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- php
- /opt/app/vendor/bin/{{ .command | default "mamatus"}}
{{- range .arguments }}
- "{{ . | replace "\\" "\\\\" }}"
{{- end }}
{{- include "mammatus.env" . | nindent 4 }}
resources:
limits:
cpu: {{ $.Values.resources.cpu }}
memory: {{ $.Values.resources.memmory }}
requests:
cpu: {{ $.Values.resources.cpu }}
memory: {{ $.Values.resources.memmory }}
{{- include "mammatus.volumeMounts" . | nindent 4 }}
{{ include "mammatus.volumes" . }}
{{- end }}

{{- define "mammatus.env" -}}
env:
- name: RELEASE_TAG
value: {{ .Chart.AppVersion }}
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: "metadata.name"
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: "metadata.namespace"
{{- if or .Values.env .Values.secrets }}
envFrom:
{{- end }}
{{- if .Values.secrets }}
{{- range .Values.secrets }}
- secretRef:
name: {{ .name }}
prefix: {{ .prefix }}
{{- end }}
{{- end }}
{{- if .Values.env }}
- configMapRef:
name: env
{{- end }}
{{- end -}}

{{- define "mammatus.volumeMounts" -}}
{{ if .Values.volumes }}
volumeMounts:
{{- range $name, $options := .Values.volumes }}
- name: {{ $name }}
{{ $options.volumeMountOptions | toYaml }}
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "mammatus.volumes" -}}
{{ if .Values.volumes }}
volumes:
{{- range $name, $options := .Values.volumes }}
- name: {{ $name }}
{{- $options.volumeOptions | toYaml | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}}

10 changes: 10 additions & 0 deletions charts/mammatus/templates/configuration/env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{ if $.Values.env }}
apiVersion: v1
kind: ConfigMap
metadata:
name: env
data:
{{ range $configName, $configValue := $.Values.env -}}
{{ $configName }}: {{ $configValue | quote }}
{{- end -}}
{{ end }}
26 changes: 26 additions & 0 deletions charts/mammatus/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- range .Values.mammatus.cronjobs }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .name }}
labels:
app.kubernetes.io/name: {{ include "mammatus.name" $ }}
app.kubernetes.io/instance: {{ .name }}
spec:
{{- if eq $.Chart.AppVersion "dev" }}
schedule: "* * * * *"
{{- else }}
schedule: "{{ .schedule }}"
{{- end }}
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 3
successfulJobsHistoryLimit: 3
jobTemplate:
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
{{- include "mammatus.pod" (dict "Chart" $.Chart "Values" $.Values "name" .name "arguments" .arguments) | nindent 10 }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/mammatus/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- range .Values.mammatus.deployments }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .name }}
labels:
app.kubernetes.io/name: {{ include "mammatus.name" $ }}
app.kubernetes.io/instance: {{ .name }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "mammatus.name" $ }}
app.kubernetes.io/instance: {{ .name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "mammatus.name" $ }}
app.kubernetes.io/instance: {{ .name }}
spec:
{{- include "mammatus.pod" (dict "Chart" $.Chart "Values" $.Values "name" .name "arguments" .arguments) | nindent 6 }}
{{- end }}
34 changes: 34 additions & 0 deletions charts/mammatus/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
mammatus:
cronjobs: []
# - name: some_job
# class: Some\Class\FQCN
# schedule: "0 3 * * *"
deployments: []
# - name: some_worker
# command: mammatus-queue
# arguments:
# - Some\Class\FQCN
# - name: some_service
# command: mammatus-vhost
# arguments:
# - Some\Class\FQCN
# post: 666

env: {}
# key: value
secrets: []
# - prefix: MQ_
# name: mq_creds

image:
repository: ghcr.io/LOGIN/REPO
pullPolicy: IfNotPresent

resources:
cpu: 100m
memmory: 256Mi

volumes: {}
# name:
# volumeMountOptions: {}
# volumeOptions: {}
7 changes: 7 additions & 0 deletions ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
remote: origin
target-branch: main
chart-dirs:
- charts
chart-repos:
- "WyriHaximusNet=https://helm.wyrihaximus.net"
debug: true
Loading

0 comments on commit da24f12

Please sign in to comment.