Skip to content

Commit

Permalink
feat(lubelogger): add secrets name overrides (#8)
Browse files Browse the repository at this point in the history
## Description
This pull request allows overriding secrets name when configuring the
application.

---------

Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur authored Jul 27, 2024
1 parent bb18444 commit f3c5f18
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 16 deletions.
2 changes: 1 addition & 1 deletion anza-labs/lubelog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v2
name: lubelog
description: LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
type: application
version: 0.1.1
version: 0.1.2
18 changes: 14 additions & 4 deletions anza-labs/lubelog/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# lubelog

![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat)
![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat)

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

Expand All @@ -13,8 +13,8 @@ LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
| autoscaling.maxReplicas | int | `3` | Maximum number of replicas for autoscaling. |
| autoscaling.minReplicas | int | `1` | Minimum number of replicas for autoscaling. |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | Target CPU utilization percentage for autoscaling. |
| config.LANG | string | `"en_US.UTF-8"` | Same as above. Note that some languages don't have UTF-8 encodings. |
| config.LC_ALL | string | `"en_US.UTF-8"` | Locale and Language Settings, this will affect how numbers, currencies, and dates are formatted. |
| 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/ |
| fullnameOverride | string | `""` | Override for the full name. |
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. |
Expand All @@ -32,13 +32,23 @@ LubeLogger is a web-based vehicle maintenance and fuel mileage tracker
| podAnnotations | object | `{}` | Annotations to be added to the pods. |
| podLabels | object | `{}` | Labels to be added to the pods. |
| podSecurityContext | object | `{}` | |
| postgres | object | `{"connect":false,"database":"postgres","host":"postgres","password":"postgres","port":5432,"user":"postgres"}` | PostgreSQL connection details. |
| postgres | object | `{"connect":false,"create":false,"database":"postgres","host":"postgres","keyRef":"POSTGRES_CONNECTION","name":"","password":"postgres","port":5432,"user":"postgres"}` | PostgreSQL connection details. |
| postgres.connect | bool | `false` | Defines if the LubeLogger should connect to the Postgres backend. It has no effect when `postgres.create=true`. |
| postgres.create | bool | `false` | Defines if the secret with Postgres connection details should be created. |
| postgres.database | string | `"postgres"` | Database name. |
| postgres.host | string | `"postgres"` | Host of the Postgres database. |
| postgres.keyRef | string | `"POSTGRES_CONNECTION"` | Defines the key under which postgres connection string can be found. It uses Npgsql connection format. |
| postgres.name | string | `""` | Specifies name of a secret used to configure the LubeLogger's Postgres backend. If not filled, uses full name. |
| postgres.password | string | `"postgres"` | Password for the user used to connect to the Postgres database. |
| postgres.port | int | `5432` | Port of the Postgres database. |
| postgres.user | string | `"postgres"` | User used to connect to the Postgres database. |
| readinessProbe.httpGet | object | `{"path":"/","port":"http"}` | Readiness probe configuration. |
| replicaCount | int | `1` | Number of replicas for the deployment. |
| resources | object | `{}` | |
| secret.create | bool | `true` | Specifies whether a secret should be created. |
| secret.emailFrom | string | `""` | Email from address for the secret. |
| secret.emailServer | string | `""` | Email server for the secret. |
| secret.name | string | `""` | Specifies name of a secret used to configure the LubeLogger's mail connection. If not filled, uses full name. |
| secret.password | string | `""` | Password for the email server. |
| secret.port | int | `587` | Port for the email server. |
| secret.username | string | `""` | Username for the email server. |
Expand Down
21 changes: 21 additions & 0 deletions anza-labs/lubelog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,24 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create secret name used for configuring mail.
*/}}
{{- define "lubelog.mailSecret" -}}
{{- default (include "lubelog.fullname" .) .Values.secret.name }}
{{- end }}

{{/*
Create secret name used for configuring PostgreSQL connection.
*/}}
{{- define "lubelog.postgresSecret" -}}
{{- default ( printf "%s-postgres-connection" (include "lubelog.fullname" .)) .Values.postgres.name }}
{{- end }}

