PostgreSQL of Opstella Installation
This content is not available in your language yet.
🟢 Management
PostgreSQL is a Database service for Opstella
Prerequisites
Section titled “Prerequisites”- 💿Persistence Storage Access for PostgreSQL for Opstella
- On Kubernetes when requesting for a PVC, will request with Storage Class specified.
- 💾S3-Compatible Object Storage (SeaweedFS)
- Required for PostgreSQL Backups (WAL Archiving)
Preparation
Section titled “Preparation”Kubernetes Cluster Preparation
Section titled “Kubernetes Cluster Preparation”-
Connect to
🟢 ManagementKubernetes Cluster ; i.e w/ Kubeconfig FileEnsure you have defined and loaded your Global Shell Variables as described in Shell Variables.
Terminal window source $HOME/opstella-installation/shell-values/kubernetes/management_cluster.vars.shTerminal window export KUBECONFIG="$HOME/opstella-installation/kubeconfigs/management_cluster.yaml" -
Prepare
🟢 ManagementKubernetes Cluster InformationEnsure
K8S_INTERNAL_DOMAIN,K8S_STORAGECLASS_NAMEare defined as per the Shell Variables guide.
PostgreSQL for Opstella Preparation
Section titled “PostgreSQL for Opstella Preparation”-
Create PostgreSQL Initial Admin Credentials with Kubernetes Secret
- Username:
postgres(Default Admin of PostgreSQL) - Password:
CHANGEME; NOTE: Only Allowed Special Characters are!-_=+?@
export OPSTELLA_POSTGRES_SUPERUSER_PASSWORD="CHANGEME"export OPSTELLA_POSTGRES_USER_PASSWORD="CHANGEME" - Username:
-
Provision PostgreSQL for Opstella Platform
The following manifest defines the entire PostgreSQL system, including credentials and the CNPG cluster.
Terminal window cat <<EOF > $HOME/opstella-installation/kubernetes-manifests/opstella-postgres.yaml---# Postgres Superuser (root) CredentialsapiVersion: v1kind: Secrettype: kubernetes.io/basic-authmetadata:name: opstella-postgres-superusernamespace: opstella-systemstringData:username: postgrespassword: "${OPSTELLA_POSTGRES_SUPERUSER_PASSWORD}"---# Opstella Platform Application User CredentialsapiVersion: v1kind: Secrettype: kubernetes.io/basic-authmetadata:name: opstella-postgres-usernamespace: opstella-systemstringData:username: opstella_platform_userpassword: "${OPSTELLA_POSTGRES_USER_PASSWORD}"---# S3 Credentials for Postgres Backups (to SeaweedFS HA)apiVersion: v1kind: Secrettype: Opaquemetadata:name: opstella-postgres-s3-secretnamespace: opstella-systemstringData:S3_ACCESS_KEY: "postgres-backup"S3_SECRET_KEY: "${SEAWEEDFS_HA_S3_POSTGRES_BACKUP_PASSWORD}"---apiVersion: barmancloud.cnpg.io/v1kind: ObjectStoremetadata:name: opstella-postgres-backupnamespace: opstella-systemspec:# This resource defines the backup destination for the Barman Cloud Pluginconfiguration:destinationPath: s3://postgres-backups/endpointURL: http://seaweedfs-s3.apps-supporting-services.svc:9000s3Credentials:accessKeyId:name: opstella-postgres-s3-secretkey: S3_ACCESS_KEYsecretAccessKey:name: opstella-postgres-s3-secretkey: S3_SECRET_KEYwal:compression: gzipdata:compression: gzip# Retention policy for backups and WALs handled by the pluginretentionPolicy: "30d"---apiVersion: postgresql.cnpg.io/v1kind: Clustermetadata:name: opstella-postgresnamespace: opstella-systemlabels:app.kubernetes.io/name: opstella-postgresapp.kubernetes.io/part-of: opstella-platformspec:instances: 1# Image configuration (Postgres 15)imageName: ghcr.io/cloudnative-pg/postgresql:15# Enable the Barman Cloud Plugin for backupsplugins:- name: barman-cloud.cloudnative-pg.ioisWALArchiver: trueparameters:serverName: "opstella-postgres"barmanObjectName: "opstella-postgres-backup"# Storage Configurationstorage:size: 5GistorageClass: "${K8S_STORAGECLASS_NAME}"walStorage:size: 2GistorageClass: "${K8S_STORAGECLASS_NAME}"# Bootstrap Configurationbootstrap:initdb:database: opstella_platformowner: opstella_platform_user# Secret containing password for the Application Usersecret:name: opstella-postgres-user# Superuser credentials (root/postgres)superuserSecret:name: opstella-postgres-superuser# Backup Configuration (Barman Cloud Plugin will automatically detect matching ObjectStore)backup:{}# Monitoring (disabled for now)monitoring:enablePodMonitor: false# Resourcesresources:requests:memory: "256Mi"cpu: "200m"limits:memory: "1Gi"cpu: "1000m"EOFApply the configuration:
Terminal window kubectl apply -f opstella-postgres.yaml💡 Should return
secret/opstella-postgres-superuser,secret/opstella-postgres-user,secret/opstella-postgres-s3-secret,objectstore.barmancloud.cnpg.io/opstella-postgres-backup, andcluster.postgresql.cnpg.io/opstella-postgrescreated messages.
Post-Installation
Section titled “Post-Installation”PostgreSQL for Opstella Testing
Section titled “PostgreSQL for Opstella Testing”-
Get Pod Status - PostgreSQL for Opstella
Terminal window kubectl get pods -n opstella-systemPostgreSQL for Opstella should be
RunningNAME READY STATUS RESTARTS AGE... (deducted)opstella-postgres-1 1/1 Running 0 XdXh
Finished?
Use the below navigation to proceed