refactor: migrate from Bitnami PostgreSQL to official PostgreSQL image

Replace Bitnami PostgreSQL dependency with custom PostgreSQL StatefulSet implementation
Add new PostgreSQL templates: statefulset, service, and PVC
Update values.yaml to include PostgreSQL image configuration with official postgres:17.4 image
Implement custom PostgreSQL deployment using official Docker Hub image instead of Bitnami chart
Add PostgreSQL resource, nodeSelector, tolerations, and affinity configuration options
Update helper templates to support new PostgreSQL implementation
Update deployment template to connect to the new PostgreSQL implementation
Update README.md to document the new PostgreSQL configuration parameters

BREAKING CHANGE: This replaces the Bitnami PostgreSQL dependency with a custom PostgreSQL implementation using the official
PostgreSQL image from Docker Hub, changing how PostgreSQL is deployed and configured.

Signed-off-by: Ilya Gilev jazer23569@gmail.com
pull/7831/head
acidsugarx 1 month ago
parent dd48f28827
commit a7dc23a1a8

@ -1,6 +0,0 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 8.10.14
digest: sha256:db7c1e0bc9ec0ed45520521bd76bb390d04711fd0f04affaadafa1dc498ce68b
generated: "2020-07-21T20:34:41.41180748-04:00"

@ -2,7 +2,7 @@ apiVersion: v2
name: wiki name: wiki
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
version: 2.3.0 version: 2.4.0
# This is the version number of the application being deployed. This version number should be # This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. # incremented each time you make changes to the application.
AppVersion: latest AppVersion: latest
@ -23,11 +23,7 @@ keywords:
# a dependency of application charts to inject those utilities and functions into the rendering # a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed. # pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application type: application
dependencies:
- name: postgresql
version: 8.10.14
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
home: https://wiki.js.org home: https://wiki.js.org
icon: https://cdn.js.wiki/images/wikijs-butterfly.svg icon: https://cdn.js.wiki/images/wikijs-butterfly.svg
sources: sources:

@ -43,7 +43,7 @@ Wiki.js is an open source project that has been made possible due to the generou
This chart bootstraps a Wiki.js deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. This chart bootstraps a Wiki.js deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
It also optionally packages the [PostgreSQL](https://github.com/kubernetes/charts/tree/master/stable/postgresql) as the database but you are free to bring your own. It also optionally deploys PostgreSQL as the database using the official PostgreSQL image from Docker Hub, but you are free to bring your own database.
## Prerequisites ## Prerequisites
@ -132,7 +132,18 @@ The following table lists the configurable parameters of the Wiki.js chart and t
| `postgresql.persistence.enabled` | Enable postgres persistence using PVC | `true` | | `postgresql.persistence.enabled` | Enable postgres persistence using PVC | `true` |
| `postgresql.persistence.existingClaim` | Provide an existing `PersistentVolumeClaim` for postgres | `nil` | | `postgresql.persistence.existingClaim` | Provide an existing `PersistentVolumeClaim` for postgres | `nil` |
| `postgresql.persistence.storageClass` | Postgres PVC Storage Class (example: `nfs`) | `nil` | | `postgresql.persistence.storageClass` | Postgres PVC Storage Class (example: `nfs`) | `nil` |
| `postgresql.persistence.size` | Postgers PVC Storage Request | `8Gi` | | `postgresql.persistence.size` | Postgres PVC Storage Request | `8Gi` |
| `postgresql.persistence.accessMode` | Postgres Persistent Volume Access Mode | `ReadWriteOnce` |
| `postgresql.image.repository` | PostgreSQL image repository | `postgres` |
| `postgresql.image.tag` | PostgreSQL image tag | `17.4` |
| `postgresql.image.pullPolicy` | PostgreSQL image pull policy | `IfNotPresent` |
| `postgresql.resources` | PostgreSQL resource requests/limits | `{}` |
| `postgresql.nodeSelector` | PostgreSQL node selector labels | `{}` |
| `postgresql.tolerations` | PostgreSQL toleration labels | `[]` |
| `postgresql.affinity` | PostgreSQL affinity settings | `{}` |
| `postgresql.service.type` | PostgreSQL service type | `ClusterIP` |
| `postgresql.service.port` | PostgreSQL service port | `5432` |
| `postgresql.service.annotations` | PostgreSQL service annotations | `{}` |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
@ -150,9 +161,9 @@ $ helm install --name my-release -f values.yaml requarks/wiki
> **Tip**: You can use the default [values.yaml](values.yaml) > **Tip**: You can use the default [values.yaml](values.yaml)
## PostgresSQL ## PostgreSQL
By default, PostgreSQL is installed as part of the chart. By default, PostgreSQL is installed as part of the chart using the official PostgreSQL image from Docker Hub (version 17.4).
### Using an external PostgreSQL server ### Using an external PostgreSQL server

@ -19,3 +19,16 @@
echo "Visit http://127.0.0.1:8080 to use your application" echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }} {{- end }}
{{- if .Values.postgresql.enabled }}
2. PostgreSQL database has been deployed as part of this release:
- Database: {{ .Values.postgresql.postgresqlDatabase }}
- User: {{ .Values.postgresql.postgresqlUser }}
- Service: {{ include "wiki.postgresql.fullname" . }}
- Version: {{ .Values.postgresql.image.tag }}
- Persistence: {{ .Values.postgresql.persistence.enabled | ternary "Enabled" "Disabled" }}
{{- end }}
{{- if not .Values.postgresql.enabled }}
2. External PostgreSQL setup detected. Ensure your database is accessible at the configured host.
{{- end }}

