Abstract
Helm PostgreSQL documentation master file, created by sphinx-quickstart on Sun Apr 28 15:35:08 2024. You can adapt this file completely to your liking, but it should at least contain the root toctree
directive.
Postgres Helm Chart#
Repository Contents#
Indices and tables#
This chart deploys PostgreSQL in either a single-node or cluster configuration.
Usage#
Install#
To install this chart follow these steps.
Create a namespace.
kubectl create ns postgresql
Install the unittest Helm plugin.
helm plugin install https://github.com/helm-unittest/helm-unittest
Run the unit tests.
helm unittest -f 'tests/*.yaml' .
You should see output similar to this.
### Chart [ postgresql ] . PASS PostgreSQL Service Test Suite tests/service_test.yaml PASS PostgreSQL ServiceAccount Test Suite tests/serviceaccount_test.yaml PASS PostgreSQL StatefulSet Test Suite tests/statefulset_test.yaml Charts: 1 passed, 1 total Test Suites: 3 passed, 3 total Tests: 9 passed, 9 total Snapshot: 0 passed, 0 total Time: 92.722398ms
Install the chart with Helm.
helm -n postgresql install postgresql .
Run the tests included with Helm.
helm -n postgresql test postgresql
Uninstall#
This can be done in the usual way.
helm -n postgresql uninstall postgresql
Chart#
- apiVersion
PostgreSQL Helm Chart
This chart deploys a PostgreSQL server in either single server or cluster configuration.
apiVersion: v2
- appVersion
PostgreSQL version
This is the version number of the application being deployed. This version number should be incremented each time you make changes to the application. Versions are not expected to follow Semantic Versioning. They should reflect the version the application is using. It is recommended to use it with quotes.
appVersion: "16.3"
- description
Chart Description
This is the chart description.
description: PostgreSQL deployed as a single server or a cluster.
- icon
Icon
Helm Chart icon path.
icon: file://./assets/icon/postgresql.jpeg
- name
name: postgresql
- type
A chart can be either an ‘application’ or a ‘library’ chart.
Application charts are a collection of templates that can be packaged into versioned archives to be deployed.
Library charts provide useful utilities or functions for the chart developer. They’re included as 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.
type: application
- version
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. Versions are expected to follow Semantic Versioning (https://semver.org/)
Values#
- affinity
Default values for PostgreSQL deployment
Default values for postgresql. This is a YAML-formatted file. Declare variables to be passed into your templates.
values.yaml#affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/os operator: In values: - linux autoscaling: enabled: false maxReplicas: 3 minReplicas: 1 # targetMemoryUtilizationPercentage: 80 targetCPUUtilizationPercentage: 80 database: username: "postgres" password: "postgres" name: postgres fullnameOverride: "postgresql" image: pullPolicy: IfNotPresent repository: postgres # Overrides the image tag whose default is the chart appVersion. tag: "16-alpine" imagePullSecrets: []
- ingress
Liveness Probe
Check that the service is live.
ingress: annotations: kubernetes.io/ingress.class: nginx className: nginx enabled: true hosts: - host: pg.breeze-blocks.net paths: - path: / pathType: ImplementationSpecific name: postgresql port: 5432 tls: []
enable tls#kubernetes.io/tls-acme: "true" tls: - secretName: chart-example-tls hosts: - chart-example.local
- livenessProbe
Liveness Probe
Check that the service is live.
livenessProbe: exec: command: - pg_isready - -U - postgres # When to give up and restart the container failureThreshold: 3 # Delay before the first probe is initiated initialDelaySeconds: 30 # How often to perform the probe periodSeconds: 10 # Minimum consecutive successes for the probe to be considered successful # after having failed. successThreshold: 1 # When the probe times out timeoutSeconds: 5
- nameOverride
Name Override
Name and node selector config.
nameOverride: postgresql nodeSelector: kubernetes.io/os: linux
- persistence
Persistence
Persistence and other pod configuration.
persistence: claim: enabled: false name: postgresql size: 50Gi storageClass: csi-lvm-linear podAnnotations: {} podLabels: app: postgresql podSecurityContext: {}
fsGroup: 2000
- readinessProbe
Readiness Probe
Verify the service is ready for requests.
readinessProbe: exec: command: - pg_isready - -U - postgres # When to give up, marking the Pod as Unready failureThreshold: 3 # Delay before the first probe is initiated, can be shorter than # liveness probe initialDelaySeconds: 5 # How often to perform the probe periodSeconds: 5 # Minimum consecutive successes for the probe to be considered successful successThreshold: 1 # When the probe times out timeoutSeconds: 1 replicaCount: 1
fsGroup: 2000
- resources
Resources
Set request and limit for resources.
resources: limits: cpu: 1 memory: 2048Mi storage: 100Gi requests: cpu: 500m memory: 1024Mi storage: 50Gi
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: 128M
- securityContext
Security and Service
Define service and security context.
capabilities: drop: - ALL readOnlyRootFilesystem: true runAsNonRoot: true runAsUser: 1000
- serviceAccount
Security and Service
Define service and security context.
- volumeMounts
Volumes
Define volumes and mounts.
volumeMounts: [] volumes: []
Additional volumeMounts on the output Deployment definition.
- mountPath: "/mnt/local/psql" name: data readOnly: false - name: foo mountPath: "/etc/foo" readOnly: true
Additional volumes on the output Deployment definition.
- name: foo secret: secretName: mysecret optional: false
Section author: Xander Harris xandertheharris@gmail.com