Skip to content

Commit

Permalink
feat: added persistence
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur committed Sep 12, 2024
1 parent da176aa commit 690593e
Show file tree
Hide file tree
Showing 10 changed files with 498 additions and 10 deletions.
4 changes: 1 addition & 3 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
brew "go"
brew "helm"
tap "norwoodj/tap"
brew "norwoodj/tap/helm-docs"
brew "kube-linter"
3 changes: 2 additions & 1 deletion anza-labs/lubelogger/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ apiVersion: v2
name: lubelogger
description: LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
type: application
version: 0.2.3
version: 0.3.0
appVersion: "v1.3.6"
maintainers:
- name: Mateusz Urbanek
email: [email protected]
url: http://linkedin.com/in/urbanekmateusz
45 changes: 43 additions & 2 deletions anza-labs/lubelogger/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# lubelogger

![Version: 0.2.3](https://img.shields.io/badge/Version-0.2.3-informational?style=flat) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat) ![AppVersion: v1.3.6](https://img.shields.io/badge/AppVersion-v1.3.6-informational?style=flat)
![Version: 0.3.0](https://img.shields.io/badge/Version-0.3.0-informational?style=flat) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat) ![AppVersion: v1.3.6](https://img.shields.io/badge/AppVersion-v1.3.6-informational?style=flat)

LubeLogger is a web-based vehicle maintenance and fuel mileage tracker

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Mateusz Urbanek | <[email protected]> | |
| Mateusz Urbanek | <[email protected]> | <http://linkedin.com/in/urbanekmateusz> |

## Values

Expand All @@ -22,6 +22,32 @@ LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
| config.LANG | string | `"en_US.UTF-8"` | Locale and Language Settings, this will affect how numbers, currencies, and dates are formatted. |
| config.LC_ALL | string | `"en_US.UTF-8"` | Same as above. Note that some languages don't have UTF-8 encodings. |
| config.LOGLEVEL | string | `"Information"` | Specifies the level of logs. Valid levels are `Trace`, `Debug`, `Information`, `Warning`, `Error`, `Critical` and `None`. Learn more at: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/ |
| config.translations | list | `["https://raw.githubusercontent.com/hargata/lubelog_translations/main/Europe/pl_PL.json"]` | Translations defines a list of URLs from which translation files will be fetched. These URLs point to JSON files containing translations for different languages or regions. The files will be downloaded by the init container and stored in the appropriate directory. |
| config.userConfig.AllowedHosts | string | `"*"` | Specifies allowed hosts for the application (use "*" to allow all hosts). |
| config.userConfig.DefaultTab | int | `8` | Sets the default tab to be shown when the application starts. |
| config.userConfig.EnableAuth | bool | `true` | Enables or disables authentication for the application. |
| config.userConfig.EnableAutoOdometerInsert | bool | `false` | Automatically inserts odometer readings based on previous data. |
| config.userConfig.EnableAutoReminderRefresh | bool | `false` | Automatically refreshes reminders without manual intervention. |
| config.userConfig.EnableCsvImports | bool | `true` | Enables the ability to import data from CSV files. |
| config.userConfig.EnableExtraFieldColumns | bool | `false` | Enables additional columns for extra field entries. |
| config.userConfig.EnableShopSupplies | bool | `false` | Enables tracking of shop supplies in transactions. |
| config.userConfig.HideSoldVehicles | bool | `false` | Hides vehicles marked as sold from the display. |
| config.userConfig.HideZero | bool | `false` | Determines whether zero values should be hidden in the UI. |
| config.userConfig.Logging.LogLevel."Microsoft.AspNetCore" | string | `"Warning"` | Sets the log level for Microsoft.AspNetCore-related components. Valid levels are `Trace`, `Debug`, `Information`, `Warning`, `Error`, `Critical` and `None`. Learn more at: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/ |
| config.userConfig.Logging.LogLevel.Default | string | `"Information"` | Specifies the default log level for all components. Valid levels are `Trace`, `Debug`, `Information`, `Warning`, `Error`, `Critical` and `None`. Learn more at: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/ |
| config.userConfig.PreferredGasMileageUnit | string | `""` | Specifies the preferred unit for gas mileage. |
| config.userConfig.PreferredGasUnit | string | `""` | Specifies the preferred unit for gas volume. |
| config.userConfig.UseDarkMode | bool | `false` | Enables or disables dark mode in the user interface. |
| config.userConfig.UseDescending | bool | `false` | Determines if lists are ordered in descending order by default. |
| config.userConfig.UseMPG | bool | `true` | Configures whether to use miles per gallon (MPG) as the fuel economy unit. |
| config.userConfig.UseMarkDownOnSavedNotes | bool | `false` | Allows saved notes to support markdown formatting. |
| config.userConfig.UseThreeDecimalGasCost | bool | `true` | Enables displaying gas costs with three decimal places for accuracy. |
| config.userConfig.UseUKMPG | bool | `false` | Uses UK miles per gallon (UK MPG) as the fuel economy unit. |
| config.userConfig.UserColumnPreferences | list | `[]` | Stores user preferences for column visibility. |
| config.userConfig.UserLanguage | string | `"en_US"` | Defines the user's language preference (e.g., "en_US"). |
| config.userConfig.UserNameHash | string | `"8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918"` | Stores a hashed version of the user's username. It is sha256, and can be created using one the following commands: `echo -n 'admin' | openssl dgst -sha256 | awk '{print $2}'` `echo -n 'admin' | sha256sum - | awk '{print $1}'` |
| config.userConfig.UserPasswordHash | string | `"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"` | Stores a hashed version of the user's password. It is sha256, and can be created using one the following commands: `echo -n 'password' | openssl dgst -sha256 | awk '{print $2}'` `echo -n 'password' | sha256sum - | awk '{print $1}'` |
| config.userConfig.VisibleTabs | list | `[0,1,4,2,3,6,5,8]` | Specifies which tabs are visible in the user interface. |
| fullnameOverride | string | `""` | Override for the full name. |
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. |
| image.repository | string | `"ghcr.io/hargata/lubelogger"` | Registry and repository for the image. |
Expand All @@ -35,6 +61,21 @@ LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
| livenessProbe.httpGet | object | `{"path":"/","port":"http"}` | Liveness probe configuration. |
| nameOverride | string | `""` | Override for the name. |
| nodeSelector | object | `{}` | Node selector for the pods. |
| persistence.data.accessMode | string | `"ReadWriteOnce"` | Access mode for the PVC. |
| persistence.data.enabled | bool | `false` | Enable/disable PVC creation for data. |
| persistence.data.existingClaim | string | `""` | Use an existing PVC if defined, otherwise create one. |
| persistence.data.size | string | `"10Gi"` | Storage size for the PVC. |
| persistence.data.storageClass | string | `""` | Specify the StorageClass (if required). |
| persistence.documents.accessMode | string | `"ReadWriteOnce"` | Access mode for the PVC. |
| persistence.documents.enabled | bool | `true` | Enable/disable PVC creation for documents. |
| persistence.documents.existingClaim | string | `""` | Use an existing PVC if defined, otherwise create one. |
| persistence.documents.size | string | `"10Gi"` | Storage size for the PVC. |
| persistence.documents.storageClass | string | `""` | Specify the StorageClass (if required). |
| persistence.images.accessMode | string | `"ReadWriteOnce"` | Access mode for the PVC. |
| persistence.images.enabled | bool | `true` | Enable/disable PVC creation for images. |
| persistence.images.existingClaim | string | `""` | Use an existing PVC if defined, otherwise create one. |
| persistence.images.size | string | `"10Gi"` | Storage size for the PVC. |
| persistence.images.storageClass | string | `""` | Specify the StorageClass (if required). |
| podAnnotations | object | `{}` | Annotations to be added to the pods. |
| podLabels | object | `{}` | Labels to be added to the pods. |
| podSecurityContext | object | `{}` | |
Expand Down
10 changes: 9 additions & 1 deletion anza-labs/lubelogger/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1. Get the application URL by running these commands:
Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
Expand All @@ -10,3 +10,11 @@
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:8080
{{- end }}

{{- $maxReplicas := int 1 }}
{{- if (gt (int .Values.replicaCount) ($maxReplicas) ) }}
WARNING!

Your set the replica count to >1. Application does not sync Data, Documents and Images between replicas, so you will see
inconsistency and you will might observe data loss.
{{- end }}
23 changes: 22 additions & 1 deletion anza-labs/lubelogger/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Create the name of the service account to use
Create secret name used for configuring mail.
*/}}
{{- define "lubelog.mailSecret" -}}
{{- default (include "lubelog.fullname" .) .Values.secret.name }}
{{- default (printf "%s-mail" (include "lubelog.fullname" .)) .Values.secret.name }}
{{- end }}

