Skip to content

Commit

Permalink
First commit with basic workflow and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jbtronics committed Aug 18, 2024
1 parent 153efae commit 256ced4
Show file tree
Hide file tree
Showing 12 changed files with 471 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
34 changes: 34 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Charts

on:
push:
branches:
- main

jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
21 changes: 21 additions & 0 deletions charts/part-db/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
10 changes: 10 additions & 0 deletions charts/part-db/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
description: Part-DB inventory management system.
engine: gotpl
maintainers:
- email: [email protected]
name: Jan Böhmer
- email: [email protected]
name: Andrey Ivanov
name: part-db
version: 0.0.1
56 changes: 56 additions & 0 deletions charts/part-db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Part-DB

## TL;DR;

```console
$ helm install part-db
```

## Introduction

This chart bootstraps an part-db service deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites
- Kubernetes 1.4+ with Beta APIs enabled

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm install --name my-release part-db
```

The command deploys ednme on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the part-db chart and their default values.

Parameter | Description | Default
--- | --- | ---

```console
$ helm install part-db --name my-release \
--set controller.stats.enabled=true
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

```console
$ helm install part-db --name my-release -f values.yaml
```

> **Tip**: You can use the default [values.yaml](values.yaml)
52 changes: 52 additions & 0 deletions charts/part-db/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "app.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).
*/}}
{{- define "app.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

{{/*
Return the appropriate apiVersion for deployment.
*/}}
{{- define "app.deployment.apiVersion" -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

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

{{/*
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
*/}}
{{- define "app.matchLabels" -}}
app.kubernetes.io/name: {{ template "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
125 changes: 125 additions & 0 deletions charts/part-db/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
apiVersion: {{ template "app.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "app.fullname" . }}
labels: {{- include "app.labels" . | nindent 4 }}
spec:
selector:
matchLabels: {{- include "app.matchLabels" . | nindent 6 }}
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1 # as an absolute number of replicas
maxUnavailable: 100% # as % of replicas
type: RollingUpdate
template:
metadata:
labels: {{- include "app.labels" . | nindent 8 }}
annotations:
spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
- name: {{ template "app.fullname" . }}
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
env:
- name: APP_ENV
value: "docker"
- name: DEFAULT_URI
value: "{{ required "Root URL value required" .Values.app.url }}"
- name: DB_USERNAME
value: {{ default "pdbadm" .Values.db.user | quote }}
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "app.fullname" . }}
key: db-password
- name: DB_DATABASE
value: {{ default "partdb" .Values.db.db | quote }}
- name: DB_TYPE
value: {{ default "sqlite" .Values.app.db_type | quote }}
- name: DATABASE_URL
value: "$(DB_TYPE)://$(DB_USERNAME):$(DB_PASSWORD)@{{ required "Database server host value required" .Values.db.host }}/$(DB_DATABASE)"
- name: DEFAULT_LANG
value: {{ default "en" .Values.app.lang | quote }}
- name: DEFAULT_TIMEZONE
value: {{ default "" .Values.app.tz | quote }}
- name: BASE_CURRENCY
value: {{ default "EUR" .Values.app.currency | quote }}
- name: ALLOW_ATTACHMENT_DOWNLOADS
value: "0"
- name: USE_GRAVATAR
value: "0"
- name: MAX_ATTACHMENT_FILE_SIZE
value: "100M"
- name: ENFORCE_CHANGE_COMMENTS_FOR
value: {{ default "" .Values.app.enforce_change_comments | quote }}
- name: CHECK_FOR_UPDATES
value: "0"
- name: HISTORY_SAVE_CHANGED_FIELDS
value: "true"
- name: HISTORY_SAVE_CHANGED_DATA
value: "true"
- name: HISTORY_SAVE_REMOVED_DATA
value: "true"
{{- if .Values.serviceLoadBalancerSourceRanges }}
- name: TRUSTED_PROXIES
value: {{ join "," .Values.serviceLoadBalancerSourceRanges | quote }}
{{- end }}


{{- if .Values.smtp }}
- name: SMTP_HOST
value: {{ default "" .Values.smtp.host | quote }}
- name: SMTP_PORT
value: {{ required "SMTP port value required" .Values.smtp.port | quote }}
{{- if .Values.smtp.user }}
- name: SMTP_USERNAME
value: {{ .Values.smtp.user | quote }}
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "app.fullname" . }}
key: smtp-password
- name: MAILER_DSN
value: "{{ required "SMTP protocol value required" .Values.smtp.protocol }}://$(SMTP_USERNAME):$(SMTP_PASSWORD)@$(SMTP_HOST):$(SMTP_PORT)"
{{- else }}
- name: MAILER_DSN
value: "{{ required "SMTP protocol value required" .Values.smtp.protocol }}://$(SMTP_HOST):$(SMTP_PORT)"
{{- end }}
{{- end }}

{{- if .Values.extraVars }}
{{ toYaml .Values.extraVars | indent 8 }}
{{- end }}
ports:
- name: http
containerPort: 80
# livenessProbe:
# httpGet:
# path: /healthz
# port: http
# initialDelaySeconds: 120
# timeoutSeconds: 5
# readinessProbe:
# httpGet:
# path: /healthz
# port: http
# initialDelaySeconds: 5
# timeoutSeconds: 1
volumeMounts:
- name: pub
mountPath: /var/www/html/uploads
subPath: uploads
- name: pub
mountPath: /var/www/html/public/media
subPath: public_media
volumes:
- name: pub
persistentVolumeClaim:
claimName: {{ template "app.fullname" . }}
33 changes: 33 additions & 0 deletions charts/part-db/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.ingress.enabled }}
apiVersion: {{ required "A valid .Values.networkPolicyApiVersion entry required!" .Values.networkPolicyApiVersion }}
kind: Ingress
metadata:
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
{{- if .Values.ingress.labels }}
labels:
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- end }}
name: {{ template "app.fullname" . }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end }}
rules:
- host: {{ .Values.ingress.hostname | quote }}
http:
paths:
- path: /
backend:
service:
name: {{ template "app.fullname" . }}
port:
number: 80
pathType: Prefix
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end }}
24 changes: 24 additions & 0 deletions charts/part-db/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if not .Values.persistence.existingClaim }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "app.fullname" . }}
labels:
app: {{ template "app.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/part-db/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "app.fullname" . }}
labels:
app: {{ template "app.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
data:
{{ if .Values.db.password }}
db-password: {{ default "" .Values.db.password | b64enc | quote }}
{{ else }}
db-password: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
{{ if .Values.smtp }}
smtp-password: {{ default "" .Values.smtp.password | b64enc | quote }}
{{ end }}
Loading

0 comments on commit 256ced4

Please sign in to comment.