@ -63,15 +63,18 @@ Create the name of the service account to use
{{- end -}} {{- end -}}
{{/* {{/*
Create a default fully qualified app name. PostgreSQL fullname
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}} */}}
{{- define "wiki.postgresql.fullname" -}} {{- define "wiki.postgresql.fullname" -}}
{{- if .Values.postgresql.fullnameOverride -}} {{- printf "%s-%s" (include "wiki.fullname" .) "postgresql" | trunc 63 | trimSuffix "-" -}}
{{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{ printf "%s-%s" .Release.Name "postgresql"}}
{{- end -}} {{- end -}}
{{/*
PostgreSQL selector labels
*/}}
{{- define "wiki.postgresql.selectorLabels" -}}
app.kubernetes.io/name: {{ include "wiki.name" . }}-postgresql
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}} {{- end -}}
{{/* {{/*
@ -79,9 +82,9 @@ Set postgres host
*/}} */}}
{{- define "wiki.postgresql.host" -}} {{- define "wiki.postgresql.host" -}}
{{- if .Values.postgresql.enabled -}} {{- if .Values.postgresql.enabled -}}
{{- template "wiki.postgresql.fullname" . -}} {{- include "wiki.postgresql.fullname" . -}}
{{- else -}} {{- else -}}
{{- .Values.postgresql.postgresqlHost | quote -}} {{- .Values.postgresql.postgresqlHost | default "localhost" | quote -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
@ -90,7 +93,7 @@ Set postgres secret
*/}} */}}
{{- define "wiki.postgresql.secret" -}} {{- define "wiki.postgresql.secret" -}}
{{- if .Values.postgresql.enabled -}} {{- if .Values.postgresql.enabled -}}
{{- template "wiki.postgresql.fullname" . -}} {{- include "wiki.postgresql.fullname" . -}}
{{- else -}} {{- else -}}
{{- template "wiki.fullname" . -}} {{- template "wiki.fullname" . -}}
{{- end -}} {{- end -}}

