chore(postgresql): adds postgres chart (#769)

Related: https://github.com/SigNoz/platform-pod/issues/1220

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

* **New Features**
* PostgreSQL is now available as a deployable component and has been
added to the default deployment configuration.
* PostgreSQL deployment includes support for persistence, custom service
configuration, security contexts, resource management, and advanced
Kubernetes features like affinity rules and topology constraints.

* **Documentation**
* Added comprehensive PostgreSQL documentation including installation
guides, configuration parameter reference, system prerequisites, and
deployment best practices.
* Documentation includes a complete values reference with detailed
descriptions of all configurable options for customizing PostgreSQL
deployments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Nageshbansal
2025-10-22 15:32:30 +05:30
committed by GitHub
parent dd5dba0325
commit dffce984b8
12 changed files with 1436 additions and 1 deletions

View File

@@ -54,7 +54,7 @@ purge: delete delete-namespace
# generate docs for specified charts with respective templates
# Usage: make chart-docs CHARTS=chart1,chart2
# Example: make chart-docs CHARTS=charts/signoz,charts/k8s-infra
CHARTS ?= charts/signoz,charts/k8s-infra
CHARTS ?= charts/signoz,charts/k8s-infra,charts/postgresql
HELM_DOCS = go run github.com/norwoodj/helm-docs/cmd/helm-docs@v1.14.2
chart-docs:
$(HELM_DOCS) --chart-search-root=charts --template-files=README.md.gotmpl --chart-to-generate=$(CHARTS) --sort-values-order=file

View File

@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -0,0 +1,15 @@
apiVersion: v2
name: postgresql
version: 0.0.1
appVersion: 15.0.0
description: A Helm Chart for PostgreSQL
type: application
home: https://signoz.io/
icon: https://wiki.postgresql.org/wiki/File:PostgreSQL_logo.3colors.svg
sources:
- https://github.com/signoz/charts
- https://github.com/postgres/postgres
maintainers:
- name: SigNoz
email: hello@signoz.io
url: https://signoz.io

543
charts/postgresql/README.md Normal file
View File

@@ -0,0 +1,543 @@
# PostgreSQL
![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 15.0.0](https://img.shields.io/badge/AppVersion-15.0.0-informational?style=flat-square)
This Helm chart is installed as a subchart/dependency of the SigNoz Helm chart with default values.
### TL;DR;
```sh
helm repo add signoz https://charts.signoz.io
helm install -n platform --create-namespace "my-release" signoz/postgresql
```
### Introduction
SigNoz uses a relational database like SQLite, Postgres exclusively for storing metadata and control-plane information, such as organizations, users, dashboards, and configurations.
It does not replace ClickHouse, which remains necessary for storing and querying all observability telemetry data (traces, metrics, and logs).
Refer to the documentation for a more detailed explanation of [Relational Database in Signoz](https://signoz.io/docs/manage/administrator-guide/configuration/relational-database/)
### Prerequisites
- Kubernetes 1.16+
- Helm 3.0+
### Installing the Chart
To install the chart with the release name `my-release`:
```bash
helm repo add signoz https://charts.signoz.io
helm -n platform --create-namespace install "my-release" signoz/postgresql
```
To uninstall/delete the `my-release` resources:
```bash
helm -n platform uninstall "my-release"
```
See the [Helm docs](https://helm.sh/docs/helm/helm_uninstall/) for documentation on the helm uninstall command.
## Values
<h3>Other Values</h3>
<table>
<thead>
<th>Key</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td id="namespace"><a href="./values.yaml#L2">namespace</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Which namespace to install postgresql to (defaults to namespace chart is installed to)</td>
</tr>
<tr>
<td id="nameOverride"><a href="./values.yaml#L4">nameOverride</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Name override for postgresql</td>
</tr>
<tr>
<td id="fullnameOverride"><a href="./values.yaml#L6">fullnameOverride</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Fullname override for postgreql</td>
</tr>
<tr>
<td id="replicaCount"><a href="./values.yaml#L10">replicaCount</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">1</pre>
</div>
</td>
<td>Number of Postgres replicas.</td>
</tr>
<tr>
<td id="image--repository"><a href="./values.yaml#L15">image.repository</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">postgres</pre>
</div>
</td>
<td>Postgres image repository.</td>
</tr>
<tr>
<td id="image--tag"><a href="./values.yaml#L18">image.tag</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">"15"</pre>
</div>
</td>
<td>Postgres image tag.</td>
</tr>
<tr>
<td id="image--pullPolicy"><a href="./values.yaml#L21">image.pullPolicy</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">IfNotPresent</pre>
</div>
</td>
<td>Image pull policy.</td>
</tr>
<tr>
<td id="imagePullSecrets"><a href="./values.yaml#L25">imagePullSecrets</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Image pull secrets for Postgres pods</td>
</tr>
<tr>
<td id="service--annotations"><a href="./values.yaml#L30">service.annotations</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Annotations for the Postgres service object.</td>
</tr>
<tr>
<td id="service--labels"><a href="./values.yaml#L33">service.labels</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Labels for the Postgres service object.</td>
</tr>
<tr>
<td id="service--type"><a href="./values.yaml#L36">service.type</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">ClusterIP</pre>
</div>
</td>
<td>The service type (`ClusterIP`, `NodePort`, `LoadBalancer`).</td>
</tr>
<tr>
<td id="service--port"><a href="./values.yaml#L39">service.port</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">5432</pre>
</div>
</td>
<td>The external port for Postgres service</td>
</tr>
<tr>
<td id="auth--username"><a href="./values.yaml#L44">auth.username</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">signoz</pre>
</div>
</td>
<td>Username for the custom user to create.</td>
</tr>
<tr>
<td id="auth--password"><a href="./values.yaml#L47">auth.password</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">signoz@123</pre>
</div>
</td>
<td>Password for the custom user to create. Ignored if `auth.existingSecret` is provided.</td>
</tr>
<tr>
<td id="auth--database"><a href="./values.yaml#L50">auth.database</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Name for a custom database to create.</td>
</tr>
<tr>
<td id="auth--existingSecret"><a href="./values.yaml#L53">auth.existingSecret</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Name of existing secret to use for PostgreSQL credentials. `auth.password` will be ignored and picked up from this secret.</td>
</tr>
<tr>
<td id="auth--secretKeys--userPasswordKey"><a href="./values.yaml#L57">auth.secretKeys.userPasswordKey</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">password</pre>
</div>
</td>
<td>Name of key in existing secret to use for PostgreSQL credentials. Only used when `auth.existingSecret` is set.</td>
</tr>
<tr>
<td id="resources"><a href="./values.yaml#L61">resources</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Resource requests and limits for Postgres pods.</td>
</tr>
<tr>
<td id="priorityClassName"><a href="./values.yaml#L65">priorityClassName</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Priority class name for Postgres pods.</td>
</tr>
<tr>
<td id="podSecurityContext"><a href="./values.yaml#L69">podSecurityContext</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Security context for Postgres pods.</td>
</tr>
<tr>
<td id="securityContext"><a href="./values.yaml#L73">securityContext</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Container security context for Postgres containers.</td>
</tr>
<tr>
<td id="podAnnotations"><a href="./values.yaml#L77">podAnnotations</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Annotations for Postgres pods.</td>
</tr>
<tr>
<td id="annotations"><a href="./values.yaml#L81">annotations</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Additional annotations for Postgres resources.</td>
</tr>
<tr>
<td id="nodeSelector"><a href="./values.yaml#L85">nodeSelector</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Node selector for Postgres pods.</td>
</tr>
<tr>
<td id="tolerations"><a href="./values.yaml#L89">tolerations</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Tolerations for Postgres pods.</td>
</tr>
<tr>
<td id="affinity"><a href="./values.yaml#L93">affinity</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Affinity rules for Postgres pods.</td>
</tr>
<tr>
<td id="topologySpreadConstraints"><a href="./values.yaml#L97">topologySpreadConstraints</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Topology spread constraints for Postgres pods.</td>
</tr>
<tr>
<td id="livenessProbe--enabled"><a href="./values.yaml#L102">livenessProbe.enabled</a></td>
<td>bool</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">true</pre>
</div>
</td>
<td>Enable liveness probe.</td>
</tr>
<tr>
<td id="livenessProbe--initialDelaySeconds"><a href="./values.yaml#L105">livenessProbe.initialDelaySeconds</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">20</pre>
</div>
</td>
<td>Initial delay seconds for liveness probe.</td>
</tr>
<tr>
<td id="livenessProbe--periodSeconds"><a href="./values.yaml#L108">livenessProbe.periodSeconds</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">10</pre>
</div>
</td>
<td>Period seconds for liveness probe.</td>
</tr>
<tr>
<td id="livenessProbe--timeoutSeconds"><a href="./values.yaml#L111">livenessProbe.timeoutSeconds</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">5</pre>
</div>
</td>
<td>Timeout seconds for liveness probe.</td>
</tr>
<tr>
<td id="livenessProbe--successThreshold"><a href="./values.yaml#L114">livenessProbe.successThreshold</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">1</pre>
</div>
</td>
<td>Success threshold for liveness probe.</td>
</tr>
<tr>
<td id="livenessProbe--failureThreshold"><a href="./values.yaml#L117">livenessProbe.failureThreshold</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">6</pre>
</div>
</td>
<td>Failure threshold for liveness probe.</td>
</tr>
<tr>
<td id="readinessProbe--enabled"><a href="./values.yaml#L122">readinessProbe.enabled</a></td>
<td>bool</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">true</pre>
</div>
</td>
<td>Enable readiness probe.</td>
</tr>
<tr>
<td id="readinessProbe--initialDelaySeconds"><a href="./values.yaml#L125">readinessProbe.initialDelaySeconds</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">5</pre>
</div>
</td>
<td>Initial delay seconds for readiness probe.</td>
</tr>
<tr>
<td id="readinessProbe--periodSeconds"><a href="./values.yaml#L128">readinessProbe.periodSeconds</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">5</pre>
</div>
</td>
<td>Period seconds for readiness probe.</td>
</tr>
<tr>
<td id="readinessProbe--timeoutSeconds"><a href="./values.yaml#L131">readinessProbe.timeoutSeconds</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">3</pre>
</div>
</td>
<td>Timeout seconds for readiness probe.</td>
</tr>
<tr>
<td id="readinessProbe--successThreshold"><a href="./values.yaml#L134">readinessProbe.successThreshold</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">1</pre>
</div>
</td>
<td>Success threshold for readiness probe.</td>
</tr>
<tr>
<td id="readinessProbe--failureThreshold"><a href="./values.yaml#L137">readinessProbe.failureThreshold</a></td>
<td>int</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">6</pre>
</div>
</td>
<td>Failure threshold for readiness probe.</td>
</tr>
<tr>
<td id="persistence--enabled"><a href="./values.yaml#L142">persistence.enabled</a></td>
<td>bool</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">true</pre>
</div>
</td>
<td>Enable persistent storage for Postgres.</td>
</tr>
<tr>
<td id="persistence--existingClaim"><a href="./values.yaml#L145">persistence.existingClaim</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Use an existing PVC for Postgres data.</td>
</tr>
<tr>
<td id="persistence--size"><a href="./values.yaml#L148">persistence.size</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">10Gi</pre>
</div>
</td>
<td>Size of the persistent volume claim.</td>
</tr>
<tr>
<td id="persistence--storageClass"><a href="./values.yaml#L151">persistence.storageClass</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">null</pre>
</div>
</td>
<td>Storage class for the persistent volume claim.</td>
</tr>
<tr>
<td id="persistence--accessModes"><a href="./values.yaml#L154">persistence.accessModes</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">- ReadWriteOnce</pre>
</div>
</td>
<td>Access modes for the persistent volume claim.</td>
</tr>
<tr>
<td id="persistence--mountPath"><a href="./values.yaml#L158">persistence.mountPath</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">/signoz/postgresql</pre>
</div>
</td>
<td>Mount path for Postgres data.</td>
</tr>
<tr>
<td id="persistence--subPath"><a href="./values.yaml#L161">persistence.subPath</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">""</pre>
</div>
</td>
<td>Subpath within the volume for Postgres data.</td>
</tr>
<tr>
<td id="persistence--dataDir"><a href="./values.yaml#L164">persistence.dataDir</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">/signoz/postgresql/data</pre>
</div>
</td>
<td>Data directory for Postgres data.</td>
</tr>
<tr>
<td id="additionalArgs"><a href="./values.yaml#L168">additionalArgs</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Additional command-line arguments for Postgres containers.</td>
</tr>
<tr>
<td id="additionalVolumes"><a href="./values.yaml#L172">additionalVolumes</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Additional volumes for Postgres pods.</td>
</tr>
<tr>
<td id="additionalVolumeMounts"><a href="./values.yaml#L176">additionalVolumeMounts</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Additional volume mounts for Postgres containers.</td>
</tr>
<tr>
<td id="extraEnv"><a href="./values.yaml#L180">extraEnv</a></td>
<td>list</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">[]</pre>
</div>
</td>
<td>Extra environment variables for Postgres containers.</td>
</tr>
<tr>
<td id="serviceAccount--create"><a href="./values.yaml#L185">serviceAccount.create</a></td>
<td>bool</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">true</pre>
</div>
</td>
<td>Specifies whether a service account should be created.</td>
</tr>
<tr>
<td id="serviceAccount--annotations"><a href="./values.yaml#L188">serviceAccount.annotations</a></td>
<td>object</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">{}</pre>
</div>
</td>
<td>Annotations to add to the service account.</td>
</tr>
<tr>
<td id="serviceAccount--name"><a href="./values.yaml#L191">serviceAccount.name</a></td>
<td>string</td>
<td>
<div style="max-width: 300px;"><pre lang="yaml">null</pre>
</div>
</td>
<td>The name of the service account to use. If not set and `create` is true, a name is generated.</td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,122 @@
# PostgreSQL
{{ template "chart.badgesSection" . }}
This Helm chart is installed as a subchart/dependency of the SigNoz Helm chart with default values.
### TL;DR;
```sh
helm repo add signoz https://charts.signoz.io
helm install -n platform --create-namespace "my-release" signoz/{{ template "chart.name" .}}
```
### Introduction
SigNoz uses a relational database like SQLite, Postgres exclusively for storing metadata and control-plane information, such as organizations, users, dashboards, and configurations.
It does not replace ClickHouse, which remains necessary for storing and querying all observability telemetry data (traces, metrics, and logs).
Refer to the documentation for a more detailed explanation of [Relational Database in Signoz](https://signoz.io/docs/manage/administrator-guide/configuration/relational-database/)
### Prerequisites
- Kubernetes 1.16+
- Helm 3.0+
### Installing the Chart
To install the chart with the release name `my-release`:
```bash
helm repo add signoz https://charts.signoz.io
helm -n platform --create-namespace install "my-release" signoz/{{ template "chart.name" . }}
```
To uninstall/delete the `my-release` resources:
```bash
helm -n platform uninstall "my-release"
```
See the [Helm docs](https://helm.sh/docs/helm/helm_uninstall/) for documentation on the helm uninstall command.
{{ define "chart.valueDefaultColumnRender" }}
{{- $defaultValue := (default .Default .AutoDefault) -}}
{{- if (and (hasPrefix "" $defaultValue) (hasSuffix "" $defaultValue) ) -}}
{{- $defaultValue = (toYaml (fromJson (trimAll "`" $defaultValue) ) ) -}}
{{- end -}}
<pre lang="yaml">{{ $defaultValue }}</pre>
{{ end }}
{{ define "chart.valuesTableHtml" }}
{{/* Handle explicitly defined sections */}}
{{- range .Sections.Sections }}
{{- if (eq .SectionName "Presets Configuration")}}
{{- $item := index .SectionItems 0 -}}
<h3>{{- .SectionName }}</h3>
<p>{{ if $item.Description }}{{ $item.Description }}{{ else }}{{ $item.AutoDescription }}{{ end }}.</p>
{{- else}}
{{- if contains "Presets" .SectionName}}
<h4>{{- .SectionName}}</h4>
{{- else}}
<h3>{{- .SectionName }}</h3>
{{- end}}
<table>
<thead>
<th>Key</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</thead>
<tbody>
{{- range .SectionItems }}
<tr>
<td id="{{ .Key | replace "." "--" }}"><a href="./values.yaml#L{{ .LineNumber }}">{{ .Key }}</a></td>
<td>{{.Type}}</td>
<td>
<div style="max-width: 300px;">{{ template "chart.valueDefaultColumnRender" . }}</div>
</td>
<td>{{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }}</td>
</tr>
{{- end }}
</tbody>
</table>
{{- end}}
{{- end }}
{{/* Handle the default section for any un-annotated values */}}
{{ if .Sections.DefaultSection.SectionItems }}
<h3>{{- .Sections.DefaultSection.SectionName }}</h3>
<table>
<thead>
<th>Key</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</thead>
<tbody>
{{- range .Sections.DefaultSection.SectionItems }}
<tr>
<td id="{{ .Key | replace "." "--" }}"><a href="./values.yaml#L{{ .LineNumber }}">{{ .Key }}</a></td>
<td>{{ .Type }}</td>
<td>
<div style="max-width: 300px;">{{ template "chart.valueDefaultColumnRender" . }}</div>
</td>
<td>{{ if .Description }}{{ .Description }}{{ else }}{{ .AutoDescription }}{{ end }}</td>
</tr>
{{- end }}
</tbody>
</table>
{{ end }}
{{ end }}
{{ define "chart.valuesSectionHtml" }}
{{ if .Sections }}
{{ template "chart.valuesHeader" . }}
{{ template "chart.valuesTableHtml" . }}
{{ end }}
{{ end }}
{{ template "chart.valuesSectionHtml" . }}

View File

@@ -0,0 +1,158 @@
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "postgresql.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name for SigNoz.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "postgresql.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Standard labels for postgres resources
*/}}
{{- define "postgresql.labels" -}}
helm.sh/chart: {{ include "postgresql.chart" . }}
{{ include "postgresql.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels (used for StatefulSet selector and Pod template)
*/}}
{{- define "postgresql.selectorLabels" -}}
app.kubernetes.io/name: {{ include "postgresql.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Base name for the chart
*/}}
{{- define "postgresql.name" -}}
{{- default "postgres" .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
ServiceAccount name
*/}}
{{- define "postgresql.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "postgresql.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{- define "postgresql.imagePullSecrets" -}}
{{- if or .Values.global.imagePullSecrets .Values.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- range .Values.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Return the proper signoz image name
*/}}
{{- define "postgresql.image" -}}
{{- $registryName := default .Values.image.registry .Values.global.imageRegistry -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $tag := default .Chart.AppVersion .Values.image.tag | toString -}}
{{- if $registryName -}}
{{- printf "%s/%s:%s" $registryName $repositoryName $tag -}}
{{- else -}}
{{- printf "%s:%s" $repositoryName $tag -}}
{{- end -}}
{{- end -}}
{{/*
Auth secret name
*/}}
{{- define "postgresql.authSecretName" -}}
{{ printf "%s-auth" (include "postgresql.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Postgres ENV
*/}}
{{- define "postgresql.env" -}}
{{- $env := dict -}}
{{- $_ := set $env "POSTGRESQL_PORT_NUMBER" (.Values.service.port | toString) -}}
{{- $_ := set $env "POSTGRESQL_VOLUME_DIR" .Values.persistence.mountPath -}}
{{- $_ := set $env "PGDATA" .Values.persistence.dataDir -}}
{{- $_ := set $env "POSTGRES_USER" .Values.auth.username -}}
{{- if .Values.auth.existingSecret }}
{{- $secretCfg := default dict .Values.auth.secretKeys -}}
{{- $secretKey := default "password" (get $secretCfg "userPasswordKey") -}}
{{- $_ := set $env "POSTGRES_PASSWORD" (dict "valueFrom" (dict "secretKeyRef" (dict "name" .Values.auth.existingSecret "key" $secretKey ))) -}}
{{- else }}
{{- $_ := set $env "POSTGRES_PASSWORD" .Values.auth.password -}}
{{- end }}
{{- if .Values.auth.database }}
{{- $_ := set $env "POSTGRES_DB" .Values.auth.database -}}
{{- end }}
{{- if .Values.extraEnv }}
{{- range .Values.extraEnv }}
{{- $_ := set $env .name .value -}}
{{- end }}
{{- end }}
{{- template "postgresql.renderEnv" $env -}}
{{- end}}
{{/*
Function to render environment variables
*/}}
{{- define "postgresql.renderEnv" -}}
{{- $dict := . -}}
{{- $processedKeys := dict -}}
{{- range keys . | sortAlpha | reverse }}
{{- $val := pluck . $dict | first -}}
{{- $key := upper . -}}
{{- if not (hasKey $processedKeys $key) }}
{{- $processedKeys = merge $processedKeys (dict $key true) -}}
{{- $valueType := printf "%T" $val -}}
{{- if eq $valueType "map[string]interface {}" }}
- name: {{ $key }}
{{ toYaml $val | indent 2 -}}
{{- else if eq $valueType "string" }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- else }}
- name: {{ $key }}
value: {{ $val | quote}}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "postgresql.service.ifClusterIP" -}}
{{- if (eq . "ClusterIP") }}
nodePort: null
{{- end }}
{{- end }}

View File

@@ -0,0 +1,28 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "postgresql.fullname" . }}
labels:
{{- include "postgresql.labels" . | nindent 4 }}
{{- with .Values.service }}
{{- if .labels }}
{{- toYaml .labels | nindent 4 }}
{{- end }}
{{- if .annotations }}
annotations:
{{- toYaml .annotations | nindent 4 }}
{{- end }}
spec:
type: {{ .type }}
ports:
- name: tcp-postgresql
port: {{ .port }}
{{- include "postgresql.service.ifClusterIP" .type | indent 6 }}
protocol: TCP
targetPort: tcp-postgresql
{{- if (and (eq .type "NodePort") .nodePort) }}
nodePort: {{ .nodePort }}
{{- end }}
{{- end }}
selector:
{{- include "postgresql.selectorLabels" . | nindent 4 }}

View File

@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "postgresql.serviceAccountName" . }}
labels:
{{- include "postgresql.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "postgresql.imagePullSecrets" . }}
{{- end -}}

View File

@@ -0,0 +1,160 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "postgresql.fullname" . }}
labels:
{{- include "postgresql.labels" . | nindent 4 }}
{{- if .Values.annotations }}
annotations:
{{- toYaml .Values.annotations | nindent 4 }}
{{- end }}
spec:
serviceName: {{ include "postgresql.fullname" . }}
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "postgresql.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- if .Values.podAnnotations }}
annotations:
{{- toYaml .Values.podAnnotations | nindent 8 }}
{{- end }}
labels:
{{- include "postgresql.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ . | quote }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "postgresql.serviceAccountName" . }}
priorityClassName: {{ .Values.priorityClassName | quote }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- with .Values.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: postgres
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: {{ template "postgresql.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: tcp-postgresql
containerPort: {{ default 5432 .Values.service.port }}
protocol: TCP
env:
{{- include "postgresql.env" . | nindent 12 }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
exec:
command:
- /bin/sh
- -c
- exec pg_isready -U "$POSTGRES_USER" -h 127.0.0.1 -p {{ default 5432 .Values.service.port }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- else if .Values.customLivenessProbe }}
livenessProbe: {{- toYaml .Values.customLivenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
exec:
command:
- /bin/sh
- -c
- exec pg_isready -U "$POSTGRES_USER" -d {{ .Values.auth.database | quote }} -h 127.0.0.1 -p {{ default 5432 .Values.service.port }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- else if .Values.customReadinessProbe }}
readinessProbe: {{- toYaml .Values.customReadinessProbe | nindent 12 }}
{{- end }}
args:
{{- range .Values.additionalArgs }}
- {{ . | quote }}
{{- end }}
volumeMounts:
- name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- name: empty-dir
mountPath: /opt/bitnami/postgresql/conf
subPath: app-conf-dir
- name: empty-dir
mountPath: /opt/bitnami/postgresql/tmp
subPath: app-tmp-dir
- name: pgdata
mountPath: {{ .Values.persistence.mountPath }}
{{- if .Values.persistence.subPath }}
subPath: {{ .Values.persistence.subPath }}
{{- end }}
{{- if .Values.additionalVolumeMounts }}
{{- toYaml .Values.additionalVolumeMounts | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: empty-dir
emptyDir: {}
{{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
- name: pgdata
persistentVolumeClaim:
claimName: {{ tpl .Values.persistence.existingClaim $ }}
{{- else if not .Values.persistence.enabled }}
- name: pgdata
emptyDir: {}
{{- end }}
{{- if .Values.additionalVolumes }}
{{- toYaml .Values.additionalVolumes | nindent 8 }}
{{- end }}
{{- if and (.Values.persistence.enabled) (not .Values.persistence.existingClaim) }}
volumeClaimTemplates:
- metadata:
name: pgdata
spec:
accessModes:
{{- toYaml .Values.persistence.accessModes | nindent 10 }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- $storageClass := default .Values.persistence.storageClass .Values.global.storageClass -}}
{{- if $storageClass -}}
{{- if (eq "-" $storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: {{ $storageClass }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,73 @@
suite: Test PostgreSQL Environment Variable
templates:
- templates/statefulset.yaml
tests:
- it: should correctly render the default key-value environment variables for postgres.
set:
enabled: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_USER
value: "signoz"
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_PASSWORD
value: "signoz123"
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_DB
value: "signoz"
- contains:
path: spec.template.spec.containers[0].env
content:
name: PGDATA
value: "/var/lib/postgresql/data"
- it: should render custom auth env Variables
set:
enabled: true
auth:
username: "abc"
password: "123"
database: "xyz"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_USER
value: "abc"
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_PASSWORD
value: "123"
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_DB
value: "xyz"
- it: should render secret keys for auth env Variables
set:
enabled: true
auth:
existingSecret: "postgres-secret"
secretKeys:
userPasswordKey: "password"
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "postgres-secret"
key: "password"

View File

@@ -0,0 +1,109 @@
suite: Test PostgreSQL Persistence Variables
templates:
- templates/statefulset.yaml
release:
name: postgresql
namespace: signoz
tests:
- it: should render 4 volumes mounts and 1 volume when persistence.enabled=true
set:
persistence:
enabled: true
size: 10Gi
asserts:
- contains:
path: spec.template.spec.containers[0].volumeMounts
count: 1
content:
name: pgdata
mountPath: /var/lib/postgresql
- contains:
path: spec.template.spec.containers[0].volumeMounts
count: 1
content:
name: empty-dir
mountPath: /tmp
subPath: tmp-dir
- contains:
path: spec.template.spec.containers[0].volumeMounts
count: 1
content:
name: empty-dir
mountPath: /opt/bitnami/postgresql/conf
subPath: app-conf-dir
- contains:
path: spec.template.spec.containers[0].volumeMounts
count: 1
content:
name: empty-dir
mountPath: /opt/bitnami/postgresql/tmp
subPath: app-tmp-dir
- contains:
path: spec.template.spec.volumes
count: 1
content:
name: empty-dir
emptyDir: {}
- it: should have pgdata-volumeclaim-template when persistence.enabled=true
set:
enabled: true
persistence:
enabled: true
size: 10Gi
asserts:
- contains:
path: spec.volumeClaimTemplates
count: 1
content:
metadata:
name: pgdata
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
- contains:
path: spec.template.spec.containers[0].volumeMounts
count: 1
content:
name: pgdata
mountPath: /var/lib/postgresql
- it: should render additional volumes and additional volume mounts
set:
enabled: true
persistence:
enabled: true
additionalVolumeMounts:
- mountPath: /does-not-matter
name: does-not-matter
additionalVolumes:
- name: does-not-matter
emptyDir: {}
asserts:
- contains:
path: spec.volumeClaimTemplates
count: 1
content:
metadata:
name: pgdata
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
- contains:
path: spec.template.spec.containers[0].volumeMounts
count: 1
content:
name: does-not-matter
mountPath: /does-not-matter
- contains:
path: spec.template.spec.volumes
count: 1
content:
name: does-not-matter
emptyDir: {}

View File

@@ -0,0 +1,191 @@
# namespace -- Which namespace to install postgresql to (defaults to namespace chart is installed to)
namespace: ""
# -- Name override for postgresql
nameOverride: ""
# -- Fullname override for postgreql
fullnameOverride: ""
# replicaCount -- Number of Postgres replicas.
# @default -- 1
replicaCount: 1
image:
# image.repository -- Postgres image repository.
# @default -- "postgres"
repository: postgres
# image.tag -- Postgres image tag.
# @default -- "15"
tag: 15
# image.pullPolicy -- Image pull policy.
# @default -- "IfNotPresent"
pullPolicy: IfNotPresent
# imagePullSecrets -- Image pull secrets for Postgres pods
# @default -- []
imagePullSecrets: []
service:
# service.annotations -- Annotations for the Postgres service object.
# @default -- {}
annotations: {}
# service.labels -- Labels for the Postgres service object.
# @default -- {}
labels: {}
# service.type -- The service type (`ClusterIP`, `NodePort`, `LoadBalancer`).
# @default -- "ClusterIP"
type: ClusterIP
# service.port -- The external port for Postgres service
# @default -- 5432
port: 5432
auth:
# auth.username -- Username for the custom user to create.
# @default -- "signoz"
username: "signoz"
# auth.password -- Password for the custom user to create. Ignored if `auth.existingSecret` is provided.
# @default -- "signoz@123"
password: "signoz123"
# auth.database -- Name for a custom database to create.
# @default -- ""
database: "signoz"
# auth.existingSecret -- Name of existing secret to use for PostgreSQL credentials. `auth.password` will be ignored and picked up from this secret.
# @default -- ""
existingSecret: ""
secretKeys:
# auth.secretKeys.userPasswordKey -- Name of key in existing secret to use for PostgreSQL credentials. Only used when `auth.existingSecret` is set.
# @default -- "password"
userPasswordKey: ""
# resources -- Resource requests and limits for Postgres pods.
# @default -- {}
resources: {}
# priorityClassName -- Priority class name for Postgres pods.
# @default -- ""
priorityClassName: ""
# podSecurityContext -- Security context for Postgres pods.
# @default -- {}
podSecurityContext: {}
# securityContext -- Container security context for Postgres containers.
# @default -- {}
securityContext: {}
# podAnnotations -- Annotations for Postgres pods.
# @default -- {}
podAnnotations: {}
# annotations -- Additional annotations for Postgres resources.
# @default -- {}
annotations: {}
# nodeSelector -- Node selector for Postgres pods.
# @default -- {}
nodeSelector: {}
# tolerations -- Tolerations for Postgres pods.
# @default -- []
tolerations: []
# affinity -- Affinity rules for Postgres pods.
# @default -- {}
affinity: {}
# topologySpreadConstraints -- Topology spread constraints for Postgres pods.
# @default -- []
topologySpreadConstraints: []
livenessProbe:
# livenessProbe.enabled -- Enable liveness probe.
# @default -- true
enabled: true
# livenessProbe.initialDelaySeconds -- Initial delay seconds for liveness probe.
# @default -- 20
initialDelaySeconds: 20
# livenessProbe.periodSeconds -- Period seconds for liveness probe.
# @default -- 10
periodSeconds: 10
# livenessProbe.timeoutSeconds -- Timeout seconds for liveness probe.
# @default -- 5
timeoutSeconds: 5
# livenessProbe.successThreshold -- Success threshold for liveness probe.
# @default -- 1
successThreshold: 1
# livenessProbe.failureThreshold -- Failure threshold for liveness probe.
# @default -- 6
failureThreshold: 6
readinessProbe:
# readinessProbe.enabled -- Enable readiness probe.
# @default -- true
enabled: true
# readinessProbe.initialDelaySeconds -- Initial delay seconds for readiness probe.
# @default -- 5
initialDelaySeconds: 5
# readinessProbe.periodSeconds -- Period seconds for readiness probe.
# @default -- 5
periodSeconds: 5
# readinessProbe.timeoutSeconds -- Timeout seconds for readiness probe.
# @default -- 3
timeoutSeconds: 3
# readinessProbe.successThreshold -- Success threshold for readiness probe.
# @default -- 1
successThreshold: 1
# readinessProbe.failureThreshold -- Failure threshold for readiness probe.
# @default -- 6
failureThreshold: 6
persistence:
# persistence.enabled -- Enable persistent storage for Postgres.
# @default -- true
enabled: true
# persistence.existingClaim -- Use an existing PVC for Postgres data.
# @default -- ""
existingClaim: ""
# persistence.size -- Size of the persistent volume claim.
# @default -- "10Gi"
size: 10Gi
# persistence.storageClass -- Storage class for the persistent volume claim.
# @default -- null
storageClass: null
# persistence.accessModes -- Access modes for the persistent volume claim.
# @default -- ["ReadWriteOnce"]
accessModes:
- ReadWriteOnce
# persistence.mountPath -- Mount path for Postgres data.
# @default -- "/signoz/postgresql"
mountPath: /var/lib/postgresql
# persistence.subPath -- Subpath within the volume for Postgres data.
# @default -- ""
subPath: ""
# persistence.dataDir -- Data directory for Postgres data.
# @default -- "/signoz/postgresql/data"
dataDir: /var/lib/postgresql/data
# additionalArgs -- Additional command-line arguments for Postgres containers.
# @default -- []
additionalArgs: []
# additionalVolumes -- Additional volumes for Postgres pods.
# @default -- []
additionalVolumes: []
# additionalVolumeMounts -- Additional volume mounts for Postgres containers.
# @default -- []
additionalVolumeMounts: []
# extraEnv -- Extra environment variables for Postgres containers.
# @default -- []
extraEnv: []
serviceAccount:
# serviceAccount.create -- Specifies whether a service account should be created.
# @default -- true
create: true
# serviceAccount.annotations -- Annotations to add to the service account.
# @default -- {}
annotations: {}
# serviceAccount.name -- The name of the service account to use. If not set and `create` is true, a name is generated.
# @default -- null
name: