Skip to content

Commit 256ced4

Browse files
committed
First commit with basic workflow and templates
1 parent 153efae commit 256ced4

File tree

12 files changed

+471
-0
lines changed

12 files changed

+471
-0
lines changed

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/release.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release Charts
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
11+
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
12+
permissions:
13+
contents: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Configure Git
22+
run: |
23+
git config user.name "$GITHUB_ACTOR"
24+
git config user.email "[email protected]"
25+
26+
- name: Install Helm
27+
uses: azure/setup-helm@v4
28+
env:
29+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
30+
31+
- name: Run chart-releaser
32+
uses: helm/[email protected]
33+
env:
34+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

charts/part-db/.helmignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj

charts/part-db/Chart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
description: Part-DB inventory management system.
3+
engine: gotpl
4+
maintainers:
5+
6+
name: Jan Böhmer
7+
8+
name: Andrey Ivanov
9+
name: part-db
10+
version: 0.0.1

charts/part-db/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Part-DB
2+
3+
## TL;DR;
4+
5+
```console
6+
$ helm install part-db
7+
```
8+
9+
## Introduction
10+
11+
This chart bootstraps an part-db service deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
12+
13+
## Prerequisites
14+
- Kubernetes 1.4+ with Beta APIs enabled
15+
16+
## Installing the Chart
17+
18+
To install the chart with the release name `my-release`:
19+
20+
```console
21+
$ helm install --name my-release part-db
22+
```
23+
24+
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.
25+
26+
> **Tip**: List all releases using `helm list`
27+
28+
## Uninstalling the Chart
29+
30+
To uninstall/delete the `my-release` deployment:
31+
32+
```console
33+
$ helm delete my-release
34+
```
35+
36+
The command removes all the Kubernetes components associated with the chart and deletes the release.
37+
38+
## Configuration
39+
40+
The following table lists the configurable parameters of the part-db chart and their default values.
41+
42+
Parameter | Description | Default
43+
--- | --- | ---
44+
45+
```console
46+
$ helm install part-db --name my-release \
47+
--set controller.stats.enabled=true
48+
```
49+
50+
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
51+
52+
```console
53+
$ helm install part-db --name my-release -f values.yaml
54+
```
55+
56+
> **Tip**: You can use the default [values.yaml](values.yaml)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "app.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "app.fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}
17+
18+
{{/*
19+
Create chart name and version as used by the chart label.
20+
*/}}
21+
{{- define "app.chart" -}}
22+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
25+
{{/*
26+
Return the appropriate apiVersion for deployment.
27+
*/}}
28+
{{- define "app.deployment.apiVersion" -}}
29+
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
30+
{{- print "extensions/v1beta1" -}}
31+
{{- else -}}
32+
{{- print "apps/v1" -}}
33+
{{- end -}}
34+
{{- end -}}
35+
36+
{{/*
37+
Common labels
38+
*/}}
39+
{{- define "app.labels" -}}
40+
app.kubernetes.io/name: {{ template "app.name" . }}
41+
helm.sh/chart: {{ template "app.chart" . }}
42+
app.kubernetes.io/instance: {{ .Release.Name }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end -}}
45+
46+
{{/*
47+
Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
48+
*/}}
49+
{{- define "app.matchLabels" -}}
50+
app.kubernetes.io/name: {{ template "app.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end -}}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
apiVersion: {{ template "app.deployment.apiVersion" . }}
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "app.fullname" . }}
5+
labels: {{- include "app.labels" . | nindent 4 }}
6+
spec:
7+
selector:
8+
matchLabels: {{- include "app.matchLabels" . | nindent 6 }}
9+
replicas: 1
10+
strategy:
11+
rollingUpdate:
12+
maxSurge: 1 # as an absolute number of replicas
13+
maxUnavailable: 100% # as % of replicas
14+
type: RollingUpdate
15+
template:
16+
metadata:
17+
labels: {{- include "app.labels" . | nindent 8 }}
18+
annotations:
19+
spec:
20+
{{- if .Values.image.pullSecrets }}
21+
imagePullSecrets:
22+
{{- range .Values.image.pullSecrets }}
23+
- name: {{ . }}
24+
{{- end}}
25+
{{- end }}
26+
containers:
27+
- name: {{ template "app.fullname" . }}
28+
image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
29+
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
30+
env:
31+
- name: APP_ENV
32+
value: "docker"
33+
- name: DEFAULT_URI
34+
value: "{{ required "Root URL value required" .Values.app.url }}"
35+
- name: DB_USERNAME
36+
value: {{ default "pdbadm" .Values.db.user | quote }}
37+
- name: DB_PASSWORD
38+
valueFrom:
39+
secretKeyRef:
40+
name: {{ template "app.fullname" . }}
41+
key: db-password
42+
- name: DB_DATABASE
43+
value: {{ default "partdb" .Values.db.db | quote }}
44+
- name: DB_TYPE
45+
value: {{ default "sqlite" .Values.app.db_type | quote }}
46+
- name: DATABASE_URL
47+
value: "$(DB_TYPE)://$(DB_USERNAME):$(DB_PASSWORD)@{{ required "Database server host value required" .Values.db.host }}/$(DB_DATABASE)"
48+
- name: DEFAULT_LANG
49+
value: {{ default "en" .Values.app.lang | quote }}
50+
- name: DEFAULT_TIMEZONE
51+
value: {{ default "" .Values.app.tz | quote }}
52+
- name: BASE_CURRENCY
53+
value: {{ default "EUR" .Values.app.currency | quote }}
54+
- name: ALLOW_ATTACHMENT_DOWNLOADS
55+
value: "0"
56+
- name: USE_GRAVATAR
57+
value: "0"
58+
- name: MAX_ATTACHMENT_FILE_SIZE
59+
value: "100M"
60+
- name: ENFORCE_CHANGE_COMMENTS_FOR
61+
value: {{ default "" .Values.app.enforce_change_comments | quote }}
62+
- name: CHECK_FOR_UPDATES
63+
value: "0"
64+
- name: HISTORY_SAVE_CHANGED_FIELDS
65+
value: "true"
66+
- name: HISTORY_SAVE_CHANGED_DATA
67+
value: "true"
68+
- name: HISTORY_SAVE_REMOVED_DATA
69+
value: "true"
70+
{{- if .Values.serviceLoadBalancerSourceRanges }}
71+
- name: TRUSTED_PROXIES
72+
value: {{ join "," .Values.serviceLoadBalancerSourceRanges | quote }}
73+
{{- end }}
74+
75+
76+
{{- if .Values.smtp }}
77+
- name: SMTP_HOST
78+
value: {{ default "" .Values.smtp.host | quote }}
79+
- name: SMTP_PORT
80+
value: {{ required "SMTP port value required" .Values.smtp.port | quote }}
81+
{{- if .Values.smtp.user }}
82+
- name: SMTP_USERNAME
83+
value: {{ .Values.smtp.user | quote }}
84+
- name: SMTP_PASSWORD
85+
valueFrom:
86+
secretKeyRef:
87+
name: {{ template "app.fullname" . }}
88+
key: smtp-password
89+
- name: MAILER_DSN
90+
value: "{{ required "SMTP protocol value required" .Values.smtp.protocol }}://$(SMTP_USERNAME):$(SMTP_PASSWORD)@$(SMTP_HOST):$(SMTP_PORT)"
91+
{{- else }}
92+
- name: MAILER_DSN
93+
value: "{{ required "SMTP protocol value required" .Values.smtp.protocol }}://$(SMTP_HOST):$(SMTP_PORT)"
94+
{{- end }}
95+
{{- end }}
96+
97+
{{- if .Values.extraVars }}
98+
{{ toYaml .Values.extraVars | indent 8 }}
99+
{{- end }}
100+
ports:
101+
- name: http
102+
containerPort: 80
103+
# livenessProbe:
104+
# httpGet:
105+
# path: /healthz
106+
# port: http
107+
# initialDelaySeconds: 120
108+
# timeoutSeconds: 5
109+
# readinessProbe:
110+
# httpGet:
111+
# path: /healthz
112+
# port: http
113+
# initialDelaySeconds: 5
114+
# timeoutSeconds: 1
115+
volumeMounts:
116+
- name: pub
117+
mountPath: /var/www/html/uploads
118+
subPath: uploads
119+
- name: pub
120+
mountPath: /var/www/html/public/media
121+
subPath: public_media
122+
volumes:
123+
- name: pub
124+
persistentVolumeClaim:
125+
claimName: {{ template "app.fullname" . }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if .Values.ingress.enabled }}
2+
apiVersion: {{ required "A valid .Values.networkPolicyApiVersion entry required!" .Values.networkPolicyApiVersion }}
3+
kind: Ingress
4+
metadata:
5+
{{- if .Values.ingress.annotations }}
6+
annotations:
7+
{{ toYaml .Values.ingress.annotations | indent 4 }}
8+
{{- end }}
9+
{{- if .Values.ingress.labels }}
10+
labels:
11+
{{ toYaml .Values.ingress.labels | indent 4 }}
12+
{{- end }}
13+
name: {{ template "app.fullname" . }}
14+
spec:
15+
{{- if .Values.ingress.ingressClassName }}
16+
ingressClassName: {{ .Values.ingress.ingressClassName }}
17+
{{- end }}
18+
rules:
19+
- host: {{ .Values.ingress.hostname | quote }}
20+
http:
21+
paths:
22+
- path: /
23+
backend:
24+
service:
25+
name: {{ template "app.fullname" . }}
26+
port:
27+
number: 80
28+
pathType: Prefix
29+
{{- if .Values.ingress.tls }}
30+
tls:
31+
{{ toYaml .Values.ingress.tls | indent 4 }}
32+
{{- end -}}
33+
{{- end }}