@ -56,7 +56,7 @@ spec:
value: {{ .Values.externalPostgresql.databaseURL }} value: {{ .Values.externalPostgresql.databaseURL }}
- name: NODE_TLS_REJECT_UNAUTHORIZED - name: NODE_TLS_REJECT_UNAUTHORIZED
value: {{ default "1" .Values.externalPostgresql.NODE_TLS_REJECT_UNAUTHORIZED | quote }} value: {{ default "1" .Values.externalPostgresql.NODE_TLS_REJECT_UNAUTHORIZED | quote }}
{{- else }} {{- else if .Values.postgresql.enabled }}
- name: DB_HOST - name: DB_HOST
value: {{ template "wiki.postgresql.host" . }} value: {{ template "wiki.postgresql.host" . }}
- name: DB_PORT - name: DB_PORT
@ -64,7 +64,7 @@ spec:
- name: DB_NAME - name: DB_NAME
value: {{ default "wiki" .Values.postgresql.postgresqlDatabase }} value: {{ default "wiki" .Values.postgresql.postgresqlDatabase }}
- name: DB_USER - name: DB_USER
value: {{ default "wiki" .Values.postgresql.postgresqlUser }} value: {{ default "postgres" .Values.postgresql.postgresqlUser }}
- name: DB_SSL - name: DB_SSL
value: "{{ default "false" .Values.postgresql.ssl }}" value: "{{ default "false" .Values.postgresql.ssl }}"
- name: DB_SSL_CA - name: DB_SSL_CA
@ -72,12 +72,23 @@ spec:
- name: DB_PASS - name: DB_PASS
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
{{- if .Values.postgresql.existingSecret }}
name: {{ .Values.postgresql.existingSecret }}
{{- else }}
name: {{ template "wiki.postgresql.secret" . }} name: {{ template "wiki.postgresql.secret" . }}
{{- end }}
key: {{ template "wiki.postgresql.secretKey" . }} key: {{ template "wiki.postgresql.secretKey" . }}
{{- else if .Values.externalPostgresql }}
# External PostgreSQL configuration
- name: DB_HOST
value: {{ required "External PostgreSQL host is required when postgresql.enabled is false" .Values.externalPostgresql.host | quote }}
- name: DB_PORT
value: {{ required "External PostgreSQL port is required when postgresql.enabled is false" .Values.externalPostgresql.port | quote }}
- name: DB_NAME
value: {{ required "External PostgreSQL database name is required when postgresql.enabled is false" .Values.externalPostgresql.database | quote }}
- name: DB_USER
value: {{ required "External PostgreSQL user is required when postgresql.enabled is false" .Values.externalPostgresql.username | quote }}
- name: DB_PASS
valueFrom:
secretKeyRef:
name: {{ required "External PostgreSQL secret name is required when postgresql.enabled is false" .Values.externalPostgresql.existingSecret | quote }}
key: {{ required "External PostgreSQL secret key is required when postgresql.enabled is false" .Values.externalPostgresql.existingSecretKey | quote }}
{{- end }} {{- end }}
- name: HA_ACTIVE - name: HA_ACTIVE
value: {{ .Values.replicaCount | int | le 2 | quote }} value: {{ .Values.replicaCount | int | le 2 | quote }}

