Skip to content

Commit

Permalink
Merge pull request #35 from cloud-pi-native/feat/handle-cnpg-replication
Browse files Browse the repository at this point in the history
feat: ✨ handle cnpg replication mode
  • Loading branch information
this-is-tobi authored Jul 10, 2024
2 parents 685f416 + 74b45eb commit 815246c
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
steps:
- name: Checks-out repository
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

- name: Check updated files paths
uses: dorny/paths-filter@v3
id: filter
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- 'charts/**'
- '!charts/**/README.md'

jobs:
release:
Expand Down
2 changes: 1 addition & 1 deletion charts/dso-console/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: cpn-console
description: A Helm chart to deploy Cloud Pi Native Console
type: application
version: 1.4.9
version: 1.5.0
appVersion: 8.8.1
keywords: []
home: https://cloud-pi-native.fr
Expand Down
9 changes: 7 additions & 2 deletions charts/dso-console/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# cpn-console

![Version: 1.4.9](https://img.shields.io/badge/Version-1.4.9-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 8.8.1](https://img.shields.io/badge/AppVersion-8.8.1-informational?style=flat-square)
![Version: 1.5.0](https://img.shields.io/badge/Version-1.5.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 8.8.1](https://img.shields.io/badge/AppVersion-8.8.1-informational?style=flat-square)

A Helm chart to deploy Cloud Pi Native Console

Expand Down Expand Up @@ -98,10 +98,15 @@ A Helm chart to deploy Cloud Pi Native Console
| cnpg.dbName | string | `"dso-console-db"` | Name of the database. |
| cnpg.enableSuperuserAccess | bool | `true` | Enable superuser access. |
| cnpg.enabled | bool | `false` | Whether or not cnpg cluster deployment should be enabled. |
| cnpg.exposed | bool | `false` | Whether or not a NodePort service should be created to exposed the database. |
| cnpg.instances | int | `3` | Number of instances to spawn in the cluster. |
| cnpg.mode | string | `"primary"` | Mode used to deploy the cnpg cluster, it should be `primary` or `replica`. |
| cnpg.nameOverride | string | `""` | Provide a name in place of the default cnpg cluster name. |
| cnpg.nodePort | string | `nil` | Port used for NodePort service. Needs `exposed` tu be true. |
| cnpg.primaryUpdateStrategy | string | `"unsupervised"` | Rolling update strategy used : unsupervised: automated update of the primary once all replicas have been upgraded (default) supervised: requires manual supervision to perform the switchover of the primary |
| cnpg.pvcSize | string | `"10Gi"` | Size of the PVC used by each cnpg instance. |
| cnpg.replica.host | string | `nil` | Primary cnpg cluster host used for replica mode. |
| cnpg.replica.port | string | `nil` | Primary cnpg cluster port used for replica mode. |
| cnpg.username | string | `"dso"` | Username of the database user. |
| config.create | bool | `false` | Whether or not helm should create the console config. |
| config.name | string | `"dso-config"` | Name of the genrated config. |
Expand Down Expand Up @@ -231,4 +236,4 @@ A Helm chart to deploy Cloud Pi Native Console
| server.tolerations | list | `[]` | Default tolerations for Console CPN server. |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
44 changes: 42 additions & 2 deletions charts/dso-console/templates/cnpg/pg-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,55 @@ spec:
max_worker_processes: "60"
pg_hba:
- {{ printf "%s %s %s %s %s" "host" .Values.cnpg.dbName .Values.cnpg.username "all" "md5" }}
- {{ printf "%s %s %s %s %s" "host" .Values.cnpg.dbName "streaming_replica" "all" "md5" }}
bootstrap:
{{- if eq .Values.cnpg.mode "primary" }}
initdb:
database: {{ .Values.cnpg.dbName }}
owner: {{ .Values.cnpg.username }}
{{- else if eq .Values.cnpg.mode "replica" }}
recovery:
source: cluster-primary
replica:
enabled: true
source: cluster-primary
externalClusters:
- name: cluster-primary
{{- if .Values.cnpg.backup }}
barmanObjectStore:
destinationPath: {{ .Values.cnpg.backup.destinationPath }}
endpointURL: {{ .Values.cnpg.backup.endpointURL }}
endpointCA:
name: {{ .Values.cnpg.backup.endpointCA.name }}
key: {{ .Values.cnpg.backup.endpointCA.key }}
s3Credentials:
accessKeyId:
name: {{ .Values.cnpg.backup.s3Credentials.name | default (printf "%s-%s" (include "cpnConsole.fullname" .) "pg-cluster") }}
key: {{ .Values.cnpg.backup.s3Credentials.accessKeyId.key }}
secretAccessKey:
name: {{ .Values.cnpg.backup.s3Credentials.name | default (printf "%s-%s" (include "cpnConsole.fullname" .) "pg-cluster") }}
key: {{ .Values.cnpg.backup.s3Credentials.secretAccessKey.key }}
{{- end }}
connectionParameters:
host: {{ .Values.cnpg.replica.host }}
port: {{ .Values.cnpg.replica.port }}
dbname: {{ .Values.cnpg.dbName }}
sslmode: prefer
sslKey:
name: {{ (printf "%s-%s" .Values.cnpg.nameOverride "replication") | default (printf "%s-%s-%s" (include "cpnConsole.fullname" .) "pg-cluster" "replication") }}
key: tls.key
sslCert:
name: {{ (printf "%s-%s" .Values.cnpg.nameOverride "replication") | default (printf "%s-%s-%s" (include "cpnConsole.fullname" .) "pg-cluster" "replication") }}
key: tls.crt
sslRootCert:
name: {{ (printf "%s-%s" .Values.cnpg.nameOverride "ca") | default (printf "%s-%s-%s" (include "cpnConsole.fullname" .) "pg-cluster" "ca") }}
key: ca.crt
{{- end }}
enableSuperuserAccess: {{ .Values.cnpg.enableSuperuserAccess }}
primaryUpdateStrategy: {{ .Values.cnpg.primaryUpdateStrategy }}
storage:
size: {{ .Values.cnpg.pvcSize }}
{{- if .Values.cnpg.backup.enabled }}
{{- if .Values.cnpg.backup.enabled }}
backup:
barmanObjectStore:
destinationPath: {{ .Values.cnpg.backup.destinationPath }}
Expand All @@ -46,5 +86,5 @@ spec:
name: {{ .Values.cnpg.backup.s3Credentials.name | default (printf "%s-%s" (include "cpnConsole.fullname" .) "pg-cluster") }}
key: {{ .Values.cnpg.backup.s3Credentials.secretAccessKey.key }}
retentionPolicy: {{ .Values.cnpg.backup.retentionPolicy }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/dso-console/templates/cnpg/service-nodeport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if and .Values.cnpg.enabled .Values.cnpg.exposed }}
apiVersion: v1
kind: Service
metadata:
name: {{ (printf "%s-%s" .Values.cnpg.nameOverride "rw-nodeport") | default (printf "%s-%s" (include "cpnConsole.fullname" .) "pg-cluster") }}
labels:
{{- include "cpnConsole.common.labels" . | nindent 4 }}
annotations:
{{- with .Values.cnpg.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ports:
- name: postgres
port: 5432
protocol: TCP
nodePort: {{ .Values.cnpg.nodePort }}
selector:
cnpg.io/cluster: {{ .Values.cnpg.nameOverride | default (printf "%s-%s" (include "cpnConsole.fullname" .) "pg-cluster") }}
role: primary
type: NodePort
{{- end }}
11 changes: 11 additions & 0 deletions charts/dso-console/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,17 @@ cnpg:
pvcSize: "10Gi"
# -- Additional cnpg cluster annotations.
annotations: {}
# -- Whether or not a NodePort service should be created to exposed the database.
exposed: false
# -- Port used for NodePort service. Needs `exposed` tu be true.
nodePort:
# -- Mode used to deploy the cnpg cluster, it should be `primary` or `replica`.
mode: "primary"
replica:
# -- Primary cnpg cluster host used for replica mode.
host:
# -- Primary cnpg cluster port used for replica mode.
port:
backup:
# -- Whether or not cnpg cluster deployment should be enabled.
enabled: false
Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/helm-docs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail

HELM_DOCS_VERSION="1.13.1"
HELM_DOCS_VERSION="1.14.2"

# install helm-docs
curl --silent --show-error --fail --location --output /tmp/helm-docs.tar.gz https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_Linux_x86_64.tar.gz
Expand Down

0 comments on commit 815246c

Please sign in to comment.