Postgres Tanzu
Postgres Tanzu
Cloud Foundry
Tanzu for Postgres on Cloud Foundry 10.1
Tanzu for Postgres on Cloud Foundry
You can find the most up-to-date technical documentation on the VMware by Broadcom website at:
https://techdocs.broadcom.com/
VMware by Broadcom
3401 Hillview Ave.
Palo Alto, CA 94304
www.vmware.com
Copyright © 2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its
subsidiaries. For more information, go to https://www.broadcom.com. All trademarks, trade names, service marks,
and logos referenced herein belong to their respective companies.
2
Tanzu for Postgres on Cloud Foundry
Contents
VMware Tanzu for Postgres on Cloud Foundry ................... 7
Product Snapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About VMware Tanzu for Postgres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About Tanzu for Postgres on Cloud Foundry . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
For more information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3
Tanzu for Postgres on Cloud Foundry
Hooks .......................................................... 29
Scripts to Run Custom Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Using Hooks to Replace run_on_every_startup Property . . . . . . . . . . . . . . . . . . 30
Backup and Restore with Bosh Backup and Restore (Legacy) .... 36
Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Restoring from S3 Backup Artifacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Structure of S3 Backup Artifacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Scheduled Backup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4
Tanzu for Postgres on Cloud Foundry
Observability ................................................... 47
Metric Exports .................................................. 47
Loggregator Firehose Endpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Metrics Polling Interval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Prometheus Endpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Configure Syslog Forwarding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5
Tanzu for Postgres on Cloud Foundry
6
Tanzu for Postgres on Cloud Foundry
This documentation provides information about how to install, configure, and use VMware Tanzu for
Postgres on Cloud Foundry.
VMware Tanzu for Postgres on Cloud Foundry (short name, Tanzu for Postgres on Cloud
Foundry) was formerly known as VMware Postgres for VMware Tanzu Application Service.
You can download the Tanzu for Postgres on Cloud Foundry tile from Broadcom Support.
This documentation:
Guides operators on how to install, configure, maintain, backup, and restore Tanzu for Postgres on
Cloud Foundry.
Guides app developers on how to choose a service plan, create and delete Postgres service
instances, and bind an app.
Product Snapshot
Element Details
Version v10.1.0
Tanzu v3.0 and Ste Ubuntu Jammy Tanzu v6.0 IaaS AWS, Azure, IPsec N
Operations above mce 1.824, FIPS Ubuntu Platform for and supp GCP, supp o
Manager ll Jammy v1.785 Cloud v10.0 ort OpenStack, ort
Foundry vSphere
7
Tanzu for Postgres on Cloud Foundry
8
Tanzu for Postgres on Cloud Foundry
This topic describes the changes in Tanzu for Postgres on Cloud Foundry v10.x.x releases.
Tanzu for Postgres on Cloud Foundry was formerly known as VMware Postgres for
VMware Tanzu Application Service.
v10.1.1
Release date: July 22, 2025
Fixes
1. When the Network name in BOSH cloud-config is not a valid DNS hostname string, the HA
deployment fails.
Compatibility
The following components are compatible with this release:
Element Details
Version 10.1.1
Software VMware
component PostgreSQL
version 16.6
Compatible Ops 3.0 and Stem Ubuntu Jammy Compatible 6.0, IaaS AWS, Azure, IPse N
Manager above cell 1.866, FIPS VMware Tanzu 10.0 sup GCP, c o
versions Versi Ubuntu Jammy Application Service and port OpenStack, supp
on 1.785 for VMs versions 10.2 vSphere ort
v10.1.0
Release date: May 15, 2025
New features
New features included in this release:
9
Tanzu for Postgres on Cloud Foundry
1. Support for in-place upgrade from Postgres Tile (1.2.x) to current release v10.1.0.
2. Support for disaster recovery of HA Postgres service instances deployed across TAS foundations
(multi-site) using Patroni for handling failover and switchover.
Fixes
1. Updated the source_id for service metrics emitted by Postgres service instances to use a
common value of postgres instead of each instance’s service GUID. This enables consistent
filtering across all instances in their observability dashboards (e.g, Grafana).
2. Previously, HA service instances shared the same password for the pgadmin user. This has now
been fixed to ensure that each HA service instance has its own unique pgadmin user password.
3. Fixed an issue where WAL files were being archived even when no backup was enabled, leading to
unnecessary disk space usage.
Compatibility
The following components are compatible with this release:
Element Details
Version 10.1.0
Software VMware
component PostgreSQL
version 16.6
Compatible Ops 3.0 and Stem Ubuntu Jammy Compatible VMware 6.0 IaaS AWS, Azure, IPse N
Manager above cell 1.824, FIPS Tanzu Application and sup GCP, c o
versions Versi Ubuntu Jammy Service for VMs 10.0 port OpenStack, supp
on 1.785 versions vSphere ort
v10.0.0
Release date: Feb 03, 2025
New features
New features included in this release:
1. Replaced pg_auto_failover with Patroni to manage high availability (HA) for the PostgreSQL service
Limitations
1. Direct In-place Upgrade from previous Postgres Tile (1.2.x or 1.1.x) is not supported to current
release v10.0.0. The next release will support direct in-place upgrade from previous Postgres Tile
(v1.x).
Compatibility
10
Tanzu for Postgres on Cloud Foundry
Element Details
Version 10.0.0
Software VMware
component PostgreSQL
version 16.6
Compatible Ops 3.0 and Stem Ubuntu Jammy Compatible VMware 6.0 IaaS AWS, Azure, IPse N
Manager above cell 1.737, FIPS Tanzu Application and sup GCP, c o
versions Versi Ubuntu Jammy Service for VMs 10.0 port OpenStack, supp
on 1.719 versions vSphere ort
11
Tanzu for Postgres on Cloud Foundry
This topic provides the information you need when planning a deployment of Tanzu for Postgres on Cloud
Foundry.
On-demand service provides a dedicated VM running a Postgres instance. App developers can
provision an instance for any of the on-demand plans and configure certain Postgres settings.
Architecture
The available plans are:
Single instance
Postgres HA
The following diagram shows the architecture for the single instance plan:
The following diagram shows the architecture for the Postgres HA plan:
12
Tanzu for Postgres on Cloud Foundry
Developers can create instances of each plan when needed, until a quota is reached, and bind their apps to
the instances.
The preceding diagrams show the postgres service broker creating a single postgres instance or a postgres
HA cluster when you run the cf create-service command, based on the service plan you have selected.
They also show the user app bound to the postgres service. Each instance has its own VM.
Smoke Tests
Smoke tests allow for a simple check to ensure that your service instances can be created properly before
affecting any already running service instances. Smoke tests are run as an errand after tile installation. You
can deactivate smoke tests by clearing the smoke test option when reviewing changes.
Smoke tests run in the org system and the space postgres-smoke-test.
VMware recommends that you use the smallest plan for smoke tests, which reduces installation time.
If any errors occur while running a smoke test, the service instance persists so that log retrieval can be
performed. You should remove these service instances in the postgres-smoke-test space when done.
Ideally, after a tile is installed, there are no service instances in the postgres-smoke-test space.
Postgres plans allow you to determine which plan can be used for smoke tests through the Smoke Test
checkbox. If no plans have a Smoke Test enabled, then no Smoke tests are run. If multiple plans have a
Smoke Test enabled, then only one plan is selected for testing.
Availability Zones
The Tanzu for Postgres on Cloud Foundry HA plan uses the pg_autofailover extension and supports
configuring multiple availability zones (AZs) to provide high availability and resiliency. The tile supports
selecting multiple AZs for both the Monitor instance VMs and the Postgres DB VMs. Both kinds of service
instances are distributed evenly among the selected AZs.
13
Tanzu for Postgres on Cloud Foundry
You can make the Tanzu for Postgres on Cloud Foundry HA plan resilient against the loss of an AZ. To
achieve this, the AZs for Monitor and Postgres instances must be separate.
For example, if your IaaS provider has 3 AZs (az0, az1, az2) then one AZ distribution for resiliency is:
In this assignment, the loss of az0, az1, or az2 does not reduce service availability. Although, to maintain
the resiliency, the operator must back up the data of the cluster and restore it within a new resilient HA
cluster. This requires re-binding the apps to the new service.
There are multiple use cases for service-gateway access, such as:
Accessing Redis from apps deployed to VMware Tanzu Application Service for VMs (TAS for VMs)
in a different foundation.
Using Redis as a service for apps that are not deployed to TAS for VMs.
Architecture
Service-gateway access to Tanzu for Postgres on Cloud Foundry instances leverages the TCP Router in
TAS for VMs.
Any Postgres requests that an app makes are forwarded through DNS to a load balancer that can route
traffic from outside to inside the foundation. This load balancer (the TCP Router) opens a range of ports that
are reserved for any TAS application traffic. This has to be configured in the TAS for VMs tile’s Tanzu
Operations Manager form.
When an app developer creates a service instance on a plan with service-gateway access enabled, they
have to specify the port in the request parameters from the configured port range in the aforementioned
TCP router. The load balancer then forwards the requests for this Tanzu for Postgres on Cloud Foundry
service instance to the TCP router.
14
Tanzu for Postgres on Cloud Foundry
This documentation uses the term service instance and cluster interchangeably.
Overview
If a TAS foundation is running a Postgres service instance, you can use the Postgres for TAS Tile to
configure a Disaster Recovery (DR) solution. This is referred to as multi-site replication for disaster
recovery.
When this is configured, if the primary foundation goes down, a standby replica in another TAS foundation
must be updated to take over the functions of the primary cluster.
Primary Foundation: Deployed in your main data center, this foundation generally receives the
majority of app traffic. Tanzu for Postgres assumes that the primary service instance is deployed
on this foundation when it is healthy.
Secondary Foundation: Deployed in your failover data center, this foundation receives minimal or no
app traffic. Tanzu for Postgres assumes that the standby/secondary service instance is deployed
on this foundation unless a developer triggers a failover.
15
Tanzu for Postgres on Cloud Foundry
Failover
Failover is the process of switching from the primary foundation to the secondary foundation. It must be
manually configured if the primary foundation becomes unavailable or unreachable.
Any data written to the old primary that hadn’t been replicated to the standby before the failover will be lost.
This usually occurs if the failover happens before the replication lag (WAL shipping) is caught up.
16
Tanzu for Postgres on Cloud Foundry
For the current v10.1.0 release, we suggest letting the newly promoted primary run as it is and
create a new standby in primary foundation.
For more information, see Restoration to initial state in Disaster Recovery using multi-site
replication.
17
Tanzu for Postgres on Cloud Foundry
This topic for operators outlines best practices when deploying Tanzu for Postgres on Cloud Foundry.
Tanzu for Postgres on Cloud Foundry was formerly known as VMware Postgres for
VMware Tanzu Application Service.
Best Practices
VMware recommends that operators follow these guidelines:
Resource allocation: Work with app developers to anticipate memory requirements and to configure VM
sizes. App developers can choose from two different plans: Single Instance Plan or Postgres HA Plan, each
with its own VM size and quota.
Backing up data: Configure automatic backups so that data can be restored in an emergency. Validate the
backed-up data with a test restore.
Errands
The following sections list the errands included in Tanzu for Postgres on Cloud Foundry.
Post-Deploy Errands
Tanzu for Postgres on Cloud Foundry includes the following post-deploy errands.
Register on-demand register-broker Registers the on-demand Postgres broker with Tanzu Application Service for
broker VMs to offer the postgres service (on-demand plans).
Upgrade all on-demand upgrade-all- Upgrades on-demand service instances to use the latest plan configuration,
service instances service- service releases, and stemcell. This causes downtime to any service instances
instances with available upgrades.
The following post-deploy errands do not run by default when Apply Changes is triggered. These errands
help operators to troubleshoot and maintain their service fleet.
18
Tanzu for Postgres on Cloud Foundry
Recreate all on-demand recreate-all- Re-creates on-demand service instances one-by-one. This causes
service instances service-instances downtime for all service instances.
Find orphan on-demand orphan- Finds all orphan on-demand service instances. The cleanup of orphan
service instances deployments on-demand service instances can be carried out manually.
Pre-Delete Errands
The following pre-delete errands are run by default when the Tanzu for Postgres on Cloud Foundry tile is
deleted:
Delete all on-demand service delete-all-service-instances- Deletes all on-demand instances and deregisters
instances and deregister broker and-deregister-broker the on-demand Postgres broker.
1. Download the Tanzu for Postgres on Cloud Foundry file from the Broadcom Customer Support
Portal. Select the latest release from the Releases drop-down menu.
2. In the Tanzu Operations Manager Installation Dashboard, click Import a Product to upload the
Tanzu for Postgres on Cloud Foundry file.
3. Click the + sign next to the uploaded product description to add the tile to your staging area.
4. To configure Tanzu for Postgres on Cloud Foundry, click the newly added tile. See configuration
instructions in the following sections.
19
Tanzu for Postgres on Cloud Foundry
Assign AZs
You can assign multiple availability zones (AZs) to Postgres jobs. However, this does not ensure high
availability. You must select AZs that are in the service network you configured in your BOSH Director. To
assign AZs:
2. Click Save.
Select Networks
To use the Tanzu for Postgres on Cloud Foundry on-demand service, you must select a network in
which the service instances are created.
1. In the Assign AZs and Networks tab, select a network. VMware recommends that each type of
service run in its own network. Usually the service broker network and service instance networks
are the same.
20
Tanzu for Postgres on Cloud Foundry
To configure settings that apply across the whole on-demand service offering:
1. In the Tanzu for Postgres on Cloud Foundry tile, select On-Demand Service Settings.
2. Enter the Maximum service instances across all on-demand plans. The maximum number of
instances you set for all your on-demand plans combined cannot exceed this number.
3. Select the Allow outbound internet access from service instances check box. You must select
this check box to allow external log forwarding, send backup artifacts to external destinations, and
communicate with an external BOSH blobstore.
Outbound network traffic rules also depend on your IaaS settings. Consult your
network or IaaS admin to ensure that your IaaS allows outbound traffic to the
external networks you need.
4. (Optional) Use the Maximum Parallel Upgrades text box to configure the maximum number of
Postgres service instances that can be upgraded at the same time.
When you click Apply Changes, the on-demand broker upgrades all service instances. By default,
each instance is upgraded serially. Allowing parallel upgrades reduces the time taken to apply
changes.
5. (Optional) Use the Number of Canaries to run before proceeding with upgrade field and the
Specify Org and Space that Canaries will be selected from? options to specify settings for
upgrade canaries. Canaries are service instances that are upgraded first. The upgrade fails if any
canaries fail to upgrade.
21
Tanzu for Postgres on Cloud Foundry
You can limit canaries by number and by org and space. To use all service instances in an org and
space as canaries, set the number of canaries to zero. This upgrades all service instances in the
selected org and space first.
If you specify that canaries should be limited to an org and space that has no service instances,
the upgrade fails.
Canary upgrades comply with the Maximum Parallel Upgrades settings. If you
specify three canaries and a Maximum Parallel Upgrades of two, then two canaries
upgrade, followed by the third.
1. In the Tanzu for Postgres on Cloud Foundry tile, select On-Demand Plans.
22
Tanzu for Postgres on Cloud Foundry
3. Configure the settings in the following table for your on-demand plans and then click Save.
Plan name on-demand- The name that you choose for the plan. This is displayed in the Marketplace.
postgres-db VMware recommends that you give your plans descriptive names based on
their configuration.
23
Tanzu for Postgres on Cloud Foundry
Plan quota 20 The maximum number of instances of this plan that app developers can create.
AZs to deploy None The AZs in which to deploy the Postgres instances from the plan. These must
postgres selected be AZs of the service network, which are configured in the BOSH Director tile. If
instances of this you select multiple AZs, instances are distributed randomly among them.
plan
Server VM type Varies VMware recommends that the persistent disk is at least 2.5x the VM memory
depending for on-demand service instances.
on IaaS
Server disk type Varies VMware recommends that the persistent disk is at least 2.5x the VM memory
depending for on-demand service instances.
on IaaS
Postgres client 3600 The server timeout for an idle client specified in seconds. Adjust this setting as
timeout needed.
Postgres TCP 60 The interval in seconds at which TCP ACKs are sent to clients. Adjust this
keepalive setting as needed.
Max clients 1000 The maximum number of clients that can be connected at any one time. Adjust
this setting as needed.
Generating a Certificate
The certificate deployed on the Tanzu for Postgres on Cloud Foundry service instance is a server
certificate. Either the operator provides the certificate to CredHub or CredHub generates it. CredHub
generates the server certificate by using a CA certificate. CredHub is a component designed for centralized
credential management in Tanzu Application Service for VMs. It is deployed on the same VM as the BOSH
Director.
Apps can use a Postgres database password, or the CA certificate to authenticate with Tanzu for Postgres
on Cloud Foundry service instances. Apps that communicate with Tanzu for Postgres on Cloud Foundry
must have access to the CA certificate in order to validate that the server certificate can be trusted.
For more information about providing or generating a certificate, see Preparing for Transport Layer Security
(TLS).
24
Tanzu for Postgres on Cloud Foundry
Deselect Enable HA
Deselect Enable HA
25
Tanzu for Postgres on Cloud Foundry
26
Tanzu for Postgres on Cloud Foundry
Tanzu for Postgres on Cloud Foundry does not support HA plans with TLS disabled.
Verify that customizable configurations are properly reflected in the PostgreSQL server
Roles
Databases
Database extensions
Environment Setup
Upload to the BOSH Director the latest stemcell and your dev postgres-release:
Some test cases make use of bbr. Make sure that it is available in your $PATH.
27
Tanzu for Postgres on Cloud Foundry
If you are not using BOSH Lite according to the quick start documentation, note that:
PGATS must have access to the target BOSH director and to the postgres VM deployed from it.
The director must be configured with verifiable certificates because PGATS use the bosh-cli
director package for programmatic access to the Director API.
Configuration
A config file for bosh-lite looks similar to this example:
boshparameters are used to connect to the BOSH director that hosts the test environment:
bosh.use_uaa (required) Set to true if the BOSH director is configured to delegate user
management to the UAA server.
cloud_config parameters are used to generate a BOSH v2 manifest that matches your IaaS configuration:
28
Tanzu for Postgres on Cloud Foundry
Other parameters:
postgresql_version The PostgreSQL version expected to be deployed. You only need to specify
it if your changes include a PostgreSQL version upgrade. If not specified, we expect that the one in
the latest published postgres-release is deployed.
Run Tests
Run all the tests with:
$ export PGATS_CONFIG=$GOPATH/src/github.com/cloudfoundry/postgres-release/pgats_confi
g.yml
$ $GOPATH/src/github.com/cloudfoundry/postgres-release/src/acceptance-tests/scripts/te
st
$ export PGATS_CONFIG=$GOPATH/src/github.com/cloudfoundry/postgres-release/pgats_confi
g.yml
$ $GOPATH/src/github.com/cloudfoundry/postgres-release/src/acceptance-tests/scripts/te
st <some test packages>
The PGATS_CONFIG environment variable must point to the absolute path of the configuration file.
Hooks
This topic discusses how you can run custom code with Tanzu for Postgres on Cloud Foundry.
pg_janitor periodically runs the janitor.script and it also takes care of creating roles and
database.
If you plan to use these scripts to run custom code, consider the following:
The return code of the database.hooks scripts is not propagated to the monit control job.
/var/vcap/sys/log/postgres/hooks.std{out,err}.log
/var/vcap/sys/log/postgres/janitor{,.err}.log
The time spent in databases.hooks.pre-start delays the start of PostgreSQL. In the same way,
the time spent in databases.hooks.pre-stop delays the stop of PostgreSQL. This influences an
eventual deployment. For this reason, VMware recommends avoiding long running actions in the
hooks and leveraging the databases.hooks.timeout property to prevent unexpected delays.
29
Tanzu for Postgres on Cloud Foundry
If for example you want to use psql in your hook, you can specify: ${PACKAGE_DIR}/bin/psql -p
${PORT} -U vcap postgres -c "\l"
Since monit starts and stops postgres based on the PostgreSQL process ID, the
databases.hooks.post-stop script may run concurrently with the restart of PostgreSQL.
Likewise, the databases.hooks.post-start script may run concurrently with the stop of
PostgreSQL.
Replace:
properties:
databases:
databases:
- name: sandbox
run_on_every_startup:
- "SQL-QUERY1"
- "SQL-QUERY2"
with:
databases:
hooks:
post_start: |
#!/bin/bash
for i in {10..0}; do
result=$(${PACKAGE_DIR}/bin/psql -p ${PORT} -U vcap postgres -t -P format=unal
igned -c "SELECT 1 from pg_database WHERE datname='sandbox'")
if [ "$result" == "1" ]; then
break
fi
echo "Database sandbox does not exists yet; trying $i more times"
sleep 1
done
if [ "$i" == "0" ]; then
30
Tanzu for Postgres on Cloud Foundry
Supported Extensions
This topic provides the list of supported extensions in Tanzu for Postgres on Cloud Foundry.
pg_stat_statements 1.10 Track planning and execution statistics of all SQL statements executed
plr 8.4.6 Load R interpreter and execute R script from within a database
postgis 3.4.0 PostGIS geometry and geography spatial types and functions
Service gateway access enables a Tanzu for Postgres on Cloud Foundry on-demand instance to connect to
external components that are not on the same foundation as the service instance. These components might
be on another foundation or hosted outside of the foundation.
To enable service gateway access for an on-demand offering, you must Enable TCP routing by using the
Tanzu Application Service for VMs tile.
1. Go to the Networking tab on the sidebar of the TAS for VMs tile.
3. For TCP routing ports, enter a range of valid ports. For example, 1024–1123
31
Tanzu for Postgres on Cloud Foundry
4. The ports you assign must not overlap with any other application or tile.
5. Apply your changes in Tanzu Operations Manager for the TAS for VMs tile to create the TCP router.
1. Go to the On-Demand Service Settings tab on the sidebar of the TAS for VMs tile.
2. Under Enable Services Gateway, select Yes and specify FQDN for TCP Router
32
Tanzu for Postgres on Cloud Foundry
3. Define a port range within the TCP routing ports range defined earlier in previous section. Also, you
must make sure to avoid conflicting or overlapping port ranges, if used by any other Tile(s).
Providing this port range is mandatory to assign a free port dynamically to the
service instance, when configured with services gateway enabled.
4. Apply your changes in Tanzu Operations Manager for the TAS for VMs tile to create the service
gateway.
Developer Workflow
For instructions for app developers, see Create a Service Instance with Service Gateway Access.
You can also do a manual incremental backup and restore using BOSH errands:
You can also configure automated backups using full and incremental scheduled backups:
33
Tanzu for Postgres on Cloud Foundry
VMware Tanzu Postgres for TAS backs up your database on a schedule. You configure this schedule with a
cron expression.
Configuring a cron expression overrides the default schedule for your service instance.
The procedure in this section assumes that you are using an Amazon S3 bucket.
1. Create a policy for your VMware Tanzu Postgres for TAS user account.
In AWS, create a new custom policy by following this procedure in the AWS documentation.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PostgresLBackupPolicy",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:ListMultipartUploadParts",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::MY_BUCKET_NAME/*",
"arn:aws:s3:::MY_BUCKET_NAME"
]
}
]
}
34
Tanzu for Postgres on Cloud Foundry
2. Record the Access Key ID and Secret Access Key user credentials for a new user account by
following this procedure in the AWS documentation. Ensure you select Programmatic access and
Attach existing policies to user directly. You must attach the policy you created in the previous
step.
Prerequisite: Before beginning this procedure, you must have an S3 bucket in which to store the backups.
1. In Ops Manager, open the VMware Tanzu for Postgres on Cloud Foundry tile Backups pane.
Field Instructions
35
Tanzu for Postgres on Cloud Foundry
Access Enter the S3 Access Key ID and Secret Access Key that you created in Create a Custom Policy and Access Key.
Key ID
and
Secret
Access
Key
Force The default behavior uses a virtual host-style URL. Select this check box if you use an Amazon S3 and your
path bucket name is not compatible with virtual hosted-style URLs or an S3-compatible endpoint such as Minio that
style might require path-style URLs. If you are using a blobstore that uses a specific set of domains in its server
access certificate, add a new wildcard domain or use path-style URLs if supported by the blobstore. For general
to information about the deprecation of S3 path-style URLs, see AWS blog posts: Amazon S3 Path Deprecation Plan
bucket – The Rest of the Story and the subsequent Update to Amazon S3 Path Deprecation Plan.
Cron Enter a cron expression using standard syntax. The cron expression sets the schedule for taking full backup for
Schedul each service instance. Test your cron expression using a website such as Crontab Guru.
e for full
backup
Cron Enter a cron expression using standard syntax. The cron expression sets the schedule for taking incremental
Schedul backup for each service instance. Test your cron expression using a website such as Crontab Guru.
e for
increme
ntal
backup
The ADBR plugin is the recommended method to perform backup and restore. The bbr
36
Tanzu for Postgres on Cloud Foundry
Backup
Back up a BOSH deployment
1. Run the BBR pre-backup check to confirm that your BOSH Director is reachable and has a
deployment that you can back up with BBR:
2. If the pre-backup check command fails, run the command again adding the –debug flag to enable
debug logs:
3. If the pre-backup check succeeds, run the BBR backup command to back up your BOSH
deployment:
This creates 2 files: a backup artifact, and a metadata file that looks like this:
instances:
- name: postgres-instance
index: "0"
artifacts:
- name: postgres-backup
checksums:
./pgdump: ae407e4d9ada961f1e12f96e7e88c80b5f838f22067519eeea92c2eb6f3c948c
backup_activity:
start_time: 2023/08/03 15:20:33 IST
finish_time: 2023/08/03 15:20:39 IST
Both files must be saved together in the same directory for restore to use them.
Restore
You can only restore by using files from your local machine/jumpbox with access to the service instance’s
network. The backup files must be those you downloaded by running the bbr command.
1. If the service instance no longer exists, you must re-create it. For example:
cf create-service postgres -w
After this, edit the metadata file’s “index” fields corresponding to each artifact. To get the index of
an instance, look at the “index” column in the output from the following command:
37
Tanzu for Postgres on Cloud Foundry
2. To restore a BOSH deployment, ensure that the BOSH deployment backup artifact is in the
directory from which you run BBR.
To restore an HA service instance using an S3 scheduled backup artifacts folder, which should have
originated from another HA service instance, see Sample App for Postgres for TAS.
The reason for this choice is that the “Primary” role can switch from the current instance VM to another at
the time of restore. You can’t keep other instance VM’s backup data empty/dummy because it’s possible
that between the time of backup and restore, one of the replication nodes has become primary.
If you set the S3 prefix to be pg-test-2 at the time of Tile configuration, and if you open your S3 bucket
containing the backup artifacts, you can see the following structure:
Non-HA Backup:
```pre
pg-test-2
├── service-instance_ffde758f-093d-4877-ba69-a5307a9884db
├──postgres-instance
├── 7dd4cf9f-6fa0-44ef-a63d-4875e8690fba
├── 20231018T16:29:17UTC
├── metadata
├── postgres-instance-0-postgres-backup.tar
```
HA backup:
```pre
pg-test-2
├── service-instance_ffde758f-093d-4877-ba69-a5307a9884db
├──postgres-instance
├── 7dd4cf9f-6fa0-44ef-a63d-4875e8690fba
├── 20231018T16:29:17UTC
├── metadata
├── postgres-instance-0-postgres-backup.tar
├── 52be4e9b-28eb-42be-b295-40ee01ea5607
├── 20231018T16:29:17UTC
├── metadata
38
Tanzu for Postgres on Cloud Foundry
├── postgres-instance-1-postgres-backup.tar
```
Scheduled Backup
No longer supported post release 1.2.0
The procedures on this page assume that you are using the adbr plug-in v0.7.0 or later.
2. Make sure to configure the S3 backup values during tile configuration, in order to provide a backup
store.
1. Make sure that the service instance to be backed up is created and running:
For example:
39
Tanzu for Postgres on Cloud Foundry
pace as user...
[Tue Sep 16 18:08:25 UTC 2024] Status: Backup was successful. Uploaded 3.2M
1. Make sure you have completed the backup of service and the backup was successful.
Where POSTGRES_PLAN is the same plan as the backup service instance plan.
3. Retrieve the backup artifacts for your service by running the command:
Where BACKUP_SERVICE_NAME is the backup service you created earlier during backup.
For example:
For example:
40
Tanzu for Postgres on Cloud Foundry
cf services
For example:
$ cf services
Getting services in org my-org / space my-space as user...
OK
name service plan bound apps last
operation
test_backup_svc postgres on-demand-postgres-db my-app creat
e succeeded
test_restore_svc postgres on-demand-postgres-db creat
e succeeded
cf restage APP-NAME
2. Complete the steps 3, 4 and 5 as per the Restore a service instance (NON-HA and TLS NON-HA)
section mentioned above.
3. Once the restore is successful, perform an upgrade of the restore service instance to HA plan
4. Make sure to bind the app if any, as shown in step 6 in Restore a service instance NON-HA and
TLS NON-HA section.
Prerequisite:
1. Make sure to configure the S3 backup values during tile configuration, to provide a backup store.
41
Tanzu for Postgres on Cloud Foundry
1. Make sure that the service instance to be backed up is created and running:
Where BACKUP_SERVICE_NAME is the service instance you are backing up. The deployment
name for the service instance will then be: service-instance_GUID_FETCHED
For example:
Task 92
Instance postgres-instance/272907cc-9660-41d8-8de8-00ad754529c5
Exit Code 0
Stdout [20250205T11:24:45] Started postgres-stream-incremental-backup erran
d...
[20250205T11:24:45] Upload selector: S3 Backups
[20250205T11:24:45] In case of HA setup, backup will be taken only f
or the primary node
This is primary/leader node and in healthy state.
[20250205T11:24:45] Initiating incremental backup process on this pr
imary node of HA setup.
42
Tanzu for Postgres on Cloud Foundry
Stderr -
Instance postgres-instance/fa2a1a9f-ea23-42f9-9d2d-ed0c328a66f0
Exit Code 0
Stdout [20250205T11:25:00] Started postgres-stream-incremental-backup erran
d...
[20250205T11:25:00] Upload selector: S3 Backups
[20250205T11:25:00] In case of HA setup, backup will be taken only f
or the primary node
This node is secondary/replica and in healthy state.
[20250205T11:25:00] Skipping backup process on secondry node of HA s
etup. Exiting.
Stderr -
2 errand(s)
43
Tanzu for Postgres on Cloud Foundry
Succeeded
1. Make sure you have successfully completed the backup of the service.
Where POSTGRES_PLAN is the plan depending on the backup service instance plan you are
restoring.
3. SSH to the service instance VM using bosh command line interface (cli):
Where RESTORE_SERVICE_NAME is the service instance you are restoring to. The deployment
name for service instance will then be: service-instance_RESTORE_SERVICE_GUID
4. Edit the name of service-instance in the pgbackrest.conf file with the backup service instance
deployment name that needs to be restored.
Before updating the file, make sure to keep a copy of this file:
cp /var/vcap/store/pgbackrest/pgbackrest.conf /tmp/pgbackrest.conf
[global]
#S3 configuration
repo1-type=s3
repo1-s3-key=AKIA2***********
repo1-s3-key-secret=EweMcMs2F1noh***********
repo1-s3-endpoint=s3.us-east-1.amazonaws.com
repo1-s3-region=us-east-1
repo1-s3-bucket=pg-tile-backup-test1
repo1-path=/pg-test-2
repo1-retention-full=2
repo1-s3-uri-style=host
#configure logs
log-level-console=info
log-level-file=debug
log-path=/var/vcap/sys/log/pgbackrest
44
Tanzu for Postgres on Cloud Foundry
#other settings
archive-async=y
spool-path=/var/vcap/store/pgbackrest/pgbackrest_spool_dir
start-fast=y
# configure parallelism
process-max=2
sudo su - vcap
export LD_LIBRARY_PATH="/var/vcap/packages/vmware-postgres/lib/x86_64-linux-gn
u" && /var/vcap/packages/pgbackrest/bin/pgbackrest restore --delta --stanza="se
rvice-instance_BACKUP_SERVICE_GUID" --config="/tmp/pgbackrest.conf"
sudo su - vcap
export LD_LIBRARY_PATH="/var/vcap/packages/vmware-postgres/lib/x86_64-linux-gn
u" && /var/vcap/packages/pgbackrest/bin/pgbackrest stanza-upgrade --stanza="ser
vice-instance_RESTORE_SERVICE_GUID" --config="/var/vcap/store/pgbackrest/pgback
rest.conf"
cf services
For example:
$ cf services
Getting services in org my-org / space my-space as user...
45
Tanzu for Postgres on Cloud Foundry
OK
name service plan bound apps last
operation
test_backup_svc postgres on-demand-postgres-db my-app creat
e succeeded
test_restore_svc postgres on-demand-postgres-db creat
e succeeded
cf restage APP-NAME
2. Complete steps 3 to 10 in Restore an incremental backup (NON-HA and TLS NON-HA) above.
3. Once the restore is successful, perform an upgrade of the restore service instance to HA plan:
4. Make sure to bind the app if any, as shown in step 11 in Restore an incremental backup (NON-HA
and TLS NON-HA).
To rotate the Services TLS CA and its leaf certificates, use one of the following procedures:
Tanzu Operations Manager v3.0: See Rotate the Services TLS CA and its leaf certificates.
Tanzu Operations Manager v2.10: See Rotate the Services TLS CA and its leaf certificates.
Tanzu for Postgres on Cloud Foundry v1.1.3 and later is compatible with CredHub Maestro.
46
Tanzu for Postgres on Cloud Foundry
There is, however, a workaround to rotate your deployment’s certificates using Maestro. This workaround
involves adding a step in the recommended steps using Credhub Meastro.
Step 1: No change.
Step 2: No change.
Step 3: Workaround step: Get the newly generated CA certificate from credhub into a local file by using the
command:
In the Ops manager UI, add the contents of this file into the “Trusted Certificates” text box in the BOSH
director tile’s “Security” section:
bosh-trusted-certs-box
From this point, all the remaining steps are identical to the recommended steps using Credhub Meastro.
The remaining steps start from Step 3 in the recommended procedure page: Redeploy the affected
services: All services that use certs signed by /setvices/tls_ca.
Observability
This section provides information about how to configure and consume observability features of VMware
Tanzu for Postgres on Cloud Foundry Tile.
Metric Exports
This topic describes how to consume Postgres metrics exported by Tanzu for Postgres on Cloud Foundry
component VMs.
47
Tanzu for Postgres on Cloud Foundry
Prometheus Endpoint
VMware recommends using the prometheus-boshrelease release on GitHub, the default metrics endpoint is:
http://prometheus.<sys sub-domain set in your Cloud foundry installation>:9187/metrics.
This is configurable in the deployment manifest of prometheus-boshrelease. If you don’t explicitly provide
secret vars needed by the boshrelease, then prometheus-boshrelease creates file: ./tmp/deployment-
vars.yml containing secrets:
alertmanager_password,grafana_password,grafana_secret_key,postgres_grafana_password,prome
theus_password.
If an existing Prometheus instance needs to collect metrics from the Postgres component VMs, it can be
configured to collect from each component VM’s 9187 port. If the Prometheus instance is outside the CF
network of the Postgres deployment, a CF route must be created to this port for each VM you wish to
collect metrics from.
pg_exporter_last_scrape gauge Whether the last scrape of metrics from PostgreSQL resulted in an error (1 for error, 0
_error for success).
pg_exporter_scrapes_tot count Total number of times PostgreSQL was scraped for metrics.
al er
48
Tanzu for Postgres on Cloud Foundry
49
Tanzu for Postgres on Cloud Foundry
50
Tanzu for Postgres on Cloud Foundry
51
Tanzu for Postgres on Cloud Foundry
52
Tanzu for Postgres on Cloud Foundry
53
Tanzu for Postgres on Cloud Foundry
54
Tanzu for Postgres on Cloud Foundry
55
Tanzu for Postgres on Cloud Foundry
56
Tanzu for Postgres on Cloud Foundry
57
Tanzu for Postgres on Cloud Foundry
58
Tanzu for Postgres on Cloud Foundry
59
Tanzu for Postgres on Cloud Foundry
60
Tanzu for Postgres on Cloud Foundry
pg_stat_activity_max_tx_ gauge Max duration in seconds any active transaction has been running.
duration
pg_stat_archiver_archive count Number of WAL files that have been successfully archived.
d_count er
pg_stat_archiver_last_ar gauge Time in seconds since last WAL segment was successfully archived.
chive_age
pg_stat_bgwriter_buffers count Number of times a back end had to execute its own fsync call. Normally the background
_backend_fsync_total er writer handles those even when the back end does its own write.
61
Tanzu for Postgres on Cloud Foundry
pg_stat_bgwriter_checkp count Total amount of time that has been spent in the portion of checkpoint processing where
oint_sync_time_total er files are synchronized to disk, in milliseconds.
pg_stat_bgwriter_checkp count Total amount of time that has been spent in the portion of checkpoint processing where
oint_write_time_total er files are written to disk, in milliseconds.
pg_stat_bgwriter_maxwri count Number of times the background writer stopped a cleaning scan because it had written
tten_clean_total er too many buffers.
pg_stat_database_blk_re count Time spent reading data file blocks by back ends in this database, in milliseconds.
ad_time er
pg_stat_database_blk_w count Time spent writing data file blocks by back ends in this database, in milliseconds.
rite_time er
pg_stat_database_blks_ count Number of times disk blocks were found already in the buffer cache, so that a read was
hit er not necessary. This only includes hits in the PostgreSQL buffer cache, not the operating
system’s file system cache.
pg_stat_database_conflic count Number of queries canceled due to conflicts with recovery in this database. (Conflicts
ts er occur only on standby servers; see pg_stat_database_conflicts for details.)
pg_stat_database_conflic count Number of queries in this database that have been canceled due to pinned buffers.
ts_confl_bufferpin er
pg_stat_database_conflic count Number of queries in this database that have been canceled due to deadlocks.
ts_confl_deadlock er
pg_stat_database_conflic count Number of queries in this database that have been canceled due to lock timeouts.
ts_confl_lock er
pg_stat_database_conflic count Number of queries in this database that have been canceled due to old snapshots.
ts_confl_snapshot er
pg_stat_database_conflic count Number of queries in this database that have been canceled due to dropped
ts_confl_tablespace er tablespaces.
62
Tanzu for Postgres on Cloud Foundry
pg_stat_database_numb gauge Number of back ends currently connected to this database. This is the only column in
ackends this view that returns a value reflecting current state. All other columns return the
accumulated values since the last reset.
pg_stat_database_temp_ count Total amount of data written to temporary files by queries in this database. All temporary
bytes er files are counted, regardless of why the temporary file was created, and regardless of
the log_temp_files setting.
pg_stat_database_temp_ count Number of temporary files created by queries in this database. All temporary files are
files er counted, regardless of why the temporary file was created (for example, sorting or
hashing), and regardless of the log_temp_files setting.
pg_stat_database_xact_ count Number of transactions in this database that have been committed.
commit er
pg_stat_database_xact_r count Number of transactions in this database that have been rolled back.
ollback er
pg_stat_user_tables_ana count Number of times this table has been manually analyzed.
lyze_count er
pg_stat_user_tables_aut count Number of times this table has been analyzed by the autovacuum daemon.
oanalyze_count er
pg_stat_user_tables_aut count Number of times this table has been vacuumed by the autovacuum daemon.
ovacuum_count er
pg_stat_user_tables_last gauge Last time at which this table was manually analyzed.
_analyze
pg_stat_user_tables_last gauge Last time at which this table was analyzed by the autovacuum daemon.
_autoanalyze
pg_stat_user_tables_last gauge Last time at which this table was vacuumed by the autovacuum daemon.
_autovacuum
63
Tanzu for Postgres on Cloud Foundry
pg_stat_user_tables_last gauge Last time at which this table was manually vacuumed, not counting VACUUM FULL.
_vacuum
pg_stat_user_tables_n_t count Number of rows HOT updated, with no separate index update required.
up_hot_upd er
pg_stat_user_tables_vac count Number of times this table has been manually vacuumed, not counting VACUUM FULL.
uum_count er
pg_statio_user_tables_id count Number of disk blocks read from all indexes on this table.
x_blocks_read er
pg_statio_user_tables_tid count Number of buffer hits in this table’s TOAST table indexes, if any.
x_blocks_hit er
pg_statio_user_tables_tid count Number of disk blocks read from this table’s TOAST table indexes, if any.
x_blocks_read er
pg_statio_user_tables_to count Number of buffer hits in this table’s TOAST table, if any.
ast_blocks_hit er
pg_statio_user_tables_to count Number of disk blocks read from this table’s TOAST table, if any.
ast_blocks_read er
64
Tanzu for Postgres on Cloud Foundry
pg_up gauge Whether the last scrape of metrics from PostgreSQL was able to connect to the server
(1 for yes, 0 for no).
postgres_exporter_build_ gauge A metric with a constant ‘1’ value labeled by version, revision, branch, goversion from
info which postgres_exporter was built, and the goos and goarch for the build.
Logging
Postgres Service instance and Broker VM log everything under their respective /var/vcap/sys/log/
directory. If syslog is configured, all these logs are forwarded to it.
To enable monitoring for VMware Tanzu for Postgres on Cloud Foundry, operators must designate an
external syslog endpoint for log entries. The endpoint serves as the input to a monitoring platform such as
Datadog, Papertrail, or SumoLogic.
To specify the destination for VMware Tanzu for Postgres on Cloud Foundry log entries:
1. From the Ops Manager Installation Dashboard, click the VMware Tanzu for Postgres on Cloud
Foundry tile.
3. Click Syslog.
Field Description
Transport Select the transport protocol of the syslog server. The options are TLS, UDP, or RELP.
Protocol
Permitted Peer If there are several peer servers that can respond to remote syslog connections, enter a wildcard in the
domain, such as *.example.com.
SSL Certificate If the server certificate is not signed by a known authority, such as an internal syslog server, enter the CA
certificate of the log management service endpoint.
Queue Size The number of log entries the buffer holds before dropping messages. A larger buffer size might overload
the system. The default is 100000.
Forward Debug Some components produce very long debug logs. This option prevents them from being forwarded. These
Logs logs are still written to local disk.
65
Tanzu for Postgres on Cloud Foundry
Field Description
Custom Rules The custom rsyslog rules are written in RainerScript and are inserted before the rule that forwards logs.
It is strongly recommended to backup the data from v1.2.x services before upgrading. Follow the
instructions in the Backup topic.
Backups created using adbr(pgBackRest) in v1.2.x cannot be restored in v10.1.0 due to a major
Postgres version change. This is a known limitation of pgBackRest
The pg_upgrade tool is used to upgrade the major version of Postgres. It requires both the old and
new Postgres data directories, so additional disk space is needed—approximately equal to the size
of the old data directory. If there isn’t enough space on the persistent disk, the upgrade will fail. To
fix this, increase the disk size using Ops Manager and reapply the changes.
If there are failed services in version 1.2.x, the upgrade will fail for those services. To resolve this
issue, delete the failed services and reapply the changes in Ops Manager.
66
Tanzu for Postgres on Cloud Foundry
67
Tanzu for Postgres on Cloud Foundry
4. Click on the Tanzu for Postgres on Cloud Foundry tile and configure the upgrade options.
Under the Errands section, choose the Default (On) value for the Upgrade All Service
Instances post-deploy errand. Save the change.
5. Click Review Pending Changes. For more information, see Reviewing your pending product
changes in Tanzu Operations Manager in the Tanzu Operations Manager documentation.
For more information about multi-site architecture, see Multi-Site Architecture Guide.
68
Tanzu for Postgres on Cloud Foundry
Prerequisites
1. Two Tanzu Platform for Cloud Foundry foundations with VMware Tanzu for Postgres on Cloud
Foundry tile v10.1.0 or later installed.
2. Primary foundation must have services gateway enabled to allow secondary foundation to access
the primary foundation. Refer to the Enable Service Gateway Access to enable the service gateway
access.
3. This concept works only with HA-TLS plan. The service gateway access is not supported for single
instance plan.
4. The service gateway access must be enabled for the primary service instance in the primary
foundation.
The following procedure involves restarting all of the VMs in your deployment to apply a CA
certificate. The operation can take a long time to complete.
1. Start with primary foundation and get the CredHub credentials in Tanzu Operations Manager:
1. In the Tanzu Ops Manager Installation Dashboard, click the BOSH Director tile.
3. In the BOSH Director section, click the link to the BOSH Commandline Credentials.
`{"credential":"BOSH_CLIENT=ops_manager BOSH_CLIENT_SECRET=abCdE1FgHIjkL2m3n-3P
qrsT4EUVwXy5 BOSH_CA_CERT=/var/tempest/workspaces/default/root_ca_certificate B
OSH_ENVIRONMENT=10.0.0.5 bosh "}`
Where
BOSH_CLIENT is the BOSH CredHub client name
BOSH_CLIENT_SECRET is the BOSH CredHub client secret
2. Record the information needed to log in to the BOSH Director VM by following the procedure in
Gather Credential and IP Address Information.
3. Log in to the Tanzu Operations Manager VM by following the procedure in Log in to the Tanzu
Operations Manager VM with SSH.
4. Set the API target of the CredHub CLI as your CredHub server by running:
69
Tanzu for Postgres on Cloud Foundry
For example:
credhub api \
https://10.0.0.5:8844 \
--ca-cert=/var/tempest/workspaces/default/root\_ca\_certificate
credhub login \
--client-name=<BOSH_CLIENT> \
--client-secret=CREDHUB-CLIENT-SECRET
Where
credhub login \
--client-name=ops_manager \
--client-secret=abCdE1FgHIjkL2m3n-3PqrsT4EUVwXy5
credhub get \
--name=/services/tls_ca \
-k ca
7. Go to Tanzu Ops Manager Installation Dashboard > BOSH Director > Security in your secondary
foundation.
8. Append the contents of the CA certificate you recorded in step 6 into Trusted Certificates.
9. Click Save.
10. Repeat Steps 1-9 for the secondary foundation to add the CA certificate to the primary foundation.
2. Once the service instance is created, gather the information about primary host, service gateway
port, and the services gateway TCP domain IP.
3. To get the details, create a new service key, if not present, use the following command:
Where:
70
Tanzu for Postgres on Cloud Foundry
For example:
Where:
For example:
{
"credentials": {
"db": "postgres",
"hosts": [
"q-s0.postgres-instance.network.service-instance-329c3459-c323-498f-85f
8-55ac62d5ac68.bosh"
],
"jdbcUrl": "jdbc:postgresql://q-s0.postgres-instance.network.service-inst
ance-329c3459-c323-498f-85f8-55ac62d5ac68.bosh:5432/postgres?targetServerType=p
rimary&user=pgadmin&password=admin",
"password": "admin",
"port": 5432,
"primary_host": "329c3459-c323-498f-85f8-55ac62d5ac68.postgres.service.in
ternal",
"service_gateway": {
"host": "tcp.tas.z9d10d4f1.shepherd.lease",
"jdbcUrl": "jdbc:postgresql://tcp.tas.z9d10d4f1.shepherd.lease:1024/pos
tgres?targetServerType=primary&user=pgadmin&password=admin",
"port": 1024,
"uri": "postgresql://pgadmin:[email protected]:102
4/postgres"
},
"uri": "postgresql://pgadmin:[email protected]
-instance-329c3459-c323-498f-85f8-55ac62d5ac68.bosh:5432/postgres",
"user": "pgadmin"
}
}
5. Create the standby service instance, using the information from the service key of primary service
instance:
Where
SERVICE_NAME is the name of the standby service instance you want to create
71
Tanzu for Postgres on Cloud Foundry
remote_primary_host is the primary host from the service key of primary service instance
remote_primary_port is the port from the service key of primary service instance under
service_gateway section
You can use tool like nslookup to resolve the IP address of the service gateway host.
For example:
nslookup tcp.tas.z9d10d4f1.shepherd.lease
This will give you the IP address of the service gateway host.
For example:
Server: 192.19.189.30
Address: 192.19.189.30#53
Non-authoritative answer:
Name: tcp.tas.z9d10d4f1.shepherd.lease
Address: 34.60.52.133
Finally, the command to create the standby service instance will look like this:
For example:
1. The operator needs to manually detect when primary foundation goes down, and trigger update
service command to promote the standby service to new primary.
2. To update the current Standby HA service to primary, run the following command:
cf update-service <SERVICE_INSTANCE_NAME> \
-c '{"promote_to_primary": true}'
Where
SERVICE_INSTANCE_NAME is the name of the standby service instance you created in step 5
mentioned in section Creating Multi-Site Replication Standby Postgres Service.
For example:
72
Tanzu for Postgres on Cloud Foundry
cf update-service pg-ha-tls-standby \
-c '{"promote_to_primary": true}'
This command will promote the standby service instance to primary and enable write operations to
your DB (this was a read-only replica before).
The command will take some time to complete, depending on the time taken to
detect the failure and time taken for update service to finish for promoting the
secondary/standby service to primary.
1. Rebuild the standby cluster from scratch. For the current release, we suggest letting the newly
promoted primary run as it is and create a new standby in the old primary foundation (the one used
to create primary service instance before failover) or a new foundation altogether.
2. If you did not enable the services gateway while creating initial standby service, you will need to
enable the services gateway now, after you have promoted this standby to new primary, because
this will be used to create a new standby service in the old primary foundation or a new foundation.
cf update-service <SERVICE_INSTANCE_NAME> \
-c '{"enable_service_gateway":true}'
Where SERVICE_INSTANCE_NAME is the name of the service instance you created in step 1.
For example:
cf update-service pg-ha-tls-standby \
-c '{"enable_service_gateway":true}'
This command will enable the services gateway for the service instance and allow you to create a
new standby service in primary foundation or a new foundation.
Procedure
Follow these instructions to collect the information you need from the Tanzu Operations Manager interface:
1. Open the Tanzu Operations Manager interface by going to the Tanzu Operations Manager fully
qualified domain name (FQDN) in a web browser.
73
Tanzu for Postgres on Cloud Foundry
2. Click the BOSH Director tile and click the Status tab.
3. Record the IP address for the Director job. This is the IP address of the VM where the BOSH
Director runs.
7. (Optional) To prepare to troubleshoot the job VM for any other product, click the product tile and
repeat the previous procedure to record the IP address and VM credentials for that job VM.
Ensure that there are no Tanzu Operations Manager installations or updates in progress while using
the BOSH CLI.
Use SSH to connect to the Tanzu Operations Manager VM. To log in to the Tanzu Operations Manager VM,
go to the procedure for your IaaS:
AWS
Azure
GCP
OpenStack
vSphere
AWS
74
Tanzu for Postgres on Cloud Foundry
To log in to the Tanzu Operations Manager VM with SSH in AWS, you need the key pair you used when you
created the Tanzu Operations Manager VM. To see the name of the key pair, click the Tanzu Operations
Manager VM and locate the key pair name in properties.
1. Locate the Tanzu Operations Manager FQDN on the AWS EC2 instances page.
2. Run chmod 600 ops_mgr.pem to change the permissions on the .pem file to be more restrictive.
For example:
Where FQDN is the fully qualified domain name of Tanzu Operations Manager.
For example:
Azure
To log in to the Tanzu Operations Manager VM with SSH in Azure, you need the key pair you used when
creating the Tanzu Operations Manager VM. If you need to reset the SSH key, locate the Tanzu Operations
Manager VM in the Azure portal and click Reset Password.
1. From the Azure portal, locate the Tanzu Operations Manager FQDN by selecting the VM.
2. Change the permissions for your SSH private key by running the following command:
Where
GCP
To log in to the Tanzu Operations Manager VM with SSH in GCP:
1. Confirm that you have installed the Google Cloud SDK and CLI. For more information, see the
Google Cloud Platform documentation.
75
Tanzu for Postgres on Cloud Foundry
2. Initialize Google Cloud CLI, using a user account with Owner, Editor, or Viewer permissions to
access the project. Ensure that the Google Cloud CLI can log in to the project by running the
command gcloud auth login.
5. Under Remote access, click the SSH drop-down menu and click View gcloud command.
7. Paste the command into your terminal window to SSH to the VM. For example:
OpenStack
To log in to the Tanzu Operations Manager VM with SSH in OpenStack, you need the key pair that you
created in Configure Security in Deploying Tanzu Operations Manager on OpenStack. If you must reset the
SSH key, locate the Tanzu Operations Manager VM in the OpenStack console and boot it in recovery mode
to generate a new key pair.
1. Locate the Tanzu Operations Manager FQDN on the Access & Security page.
2. Run chmod 600 ops_mgr.pem to change the permissions on the .pem file to be more restrictive.
For example:
Where FQDN is the fully qualified domain name of Tanzu Operations Manager.
For example:
vSphere
To log in to the Tanzu Operations Manager VM with SSH in vSphere, you must have the public SSH key
that imports the Tanzu Operations Manager .ova or .ovf file into your virtualization system.
You set the public SSH key in the Public SSH Key text box of the Customize template screen when you
deployed Tanzu Operations Manager. For more information, see Deploy Tanzu Operations Manager in
Deploying Tanzu Operations Manager on vSphere.
If you lose your SSH key, you must shut down the Tanzu Operations Manager VM in the vSphere UI and
then reset the public SSH key. For more information, see Edit vApp Settings in the vSphere documentation.
76
Tanzu for Postgres on Cloud Foundry
ssh ubuntu@FQDN
Where FQDN is the fully qualified domain name of Tanzu Operations Manager.
For example:
$ ssh [email protected]
77
Tanzu for Postgres on Cloud Foundry
This topic tells you how to begin using Tanzu for Postgres on Cloud Foundry.
Tanzu for Postgres on Cloud Foundry was formerly known as VMware Postgres for
VMware Tanzu Application Service.
Prerequisites
You must have:
1. An Ops Manager installation with Tanzu for Postgres on Cloud Foundry installed and listed in the
Marketplace.
2. A Space Developer or Admin account on the VMware Tanzu Application Service for VMs
installation.
A shell
Then you must log in to the org and space containing your app.
Next Steps
Use Tanzu for Postgres on Cloud Foundry in your app
Every app and service is scoped to a space. To use a service, an app must exist in the same space as an
instance of the service. To use Tanzu for Postgres on Cloud Foundry in an app:
1. Use the cf CLI to log in to the org and space that contains the app.
78
Tanzu for Postgres on Cloud Foundry
2. Make sure a Tanzu for Postgres on Cloud Foundry instance exists in the same space.
If the space does not already have a Tanzu for Postgres on Cloud Foundry instance, create
one.
If the space already has a Tanzu for Postgres on Cloud Foundry instance, you can bind
your app to the existing instance.
3. Bind the app to the Tanzu for Postgres on Cloud Foundry instance to enable the app to use
Postgres.
If the output lists postgres in the service column, on-demand Tanzu for Postgres on Cloud
Foundry is available. If it is not available, ask your operator to install it.
For example:
To confirm that a Tanzu for Postgres on Cloud Foundry instance is running in the space,
run cf services.
Any postgres listings in the service column are service instances of on-demand Tanzu for
Postgres on Cloud Foundry in the space.
For example:
Where:
For example:
79
Tanzu for Postgres on Cloud Foundry
These variables become available to the application when the service is bound to the application.
The following shows a sample of environment variables VCAP_SERVICES and VCAP_APPLICATION for
Postgres Service with single instance:
VCAP_SERVICES: {
"postgres": [
{
"binding_guid": "75e8053f-57ac-90cc-b7af-4bc40d714c2e",
"binding_name": null,
"credentials": {
"db": "my-db",
"hosts": [
"q-s0.postgres-instance.shamrockgreen-services-subnet.service-instance-f23
98a52-5430-2b17-50sd-b50f0c7c150c.bosh"
],
"jdbcUrl": "jdbc:postgresql://q-s0.postgres-instance.shamrockgreen-services-su
bnet.service-instance-f2398a52-5430-2b17-50sd-b50f0c7c150c.bosh:5432/postgres?user=pga
dmin&password=1a4E820y19XgFmH4143",
"password": "1a4E820y19XgFmH4143",
"port": 5432,
"service_gateway_access_port": 0,
"service_gateway_enabled": false,
"user": "myuser"
},
"instance_guid": "22a1998f-e30f-3032-b360-f7a21de7a461",
"instance_name": "postgres-instance",
"label": "postgres",
"name": "postgres-instance",
"plan": "on-demand-postgres-db",
"provider": null,
"syslog_drain_url": null,
"tags": [
"postgres",
"pivotal",
"on-demand"
],
"volume_mounts": []
}
]
}
VCAP_APPLICATION: {
"application_id": "9646bed4-d52d-4a6c-b781-6d589e3873f0",
"application_name": "sample-app",
"application_uris": [
"my-app.example.com"
],
80
Tanzu for Postgres on Cloud Foundry
"cf_api": "https://api.example.com",
"limits": {
"fds": 16384
},
"name": "pg-app-ci-2",
"organization_id": "eb4d1234-0w34-2e21-912c-f4ae36501845",
"organization_name": "my-org",
"space_id": "a32e9046-0167-4e64-95c3-abe04d99c2bd",
"space_name": "my-space",
"uris": [
"my-app.example.com"
],
"users": null
}
The application developer can use the following environment variables from VCAP_SERVICES to create a
Postgres connection URI:
port
user
password
db
To connect an application using jdbc drivers to the Postgres service, you can use the environment variable
jdbcUrl. For example, the jdbcUrl looks like this:
The following is sample Java code to form a connection string for a JDBC driver for a Postgres Service with
Single Instance. This is just an example. You can use the jdbcUrl instead.
@Configuration
@Profile("cloud")
public class DataSourceConfiguration {
@Bean
public Cloud cloud() {
return new CloudFactory().getCloud();
}
@Value("${SSL_MODE}")
private String sslMode;
@Bean
public DataSource dataSource() {
VcapServices vcapServices = gson.fromJson(vsJson, VcapServices.class);
81
Tanzu for Postgres on Cloud Foundry
if(!StringUtils.isEmpty(sslMode)) {
jdbcUri.append("&sslmode="+sslMode);
jdbcUri.append("&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory");
}
}
}
These variables become available to the application when the service is bound to the application.
The following shows a sample of environment variables VCAP_SERVICES and VCAP_APPLICATION for
Postgres HA service:
VCAP_SERVICES: {
"postgres": [
{
"binding_guid": "75e8053f-57ac-90cc-b7af-4bc40d714c2e",
"binding_name": null,
"credentials": {
"db": "my-db",
"hosts": [
"q-s0.postgres-instance.shamrockgreen-services-subnet.service-instance-f23
98a52-5430-2b17-50sd-b50f0c7c150c.bosh"
],
"jdbcUrl": "jdbc:postgresql://q-s0.postgres-instance.shamrockgreen-services-su
bnet.service-instance-f2398a52-5430-2b17-50sd-b50f0c7c150c.bosh:5432/postgres?targetSe
82
Tanzu for Postgres on Cloud Foundry
rverType=primary&user=pgadmin&password=1a4E820y19XgFmH4143",
"password": "1a4E820y19XgFmH4143",
"port": 5432,
"service_gateway_access_port": 0,
"service_gateway_enabled": false,
"user": "myuser"
},
"instance_guid": "22a1998f-e30f-3032-b360-f7a21de7a461",
"instance_name": "postgres-instance",
"label": "postgres",
"name": "postgres-instance",
"plan": "on-demand-postgres-db",
"provider": null,
"syslog_drain_url": null,
"tags": [
"postgres",
"pivotal",
"on-demand"
],
"volume_mounts": []
}
]
}
VCAP_APPLICATION: {
"application_id": "9646bed4-d52d-4a6c-b781-6d589e3873f0",
"application_name": "sample-app",
"application_uris": [
"my-app.example.com"
],
"cf_api": "https://api.example.com",
"limits": {
"fds": 16384
},
"name": "pg-app-ci-2",
"organization_id": "eb4d1234-0w34-2e21-912c-f4ae36501845",
"organization_name": "my-org",
"space_id": "a32e9046-0167-4e64-95c3-abe04d99c2bd",
"space_name": "my-space",
"uris": [
"my-app.example.com"
],
"users": null
}
The application developer can use the following environment variables from VCAP_SERVICES to create a
Postgres connection URI:
port
user
password
db
83
Tanzu for Postgres on Cloud Foundry
To connect an application using jdbc drivers to the Postgres HA service, you can simply use the
environment variable jdbcUrl. For example, the jdbcUrl would look like this:
You can use targetServerType=primary to specify that the JDBC driver only connects to the primary
node in the HA cluster.
The following is sample Java code to form a connection string for a JDBC driver for a Postgres HA service.
This is just an example. You can simply use the jdbcUrl instead.
@Configuration
@Profile("cloud")
public class DataSourceConfiguration {
@Bean
public Cloud cloud() {
return new CloudFactory().getCloud();
}
@Value("${SSL_MODE}")
private String sslMode;
@Bean
public DataSource dataSource() {
VcapServices vcapServices = gson.fromJson(vsJson, VcapServices.class);
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
List<String> hosts = vcapServices.getPostgres().get(0).getCredentials().getHos
ts();
Long port = vcapServices.getPostgres().get(0).getCredentials().getPort();
StringBuilder jdbcUri = new StringBuilder("jdbc:postgresql://");
Stream<String>withPort=hosts.stream().map(s-> String.format("%s:%d",s,port));
jdbcUri.append(withPort.collect(Collectors.joining(",")));
jdbcUri.append("/")
.append(vcapServices.getPostgres().get(0).getCredentials().getDb())
.append("?targetServerType=primary");
if(!StringUtils.isEmpty(sslMode)) {
jdbcUri.append("&sslmode="+sslMode);
jdbcUri.append("&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory");
}
84
Tanzu for Postgres on Cloud Foundry
}
}
Where:
APP is the app you want to use the Postgres service instance for.
For example:
The following information assumes that you meet the prerequisites for using on-demand Tanzu for Postgres
on Cloud Foundry. For more information, see Prerequisites.
If you have enabled a service-gateway plan, you can create a service instance that can connect to
components outside your foundation. Contact your operator if you are unsure which plans are enabled for
service-gateway access. For information about the architecture and use cases, see Service-Gateway
access.
As per release version 1.2 and onwards, you need not pass the external_port and
router_group params. This port will be assigned automatically from within the configurable
port range defined under Reservable ports range for TCP field in Ops Manager during
enabling of service gateway mentioned in Enable Service Gateway Using the TAS for VMs
Tile
85
Tanzu for Postgres on Cloud Foundry
{
"credentials": {
"db": "postgres",
"hosts": [
"q-s0.postgres-instance.tilt-541058-services-subnet.service-instance-97e48
698-93fa-4f5c-bdb5-874019238737.bosh"
],
"jdbcUrl": "jdbc:postgresql://q-s0.postgres-instance.tilt-541058-services-su
bnet.service-instance-97e48698-93fa-4f5c-bdb5-874019238737.bosh:5432/postgres?t
argetServerType=primary&user=pgadmin&password=9qX204t6v178kBAE35xC",
"password": "9qX204t6v178kBAE35xC",
"port": 5432,
"service_gateway": {
"host": "tcp.tilt-541058.cf-app.com",
"jdbcUrl": "jdbc:postgresql://tcp.tilt-541058.cf-app.com:1082/postgres?tar
getServerType=primary&user=pgadmin&password=9qX204t6v178kBAE35xC",
"port": 1082,
"uri": "postgresql://pgadmin:[email protected]
om:1082/postgres"
},
"uri": "postgresql://pgadmin:[email protected]
t-541058-services-subnet.service-instance-97e48698-93fa-4f5c-bdb5-874019238737.
bosh:5432/postgres",
"user": "pgadmin"
}
}
The port field in service_gateway informs you of the port that was reserved for the created
service instance. You can use this uri to connect to Postgres from outside your foundation.
After you upgrade to Tanzu for Postgres on Cloud Foundry v1.2.0, if you delete a service instance other
running services might fail while connecting to their bound apps or trying to access services like psql on
exposed service gateway ports.
After you upgrade to Tanzu for Postgres on Cloud Foundry v1.2.0, when you delete a service instance,
other services fail if both of these conditions are met:
The service was created before you upgraded to Tanzu for Postgres on Cloud Foundry v1.2.0.
The service was created with the same router group name as the one being deleted.
86
Tanzu for Postgres on Cloud Foundry
Prior to Tanzu for Postgres on Cloud Foundry v1.2.x, you created a service instance with service gateway
enabled by mentioning the request params. For example,
The router_group param requires the name of an existing router group, for example, default-tcp is the
default router group that already exists. Users might create multiple service instances using the default-
tcp router group or another router group that they create.
When you delete an existing service after upgrading to Tanzu for Postgres on Cloud Foundry v1.2, the
router group that was used to create the service is also deleted. This causes all service instances to fail to
connect over the exposed service gateway port. This happens because the “delete-router-group” pre-
delete errand that was added in Tanzu for Postgres on Cloud Foundry v1.2.x is invoked when you delete
the service instance.
1. Before you run routing API, you must install and setup the UAA CLI described in Setup UAA CLI.
2. Get the value for UAA token and FQDN of your TAS env from the previous step.
Procedure:
Where
UAA-TOKEN is the bearer token from the UAA CLI setup step.
TYPE is tcp.
87
Tanzu for Postgres on Cloud Foundry
RESERVABLE-PORTS is a comma delimited list of reservable port or port ranges. These ports must
fall between 1024 and 65535 (inclusive).
Example
Example
[
{
"guid": "966b0dea-8ee1-4ffd-7891-15f924b20074",
"name": "default-tcp",
"type": "tcp",
"reservable_ports": "1024-32567"
}
]
Where
`ROUTER_GROUP_NAME` is the name of existing router group (or created in previous step)
When the service is updated to use the new router group name, it won’t affect other services on deletion.
88
Tanzu for Postgres on Cloud Foundry
uaa version
4. Get the fqdn for the env where TAS is deployed and save it in a shell variable so that you can set
the uaa target:
export uaa_fqdn="https://<fqdn_for_tas_env>"
Example:
export uaa_fqdn="https://uaa.sys.tas.z9027a87e.shepherd.lease"
5. Get the UAA Admin Client credentials from the Ops manager UI:
6. Create a new UAA client with following scopes to be able to create new router group:
Where
CLIENT-NAME is the name you want to keep for this new client.
Example:
This will generate a new client with appropriate permissions to run the routing API to create a new
router group later.
7. Once, the client is created, get the client Bearer token to authorize API calls for routing:
89
Tanzu for Postgres on Cloud Foundry
8. To display the token and use it sub sequentially for running routing API:
uaa context
{
"client_id": "routing-client",
"grant_type": "client_credentials",
"username": "",
"Token":
{
"access_token": "eyJqa3UiOiJodHRwczovL3VhYSIkqx6M-2GsIJYS0nQ...(tru
ncated)",
"token_type": "bearer",
"expiry": "2024-11-21T00:02:07.493058+05:30"
}
}
This token will be used during API call for creating router group, it has default expiry of 24 hours.
90