@ -0,0 +1,21 @@
{{- if and .Values.postgresql.enabled .Values.postgresql.persistence.enabled -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "wiki.postgresql.fullname" . }}
labels:
{{- include "wiki.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.postgresql.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.postgresql.persistence.size | quote }}
{{- if .Values.postgresql.persistence.storageClass }}
{{- if (eq "-" .Values.postgresql.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.postgresql.persistence.storageClass | quote }}
{{- end }}
{{- end }}
{{- end }}

@ -0,0 +1,13 @@
{{- if and .Values.postgresql.enabled (not .Values.postgresql.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "wiki.postgresql.fullname" . }}
labels:
{{- include "wiki.labels" . | nindent 4 }}
type: Opaque
data:
postgresql-password: {{ .Values.postgresql.postgresqlPassword | b64enc | quote }}
postgresql-username: {{ .Values.postgresql.postgresqlUser | b64enc | quote }}
postgresql-database: {{ .Values.postgresql.postgresqlDatabase | b64enc | quote }}
{{- end }}

@ -0,0 +1,21 @@
{{- if .Values.postgresql.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "wiki.postgresql.fullname" . }}
labels:
{{- include "wiki.labels" . | nindent 4 }}
{{- with .Values.postgresql.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.postgresql.service.type }}
ports:
- port: {{ .Values.postgresql.service.port }}
targetPort: 5432
protocol: TCP
name: postgresql
selector:
{{- include "wiki.postgresql.selectorLabels" . | nindent 4 }}
{{- end }}

@ -0,0 +1,90 @@
{{- if .Values.postgresql.enabled -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "wiki.postgresql.fullname" . }}
labels:
{{- include "wiki.labels" . | nindent 4 }}
spec:
serviceName: {{ include "wiki.postgresql.fullname" . }}
replicas: 1
selector:
matchLabels:
{{- include "wiki.postgresql.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "wiki.postgresql.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.postgresql.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.postgresql.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.postgresql.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgresql
image: {{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
imagePullPolicy: {{ .Values.postgresql.image.pullPolicy }}
ports:
- containerPort: 5432
name: postgresql
env:
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: {{ include "wiki.postgresql.fullname" . }}
key: postgresql-database
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: {{ include "wiki.postgresql.fullname" . }}
key: postgresql-username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "wiki.postgresql.fullname" . }}
key: postgresql-password
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
livenessProbe:
exec:
command:
- sh
- -c
- exec pg_isready -U {{ .Values.postgresql.postgresqlUser }} -d {{ .Values.postgresql.postgresqlDatabase }}
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
readinessProbe:
exec:
command:
- sh
- -c
- exec pg_isready -U {{ .Values.postgresql.postgresqlUser }} -d {{ .Values.postgresql.postgresqlDatabase }}
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 6
resources:
{{- toYaml .Values.postgresql.resources | nindent 12 }}
volumeMounts:
- name: postgresql-data
mountPath: /var/lib/postgresql/data
subPath: postgresql
volumes:
- name: postgresql-data
{{- if .Values.postgresql.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "wiki.postgresql.fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}

@ -156,47 +156,39 @@ extraEnvVars: []
# # For self signed CAs, like DigitalOcean # # For self signed CAs, like DigitalOcean
# NODE_TLS_REJECT_UNAUTHORIZED: "0" # NODE_TLS_REJECT_UNAUTHORIZED: "0"
## Configuration values for the postgresql dependency. ## Configuration for the custom PostgreSQL 17.4 deployment
## ref: https://github.com/kubernetes/charts/blob/master/stable/postgresql/README.md
## ##
postgresql: postgresql:
## Use the PostgreSQL chart dependency.
## Set to false if bringing your own PostgreSQL, and set secret value postgresql-uri.
##
enabled: true enabled: true
## ssl enforce SSL communication with PostgresSQL ## ssl enforce SSL communication with PostgresSQL
## Default to false ## Default to false
## ##
# ssl: false ssl: false
## ca Certificate of Authority ## ca Certificate of Authority
## Default to empty, point to location of CA ## Default to empty, point to location of CA
## ##
# ca: "path to ca" # ca: "path to ca"
## postgresqlHost override postgres database host ## postgresqlHost override postgres database host
## Default to postgres ## Default to the service name of the custom PostgreSQL deployment
## ##
# postgresqlHost: postgres postgresqlHost: "{{ include \"wiki.postgresql.fullname\" . }}"
## postgresqlPort port for postgres ## postgresqlPort port for postgres
## Default to 5432 ## Default to 5432
## ##
# postgresqlPort: 5432 postgresqlPort: 5432
## PostgreSQL fullname Override
## Default to wiki-postgresql unless fullname override is set for Chart
##
fullnameOverride: ""
## PostgreSQL User to create. ## PostgreSQL User to create.
## ##
postgresqlUser: postgres postgresqlUser: postgres
## PostgreSQL Database to create. ## PostgreSQL Database to create.
## ##
postgresqlDatabase: wiki postgresqlDatabase: wiki
## PostgreSQL password (will be stored in a secret)
##
postgresqlPassword: "postgres"
## Persistent Volume Storage configuration. ## Persistent Volume Storage configuration.
## ref: https://kubernetes.io/docs/user-guide/persistent-volumes ## ref: https://kubernetes.io/docs/user-guide/persistent-volumes
## ##
replication:
## Enable PostgreSQL replication (primary/secondary)
##
enabled: false
persistence: persistence:
## Enable PostgreSQL persistence using Persistent Volume Claims. ## Enable PostgreSQL persistence using Persistent Volume Claims.
## ##
@ -215,3 +207,34 @@ postgresql:
## Persistent Volume Storage Size. ## Persistent Volume Storage Size.
## ##
size: 8Gi size: 8Gi
## PostgreSQL Image Configuration
image:
repository: postgres
tag: "17.4"
pullPolicy: IfNotPresent
## PostgreSQL Resources Configuration
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
## PostgreSQL Node Selector, Tolerations and Affinity
nodeSelector: {}
tolerations: []
affinity: {}
## PostgreSQL Service Configuration
service:
type: ClusterIP
port: 5432
# Additional service annotations
annotations: {}

Loading…
Cancel
Save