{{/*
Expand All @@ -78,3 +78,24 @@ Create key under which PostgreSQL connection string can be found.
{{- define "lubelog.postgresSecretKey" -}}
{{- default "POSTGRES_CONNECTION" .Values.postgres.keyRef }}
{{- end }}

{{/*
Create pvc name used for configuring the data persistence in app.
*/}}
{{- define "lubelog.pvcData" -}}
{{- default ( printf "%s-data" (include "lubelog.fullname" .)) .Values.persistence.data.existingClaim }}
{{- end }}

{{/*
Create pvc name used for configuring the documents persistence in app.
*/}}
{{- define "lubelog.pvcDocuments" -}}
{{- default ( printf "%s-documents" (include "lubelog.fullname" .)) .Values.persistence.documents.existingClaim }}
{{- end }}

{{/*
Create pvc name used for configuring the images persistence in app.
*/}}
{{- define "lubelog.pvcImages" -}}
{{- default ( printf "%s-images" (include "lubelog.fullname" .)) .Values.persistence.images.existingClaim }}
{{- end }}
67 changes: 65 additions & 2 deletions anza-labs/lubelogger/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,54 @@ spec:
serviceAccountName: {{ include "lubelog.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes: []
volumes:
- name: config-ro
secret:
secretName: {{ include "lubelog.fullname" . }}
items:
- key: userConfig
path: userConfig.json
- name: translations
emptyDir: {}
- name: config
emptyDir: {}
{{- if .Values.persistence.data.enabled }}
- name: data
persistentVolumeClaim:
claimName: {{ include "lubelog.pvcData" . }}
{{- end }}
{{- if .Values.persistence.documents.enabled }}
- name: documents
persistentVolumeClaim:
claimName: {{ include "lubelog.pvcDocuments" . }}
{{- end }}
{{- if .Values.persistence.images.enabled }}
- name: images
persistentVolumeClaim:
claimName: {{ include "lubelog.pvcImages" . }}
{{- end }}
{{- if .Values.config.translations }}
initContainers:
- name: init-translations
image: curlimages/curl:latest
command: ["/bin/sh", "-c"]
args:
- |
mkdir -p /config
cp /config-ro/* /config
mkdir -p /translations
{{- range .Values.config.translations }}
echo "Fetching {{ . }}"
curl -o "/translations/$(basename {{ . }})" "{{ . }}"
{{- end }}
volumeMounts:
- name: config-ro
mountPath: /config-ro
- name: config
mountPath: /config
- name: translations
mountPath: /translations
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand All @@ -48,7 +95,23 @@ spec:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts: []
volumeMounts:
- name: config
mountPath: /App/config
- name: translations
mountPath: /App/wwwroot/translations
{{- if .Values.persistence.data.enabled }}
- name: data
mountPath: /App/data
{{- end }}
{{- if .Values.persistence.documents.enabled }}
- name: documents
mountPath: /App/wwwroot/documents
{{- end }}
{{- if .Values.persistence.images.enabled }}
- name: images
mountPath: /App/wwwroot/images
{{- end }}
env:
- name: "LC_ALL"
value: {{ .Values.config.LC_ALL | default "en_US.UTF-8" | quote }}
Expand Down
72 changes: 72 additions & 0 deletions anza-labs/lubelogger/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{- if and .Values.persistence.data.enabled (not .Values.persistence.data.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "lubelog.pvcData" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "lubelog.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: "keep"
spec:
accessModes:
- {{ .Values.persistence.data.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.data.size }}
{{- if .Values.persistence.data.storageClass }}
storageClassName: {{ .Values.persistence.data.storageClass }}
{{- end }}
{{- end }}
{{- if and .Values.persistence.images.enabled (not .Values.persistence.images.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "lubelog.pvcImages" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "lubelog.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: "keep"
spec:
accessModes:
- {{ .Values.persistence.images.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.images.size }}
{{- if .Values.persistence.images.storageClass }}
storageClassName: {{ .Values.persistence.images.storageClass }}
{{- end }}
{{- end }}
{{- if and .Values.persistence.documents.enabled (not .Values.persistence.documents.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "lubelog.pvcDocuments" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "lubelog.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: "keep"
spec:
accessModes:
- {{ .Values.persistence.documents.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.documents.size }}
{{- if .Values.persistence.documents.storageClass }}
storageClassName: {{ .Values.persistence.documents.storageClass }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions anza-labs/lubelogger/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{{- $port := .Values.secret.port | required ".Values.secret.port is required." -}}
{{- $username := .Values.secret.username | required ".Values.secret.username is required." -}}
{{- $password := .Values.secret.password | required ".Values.secret.password is required." -}}
---
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -22,3 +23,17 @@ stringData:
MailConfig__Username: "{{ $username }}"
MailConfig__Password: "{{ $password }}"
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "lubelog.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "lubelog.labels" . | nindent 4 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
type: Opaque
stringData:
userConfig: {{ toJson .Values.config.userConfig | quote }}
Loading

0 comments on commit 690593e

Please sign in to comment.