Skip to content

Commit

Permalink
Added Image Catalog Reference
Browse files Browse the repository at this point in the history
Signed-off-by: Bulat Gafurov <[email protected]>
  • Loading branch information
paraddise committed May 5, 2024
1 parent 9c668bc commit 213eabe
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions charts/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat
| cluster.certificates | object | `{}` | The configuration for the CA and related certificates. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-CertificatesConfiguration |
| cluster.enableSuperuserAccess | bool | `true` | When this option is enabled, the operator will use the SuperuserSecret to update the postgres user password. If the secret is not present, the operator will automatically create one. When this option is disabled, the operator will ignore the SuperuserSecret content, delete it when automatically created, and then blank the password of the postgres user by setting it to NULL. |
| cluster.imageName | string | `""` | Name of the container image, supporting both tags (<image>:<tag>) and digests for deterministic and repeatable deployments: <image>:<tag>@sha256:<digestValue> |
| cluster.imageCatalogRef | object | `{}` | Reference to `ImageCatalog` of `ClusterImageCatalog`, if specified takes precedence over `cluster.imageName` |
| cluster.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy. One of Always, Never or IfNotPresent. If not defined, it defaults to IfNotPresent. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images |
| cluster.imagePullSecrets | list | `[]` | The list of pull secrets to be used to pull the images. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-LocalObjectReference |
| cluster.initdb | object | `{}` | BootstrapInitDB is the configuration of the bootstrap process when initdb is used. See: https://cloudnative-pg.io/documentation/current/bootstrap/ See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-bootstrapinitdb |
Expand Down
9 changes: 5 additions & 4 deletions charts/cluster/docs/Getting Started.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started

The CNPG cluster chart follows a convention over configuration approach. This means that the chart will create a reasonable
The CNPG cluster chart follows a convention over configuration approach. This means that the chart will create a reasonable
CNPG setup with sensible defaults. However, you can override these defaults to create a more customized setup. Note that
you still need to configure backups and monitoring separately. The chart will not install a Prometheus stack for you.

Expand Down Expand Up @@ -44,7 +44,7 @@ are likely looking for the `standalone` option.

### Backup configuration

Most importantly you should configure your backup storage.
Most importantly you should configure your backup storage.

CNPG implements disaster recovery via [Barman](https://pgbarman.org/). The following section configures the barman object
store where backups will be stored. Barman performs backups of the cluster filesystem base backup and WALs. Both are
Expand Down Expand Up @@ -76,10 +76,11 @@ There are several important cluster options. Here are the most important ones:

`cluster.instances` - The number of instances in the cluster. Defaults to `1`, but you should set this to `3` for production.
`cluster.imageName` - This allows you to override the Docker image used for the cluster. The chart will choose a default
for you based on the setting you chose for `type`. If you need to run a configuration that is not supported, you can
for you based on the setting you chose for `type`. If you need to run a configuration that is not supported, you can
create your own Docker image. You can use the [postgres-containers](https://github.com/cloudnative-pg/postgres-containers)
repository for a starting point.
You will likely need to set your own repository access credentials via: `cluster.imagePullPolicy` and `cluster.imagePullSecrets`.
`cluster.imageCatalogRef` - This allows you to specify version from ImageCatalog or ClusterImageCatalog. If both `cluster.imageName` and `cluster.imageCatalogRef`, later takes precedence.
`cluster.storage.size` - The size of the persistent volume claim for the cluster. Defaults to `8Gi`. Every instance will
have it's own persistent volume claim.
`cluster.storage.storageClass` - The storage class to use for the persistent volume claim.
Expand All @@ -93,7 +94,7 @@ There are several important cluster options. Here are the most important ones:
cluster:
postgresql:
max_connections: "200"
shared_buffers: "2GB"
shared_buffers: "2GB"
```
`cluster.initSQL` - Allows you to run custom SQL queries during the cluster initialization. This is useful for creating
extensions, schemas and databases. Note that these are as a superuser.
Expand Down
10 changes: 10 additions & 0 deletions charts/cluster/examples/image-catalog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mode: standalone
cluster:
instances: 1
imageCatalogRef:
apiGroup: postgresql.cnpg.io
kind: ClusterImageCatalog
name: postgresql
major: 16
backups:
enabled: false
4 changes: 4 additions & 0 deletions charts/cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ Configuration
┝━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┥
│ Cluster mode │ {{ (printf "%-54s" .Values.mode) }} │
│ Type │ {{ (printf "%-54s" .Values.type) }} │
{{- if .Values.cluster.imageCatalogRef }}
| Image | {{ include "cluster.color-info" (printf "%-54s" (printf "%s/%s:%v" .Values.cluster.imageCatalogRef.kind .Values.cluster.imageCatalogRef.name .Values.cluster.imageCatalogRef.major)) }} │
{{- else }}
│ Image │ {{ include "cluster.color-info" (printf "%-54s" (include "cluster.imageName" .)) }} │
{{- end }}
│ Instances │ {{ include (printf "%s%s" "cluster.color-" $redundancyColor) (printf "%-54s" (toString .Values.cluster.instances)) }} │
│ Backups │ {{ include (printf "%s%s" "cluster.color-" (ternary "ok" "error" .Values.backups.enabled)) (printf "%-54s" (ternary "Enabled" "Disabled" .Values.backups.enabled)) }} │
│ Backup Provider │ {{ (printf "%-54s" (title .Values.backups.provider)) }} │
Expand Down
16 changes: 16 additions & 0 deletions charts/cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,19 @@ If a custom imageName is available, use it, otherwise use the defaults based on
{{ fail "Invalid cluster type!" }}
{{- end }}
{{- end -}}

{{/*
Cluster Image
If imageCatalogRef defined, use it, otherwice calculate ordinary imageName.
*/}}
{{- define "cluster.image" }}
{{- if .Values.cluster.imageCatalogRef }}
{{- with .Values.cluster.imageCatalogRef }}
imageCatalogRef:
{{- toYaml . | nindent 2 -}}
{{- end }}
{{- else }}
imageName: {{ include "cluster.imageName" . }}
{{- end }}
{{- end }}

2 changes: 1 addition & 1 deletion charts/cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ metadata:
{{- end }}
spec:
instances: {{ .Values.cluster.instances }}
imageName: {{ include "cluster.imageName" . }}
{{- include "cluster.image" . | nindent 2 }}
imagePullPolicy: {{ .Values.cluster.imagePullPolicy }}
{{- with .Values.cluster.imagePullSecrets}}
imagePullSecrets:
Expand Down
7 changes: 7 additions & 0 deletions charts/cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ cluster:
# <image>:<tag>@sha256:<digestValue>
imageName: "" # Default value depends on type (postgresql/postgis/timescaledb)

# -- Image Catalog Reference
imageCatalogRef: {}
# apiGroup: postgresql.cnpg.io
# kind: ClusterImageCatalog
# name: postgresql
# major: 16

# -- Image pull policy. One of Always, Never or IfNotPresent. If not defined, it defaults to IfNotPresent. Cannot be updated.
# More info: https://kubernetes.io/docs/concepts/containers/images#updating-images
imagePullPolicy: IfNotPresent
Expand Down

0 comments on commit 213eabe

Please sign in to comment.