charts/part-db/templates/pvc.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{- if not .Values.persistence.existingClaim }}
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: {{ template "app.fullname" . }}
6+
labels:
7+
app: {{ template "app.fullname" . }}
8+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
spec:
12+
accessModes:
13+
- {{ .Values.persistence.accessMode | quote }}
14+
resources:
15+
requests:
16+
storage: {{ .Values.persistence.size | quote }}
17+
{{- if .Values.persistence.storageClass }}
18+
{{- if (eq "-" .Values.persistence.storageClass) }}
19+
storageClassName: ""
20+
{{- else }}
21+
storageClassName: "{{ .Values.persistence.storageClass }}"
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ template "app.fullname" . }}
5+
labels:
6+
app: {{ template "app.fullname" . }}
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
8+
release: "{{ .Release.Name }}"
9+
heritage: "{{ .Release.Service }}"
10+
type: Opaque
11+
data:
12+
{{ if .Values.db.password }}
13+
db-password: {{ default "" .Values.db.password | b64enc | quote }}
14+
{{ else }}
15+
db-password: {{ randAlphaNum 10 | b64enc | quote }}
16+
{{ end }}
17+
{{ if .Values.smtp }}
18+
smtp-password: {{ default "" .Values.smtp.password | b64enc | quote }}
19+
{{ end }}

0 commit comments

Comments
 (0)