@@ -13,16 +13,20 @@ Systems) objects in the database and be queried via SQL.
1313 in Kubernetes via { {name.ln }} .
1414
1515The CloudNativePG Community maintains container images that are built on top
16- of the official [ PostGIS images hosted on DockerHub ] ( https://hub.docker. com/r/postgis/postgis ) .
17- For more information please visit:
16+ of the maintained [ PostgreSQL Container images ] ( https://github. com/cloudnative-pg/postgres-containers ) .
17+ For more information, please visit:
1818
1919- The [ ` postgis-containers ` project in GitHub] ( https://github.com/cloudnative-pg/postgis-containers )
2020- The [ ` postgis-containers ` Container Registry in GitHub] ( https://github.com/cloudnative-pg/postgis-containers/pkgs/container/postgis )
2121
22- Additionally, EDB provides container images for EDB Postgres Advanced Server
23- that include PostGIS and makes them available in the official
24- [ registry on Quay.io] ( https://quay.io/repository/enterprisedb/edb-postgres-advanced?tab=tags )
25- with the ` -postgis ` suffix.
22+ Additionally, EDB provides container images for:
23+
24+ - Community PostgreSQL + PostGIS
25+ - EDB Postgres Advanced Server (EPAS) + PostGIS
26+ - EDB Postgres Extended (PGE) + PostGIS
27+
28+ and makes them available in the official registry
29+ at ` docker.enterprisedb.com ` , with the ` -postgis ` suffix.
2630
2731## Basic concepts about a PostGIS cluster
2832
@@ -43,18 +47,18 @@ do this in two ways:
4347
4448- install it in the application database, which is the main and supposedly only
4549 database you host in the cluster according to the microservice architecture, or
46- - install it in the ` template1 ` database so as to make it available for all the
50+ - install it in the ` template1 ` database to make it available for all the
4751 databases you end up creating in the cluster, in case you adopt the monolith
4852 architecture where the instance is shared by multiple databases
4953
5054!!! Info
51- For more information on the microservice vs monolith architecture in the database
55+ For more information on the microservice vs monolith architecture in the database,
5256 please refer to the [ "How many databases should be hosted in a single PostgreSQL instance?" FAQ] ( faq.md )
5357 or the [ "Database import" section] ( database_import.md ) .
5458
5559## Create a new PostgreSQL cluster with PostGIS
5660
57- Let's suppose you want to create a new PostgreSQL 14 cluster with PostGIS 3.2 .
61+ Let's suppose you want to create a new PostgreSQL 18 cluster with PostGIS 3.6 .
5862
5963The first step is to ensure you use the right PostGIS container image for the
6064operand, and properly set the ` .spec.imageName ` option in the ` Cluster `
@@ -66,82 +70,90 @@ provides some guidance on how the creation of a PostGIS cluster can be done.
6670!!! Warning
6771 Please consider that, although convention over configuration applies in
6872 { {name.ln }} , you should spend time configuring and tuning your system for
69- production. Also the ` imageName ` in the example below deliberately points
70- to the latest available image for PostgreSQL 14 - you should use a specific
73+ production. Also, the ` imageName ` in the example below deliberately points
74+ to the latest available image for PostgreSQL 17 - you should use a specific
7175 image name or, preferably, the SHA256 digest for true immutability.
7276
7377``` yaml
74- apiVersion : postgresql.k8s.enterprisedb .io/v1
78+ apiVersion : postgresql.cnpg .io/v1
7579kind : Cluster
7680metadata :
7781 name : postgis-example
7882spec :
79- instances : 3
80- imageName : ghcr.io/enterprisedb/postgresql:16-postgis
81- bootstrap :
82- initdb :
83- postInitTemplateSQL :
84- - CREATE EXTENSION postgis;
85- - CREATE EXTENSION postgis_topology;
86- - CREATE EXTENSION fuzzystrmatch;
87- - CREATE EXTENSION postgis_tiger_geocoder;
88-
83+ instances : 1
84+ imageName : docker.enterprisedb.com/k8s_enterprise/postgresql:17-postgis-ubi9
8985 storage :
9086 size : 1Gi
87+ postgresql :
88+ parameters :
89+ log_statement : ddl
90+ ---
91+ apiVersion : postgresql.cnpg.io/v1
92+ kind : Database
93+ metadata :
94+ name : postgis-example-app
95+ spec :
96+ name : app
97+ owner : app
98+ cluster :
99+ name : postgis-example
100+ extensions :
101+ - name : postgis
102+ - name : postgis_topology
103+ - name : fuzzystrmatch
104+ - name : postgis_tiger_geocoder
91105` ` `
92106
93- The example relies on the ` postInitTemplateSQL` option which executes a list of
94- queries against the `template1` database, before the actual creation of the
95- application database (called `app`). This means that, once you have applied the
96- manifest and the cluster is up, you will have the above extensions installed in
97- both the template database and the application database, ready for use.
107+ The example leverages the ` Database` resource's declarative extension
108+ management to add the specified extensions to the `app` database.
98109
99110!!! Info
100111 Take some time and look at the available options in `.spec.bootstrap.initdb`
101112 from the [API reference](pg4k.v1.md#postgresql-k8s-enterprisedb-io-v1-BootstrapInitDB), such as
102113 ` postInitApplicationSQL` .
103114
115+ !!! Info
116+ For more details, see the
117+ ["Managing Extensions in a Database" section](declarative_database_management.md#managing-extensions-in-a-database).
118+
104119You can easily verify the available version of PostGIS that is in the
105120container, by connecting to the `app` database (you might obtain different
106121values from the ones in this document) :
107122
108123` ` ` console
109- $ kubectl exec -ti postgis-example-1 -- psql app
110- Defaulted container "postgres" out of: postgres, bootstrap-controller (init)
111- psql (16.0 (Debian 16.0-1.pgdg110+1))
124+ $ kubectl cnpg psql postgis-example -- app
125+ psql (18.0 (Debian 18.0-1.pgdg13+3))
112126Type "help" for help.
113127
114128app=# SELECT * FROM pg_available_extensions WHERE name ~ '^postgis' ORDER BY 1;
115129 name | default_version | installed_version | comment
116130--------------------------+-----------------+-------------------+------------------------------------------------------------
117- postgis | 3.2.2 | 3.2.2 | PostGIS geometry and geography spatial types and functions
118- postgis-3 | 3.2.2 | | PostGIS geometry and geography spatial types and functions
119- postgis_raster | 3.2.2 | | PostGIS raster types and functions
120- postgis_raster-3 | 3.2.2 | | PostGIS raster types and functions
121- postgis_sfcgal | 3.2.2 | | PostGIS SFCGAL functions
122- postgis_sfcgal-3 | 3.2.2 | | PostGIS SFCGAL functions
123- postgis_tiger_geocoder | 3.2.2 | 3.2.2 | PostGIS tiger geocoder and reverse geocoder
124- postgis_tiger_geocoder-3 | 3.2.2 | | PostGIS tiger geocoder and reverse geocoder
125- postgis_topology | 3.2.2 | 3.2.2 | PostGIS topology spatial types and functions
126- postgis_topology-3 | 3.2.2 | | PostGIS topology spatial types and functions
131+ postgis | 3.6.0 | 3.6.0 | PostGIS geometry and geography spatial types and functions
132+ postgis-3 | 3.6.0 | | PostGIS geometry and geography spatial types and functions
133+ postgis_raster | 3.6.0 | | PostGIS raster types and functions
134+ postgis_raster-3 | 3.6.0 | | PostGIS raster types and functions
135+ postgis_sfcgal | 3.6.0 | | PostGIS SFCGAL functions
136+ postgis_sfcgal-3 | 3.6.0 | | PostGIS SFCGAL functions
137+ postgis_tiger_geocoder | 3.6.0 | 3.6.0 | PostGIS tiger geocoder and reverse geocoder
138+ postgis_tiger_geocoder-3 | 3.6.0 | | PostGIS tiger geocoder and reverse geocoder
139+ postgis_topology | 3.6.0 | 3.6.0 | PostGIS topology spatial types and functions
140+ postgis_topology-3 | 3.6.0 | | PostGIS topology spatial types and functions
127141(10 rows)
128142` ` `
129143
130- The next step is to verify that the extensions listed in the
131- ` postInitTemplateSQL` section have been correctly installed in the `app`
132- database.
144+ The next step is to verify that the extensions listed in the `Database`
145+ resource have been correctly installed in the `app` database.
133146
134147` ` ` console
135148app=# \d x
136- List of installed extensions
137- Name | Version | Schema | Description
138- ------------------------+---------+------------+------------------------------------------------------------
139- fuzzystrmatch | 1.1 | public | determine similarities and distance between strings
140- plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
141- postgis | 3.2.2 | public | PostGIS geometry and geography spatial types and functions
142- postgis_tiger_geocoder | 3.2.2 | tiger | PostGIS tiger geocoder and reverse geocoder
143- postgis_topology | 3.2.2 | topology | PostGIS topology spatial types and functions
144- (5 rows)
149+ List of installed extensions
150+ Name | Version | Default version | Schema | Description
151+ ------------------------+---------+-----------------+------------+------------------------------------------------------------
152+ fuzzystrmatch | 1.2 | 1.2 | public | determine similarities and distance between strings
153+ plpgsql | 1.0 | 1.0 | pg_catalog | PL/pgSQL procedural language
154+ postgis | 3.6.0 | 3.6.0 | public | PostGIS geometry and geography spatial types and functions
155+ postgis_tiger_geocoder | 3.6.0 | 3.6.0 | tiger | PostGIS tiger geocoder and reverse geocoder
156+ postgis_topology | 3.6.0 | 3.6.0 | topology | PostGIS topology spatial types and functions
145157` ` `
146158
147159Finally :
@@ -150,6 +162,7 @@ Finally:
150162app=# SELECT postgis_full_version();
151163 postgis_full_version
152164----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
153- POSTGIS="3.2.2 628da50" [EXTENSION] PGSQL="140" GEOS="3.9.0-CAPI-1.16.2" PROJ="7.2.1" LIBXML="2.9.10" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" TOPOLOGY
165+ POSTGIS="3.6.0 4c1967d" [EXTENSION] PGSQL="180" GEOS="3.13.1-CAPI-1.19.2" PROJ="9.6.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.
166+ db" (compiled against PROJ 9.6.0) LIBXML="2.9.14" LIBJSON="0.18" LIBPROTOBUF="1.5.1" WAGYU="0.5.0 (Internal)" TOPOLOGY
154167(1 row)
155168` ` `
0 commit comments