Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/streaming replica #3313

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openshift/patroni-postgis/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FROM image-registry.openshift-image-registry.svc:5000/bcgov/patroni-postgres:12.4-latest

ENV POSTGIS_MAJOR 3
ENV POSTGIS_VERSION 3.3.1+dfsg-1.pgdg100+1
ENV POSTGIS_VERSION 3.3.4+dfsg-1.pgdg100+1

# Switch to root user for package installs
USER 0
Expand All @@ -12,6 +12,8 @@ USER 0
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
vim \
less \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts=$POSTGIS_VERSION \
&& rm -rf /var/lib/apt/lists/*
Expand Down
2 changes: 1 addition & 1 deletion openshift/patroni-postgis/openshift/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ labels:
app.kubernetes.io/version: "12"
parameters:
- name: NAME
value: patroni-postgres
value: patroni-postgres-vim
- name: SUFFIX
- name: VERSION
description: Output version
Expand Down
72 changes: 72 additions & 0 deletions openshift/scripts/oc_provision_crunchy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh -l
#
source "$(dirname ${0})/common/common"

#%
#% OpenShift Deploy Helper
#%
#% Intended for use with a pull request-based pipeline.
#% Suffixes incl.: pr-###.
#%
#% Usage:
#%
#% ${THIS_FILE} [SUFFIX] [apply]
#%
#% Examples:
#%
#% Provide a PR number. Defaults to a dry-run.
#% ${THIS_FILE} pr-0
#%
#% Apply when satisfied.
#% ${THIS_FILE} pr-0 apply
#%


# Target project override for Dev or Prod deployments
#
PROJ_TARGET="${PROJ_TARGET:-${PROJ_DEV}}"

# Prepare names for patroni ephemeral instance for this PR.
IMAGE_STREAM_NAMESPACE=${IMAGE_STREAM_NAMESPACE:-${PROJ_TOOLS}}
EPHEMERAL_STORAGE=${EPHEMERAL_STORAGE:-'False'}

# Process template
OC_PROCESS="oc -n ${PROJ_TARGET} process -f ${TEMPLATE_PATH}/crunchy.yaml \
-p NAME=\"crunchy-${APP_NAME}-${SUFFIX}\" \
-p SUFFIX=\"${SUFFIX}\" \
-p APP_USER=\"${APP_NAME}\" \
-p PARENT_NAME=\"${APP_NAME}\" \
-p TARGET_NAMESPACE=${PROJ_TARGET} \
${IMAGE_NAME:+ " -p IMAGE_NAME=${IMAGE_NAME}"} \
${IMAGE_TAG:+ " -p IMAGE_TAG=${IMAGE_TAG}"} \
${IMAGE_REGISTRY:+ " -p IMAGE_REGISTRY=${IMAGE_REGISTRY}"} \
${PVC_SIZE:+ " -p PVC_SIZE=${PVC_SIZE}"} \
${CPU_REQUEST:+ "-p CPU_REQUEST=${CPU_REQUEST}"} \
${CPU_LIMIT:+ "-p CPU_LIMIT=${CPU_LIMIT}"} \
${MEMORY_REQUEST:+ "-p MEMORY_REQUEST=${MEMORY_REQUEST}"} \
${MEMORY_LIMIT:+ "-p MEMORY_LIMIT=${MEMORY_LIMIT}"}"


# In order to avoid running out of storage quote in our development environment, use
# ephemeral storage by removing the pvc request from the template.
if [ "$EPHEMERAL_STORAGE" = "True" ]
then
# Pipe the template to jq, and delete the pvc and volume claim items from the template.
OC_PROCESS="${OC_PROCESS} | jq 'del(.items[2].spec.template.spec.volumes[0].persistentVolumeClaim) \
| del(.items[2].spec.volumeClaimTemplates)'"
fi

# Apply template (apply or use --dry-run)
#
OC_APPLY="oc -n ${PROJ_TARGET} apply -f -"
[ "${APPLY}" ] || OC_APPLY="${OC_APPLY} --dry-run=client"

# Execute commands
#

eval "${OC_PROCESS}"
eval "${OC_PROCESS} | ${OC_APPLY}"

# Provide oc command instruction
#
display_helper "${OC_PROCESS} | ${OC_APPLY}"
92 changes: 92 additions & 0 deletions openshift/templates/crunchy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: ${APP_NAME}-${SUFFIX}
annotations:
"openshift.io/display-name": ${APP_NAME}-${SUFFIX}
labels:
app.kubernetes.io/part-of: "${APP_NAME}"
app: ${APP_NAME}-${SUFFIX}
parameters:
- name: NAME
description: |
The name of the application for labelling all artifacts.
displayName: Application Name
required: true
- name: PARENT_NAME
description: |
The name of the primary application that uses this database.
displayName: Parent Application Name
required: true
- name: APP_USER
description: Username for database.
displayName: Username for database.
required: true
- description: Namespace in which database resides
displayName: Target Namespace
name: TARGET_NAMESPACE
required: true
- name: APP_NAME
description: Application name (wps - wildfire predictive services)
value: wps-crunchydb
required: true
- name: SUFFIX
description: Deployment suffix, e.g. pr-###
required: true
- name: IMAGE_REGISTRY
value: image-registry.apps.silver.devops.gov.bc.ca
- name: IMAGE_NAMESPACE
value: e1e498-tools
objects:
- apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: ${APP_NAME}-${SUFFIX}
spec:
image: artifacts.developer.gov.bc.ca/bcgov-docker-local/crunchy-postgres-gis:ubi8-14.7-3.2-0
metadata:
name: ${APP_NAME}-${SUFFIX}
labels:
app: ${APP_NAME}-${SUFFIX}
customTLSSecret:
name: custom.tls
customReplicationTLSSecret:
name: custom.tls
standby:
enabled: true
host: "patroni-wps-test-leader.e1e498-dev.svc.cluster.local"
port: 5432
users:
- name: ${APP_NAME}-${SUFFIX}
databases:
- postgres
options: "SUPERUSER"
postgresVersion: 14
instances:
- name: crunchy
dataVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
storageClassName: netapp-block-standard
walVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
storageClassName: netapp-block-standard
backups:
pgbackrest:
image: artifacts.developer.gov.bc.ca/bcgov-docker-local/crunchy-pgbackrest:ubi8-2.41-4
repos:
- name: repo1
volume:
volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
21 changes: 19 additions & 2 deletions openshift/templates/patroni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ objects:
volumeMounts:
- mountPath: /home/postgres/pgdata
name: postgresql
- name: certs
mountPath: "/home/postgres/certs"
readOnly: true
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
Expand All @@ -219,6 +222,20 @@ objects:
- name: postgresql
persistentVolumeClaim:
claimName: ${NAME}
- name: certs
projected:
defaultMode: 0640
sources:
- secret:
name: custom.tls
items:
- key: tls.crt
path: tls.crt
- key: tls.key
path: tls.key
- key: ca.crt
path: ca.crt

updateStrategy:
type: RollingUpdate
volumeClaimTemplates:
Expand Down Expand Up @@ -287,12 +304,12 @@ parameters:
- name: IMAGE_NAME
description: |
The Patroni image stream name
value: patroni-postgres
value: patroni-postgres-vim
- name: IMAGE_TAG
description: |
The image tag used to specify which image you would like deployed.
Don't use `latest`.
value: "v12-2022-09-12"
value: "v12-latest"
- name: PVC_SIZE
description: The size of the persistent volume to create.
displayName: Persistent Volume Size
Expand Down
4 changes: 2 additions & 2 deletions openshift/templates/patroni_prerequisite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ parameters:
- name: IMAGE_NAME
description: |
The Patroni image stream name
value: patroni-postgres
value: patroni-postgres-vim
- name: IMAGE_TAG
description: |
The image tag used to specify which image you would like deployed.
Don't use `latest`.
value: "v12"
value: "v12-latest"
- name: PVC_SIZE
description: The size of the persistent volume to create.
displayName: Persistent Volume Size
Expand Down
Loading