{{/*
Create key under which PostgreSQL connection string can be found.
*/}}
{{- define "lubelog.postgresSecretKey" -}}
{{- default "POSTGRES_CONNECTION" .Values.postgres.keyRef }}
{{- end }}
14 changes: 7 additions & 7 deletions anza-labs/lubelog/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,33 @@ spec:
- name: MailConfig__EmailServer
valueFrom:
secretKeyRef:
name: {{ include "lubelog.fullname" . }}
name: {{ include "lubelog.mailSecret" . }}
key: MailConfig__EmailServer
- name: MailConfig__EmailFrom
valueFrom:
secretKeyRef:
name: {{ include "lubelog.fullname" . }}
name: {{ include "lubelog.mailSecret" . }}
key: MailConfig__EmailFrom
- name: MailConfig__Port
valueFrom:
secretKeyRef:
name: {{ include "lubelog.fullname" . }}
name: {{ include "lubelog.mailSecret" . }}
key: MailConfig__Port
- name: MailConfig__Username
valueFrom:
secretKeyRef:
name: {{ include "lubelog.fullname" . }}
name: {{ include "lubelog.mailSecret" . }}
key: MailConfig__Username
- name: MailConfig__Password
valueFrom:
secretKeyRef:
name: {{ include "lubelog.fullname" . }}
name: {{ include "lubelog.mailSecret" . }}
key: MailConfig__Password
{{- if .Values.postgres.connect }}
{{- if or .Values.postgres.connect .Values.postgres.create }}
- name: POSTGRES_CONNECTION
valueFrom:
secretKeyRef:
name: {{ include "lubelog.fullname" . }}-postgres-connection
name: {{ include "lubelog.postgresSecret" . }}
key: POSTGRES_CONNECTION
{{- end }}
{{- with .Values.nodeSelector }}
Expand Down
2 changes: 1 addition & 1 deletion anza-labs/lubelog/templates/postgres-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ metadata:
{{- end }}
type: Opaque
stringData:
POSTGRES_CONNECTION: "Host={{ $pgHost }}:{{ $pgPort }};Username={{ $pgUser }};Password={{ $pgPass }};Database={{ $pgDatabase }};"
{{- include "lubelog.postgresSecretKey" . | nindent 2}}: "Host={{ $pgHost }}:{{ $pgPort }};Username={{ $pgUser }};Password={{ $pgPass }};Database={{ $pgDatabase }};"
{{- end }}
2 changes: 1 addition & 1 deletion anza-labs/lubelog/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "lubelog.fullname" . }}
name: {{ include "lubelog.mailSecret" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "lubelog.labels" . | nindent 4 }}
Expand Down
22 changes: 20 additions & 2 deletions anza-labs/lubelog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ image:
pullPolicy: IfNotPresent

config:
# -- Same as above. Note that some languages don't have UTF-8 encodings.
LANG: en_US.UTF-8
# -- Locale and Language Settings, this will affect how numbers, currencies, and dates are
# formatted.
LANG: en_US.UTF-8
# -- Same as above. Note that some languages don't have UTF-8 encodings.
LC_ALL: en_US.UTF-8
# -- Specifies the level of logs. Valid levels are `Trace`, `Debug`, `Information`,
# `Warning`, `Error`, `Critical` and `None`. Learn more at:
Expand Down Expand Up @@ -43,6 +43,9 @@ serviceAccount:
secret:
# -- Specifies whether a secret should be created.
create: true
# -- Specifies name of a secret used to configure the LubeLogger's mail connection.
# If not filled, uses full name.
name: ""
# -- Email server for the secret.
emailServer: ""
# -- Email from address for the secret.
Expand All @@ -56,11 +59,26 @@ secret:

# -- PostgreSQL connection details.
postgres:
# -- Defines if the secret with Postgres connection details should be created.
create: false
# -- Defines if the LubeLogger should connect to the Postgres backend.
# It has no effect when `postgres.create=true`.
connect: false
# -- Specifies name of a secret used to configure the LubeLogger's Postgres backend.
# If not filled, uses full name.
name: ""
# -- Defines the key under which postgres connection string can be found.
# It uses Npgsql connection format.
keyRef: "POSTGRES_CONNECTION"
# -- Host of the Postgres database.
host: "postgres"
# -- Port of the Postgres database.
port: 5432
# -- User used to connect to the Postgres database.
user: "postgres"
# -- Password for the user used to connect to the Postgres database.
password: "postgres"
# -- Database name.
database: "postgres"

# -- Annotations to be added to the pods.
Expand Down

0 comments on commit f3c5f18

Please sign in to comment.