Skip to content

Commit

Permalink
Add age image for bookworm
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <[email protected]>
  • Loading branch information
souravbiswassanto committed May 14, 2024
1 parent c324e9c commit 01824e9
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 257 deletions.
57 changes: 10 additions & 47 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM postgres:15.3-alpine
FROM postgres:15.5-bookworm AS builder

ENV TDS_FDW_VERSION 2.0.3
RUN apt-get update \
&& apt-get install -y git build-essential postgresql-server-dev-15 libreadline-dev zlib1g-dev flex bison clang-14
RUN git clone https://github.com/apache/age.git \
&& cd /age \
&& git checkout release/PG15/1.5.0 \
&& make PG_CONFIG=/usr/bin/pg_config install

RUN set -eux \
&& apk add --no-cache --virtual .fetch-deps \
ca-certificates \
openssl \
tar \
\
&& wget -O tds_fdw.tar.gz "https://github.com/tds-fdw/tds_fdw/archive/v${TDS_FDW_VERSION}.tar.gz" \
&& mkdir -p /usr/src/tds_fdw \
&& tar \
--extract \
--file tds_fdw.tar.gz \
--directory /usr/src/tds_fdw \
--strip-components 1 \
&& rm tds_fdw.tar.gz \
\
&& apk add --no-cache --virtual .build-deps \
\
freetds-dev \
gcc \
libc-dev \
make \
postgresql-dev \
\
# The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains
# the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL.
# This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077
$DOCKER_PG_LLVM_DEPS \
\
\
# build TDS FDW
&& cd /usr/src/tds_fdw \
&& make USE_PGXS=1 \
&& make USE_PGXS=1 install \
\
# add .postgis-rundeps
&& apk add --no-cache --virtual .postgis-rundeps \
\
freetds-dev \
\
# clean
&& cd / \
&& rm -rf /usr/src/tds_fdw \
&& apk del .fetch-deps .build-deps

COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh
FROM postgres:15.5-bookworm
COPY --from=builder /usr/share/postgresql /usr/share/postgresql
COPY --from=builder /usr/lib/postgresql /usr/lib/postgresql
81 changes: 78 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,89 @@

1. Install KubeDB operator.

2. Add tds_fdw version to KubeDB catalog.
2. Create catalog.yaml

```
kubectl apply -f https://github.com/kubedb/postgres-docker/raw/release-15.3-alpine-tds_fdw/example/catalog.yaml
kubectl apply -f https://raw.githubusercontent.com/kubedb/postgres-docker/15.5-bookworm-age/example/catalog.yaml
```

3. Deploy a demo PostgreSQL database.

```
kubectl apply -f https://github.com/kubedb/postgres-docker/raw/release-15.3-alpine-tds_fdw/example/demo.yaml
kubectl apply -f https://raw.githubusercontent.com/kubedb/postgres-docker/15.5-bookworm-age/example/demo.yaml
```
4. Wait until postgres is ready.
```bash
NAME VERSION STATUS AGE
postgres.kubedb.com/ha-postgres 15.5-bookworm Ready 22m

```
5. Exec into the pod and run psql command.
```bash
kubectl exec -it -n demo ha-postgres-0 -- bash
Defaulted container "postgres" out of: postgres, pg-coordinator, postgres-init-container (init)
postgres@ha-postgres-0:/$ psql
psql (15.7 (Debian 15.7-1.pgdg120+1))
Type "help" for help.

postgres=#

```
6. Run the queries to verify:
```sql
CREATE EXTENSION age;
LOAD 'age';
SET search_path = ag_catalog, postgres, public;


-- To create a graph, use the create_graph function located in the ag_catalog namespace.

SELECT create_graph('graph_name');
-- To create a single vertex, use the CREATE clause.

SELECT *
FROM cypher('graph_name', $$
CREATE (n)
$$) as (v agtype);
-- To create a single vertex with the label, use the CREATE clause.

SELECT *
FROM cypher('graph_name', $$
CREATE (:label)
$$) as (v agtype);
-- To query the graph, you can use the MATCH clause.

SELECT *
FROM cypher('graph_name', $$
MATCH (v)
RETURN v
$$) as (v agtype);
-- You can use the following to create an edge, for example, between two nodes.

SELECT *
FROM cypher('graph_name', $$
MATCH (a:label), (b:label)
WHERE a.property = 'Node A' AND b.property = 'Node B'
CREATE (a)-[e:RELTYPE]->(b)
RETURN e
$$) as (e agtype);
-- To create an edge and set properties.

SELECT *
FROM cypher('graph_name', $$
MATCH (a:label), (b:label)
WHERE a.property = 'Node A' AND b.property = 'Node B'
CREATE (a)-[e:RELTYPE {property:a.property + '<->' + b.property}]->(b)
RETURN e
$$) as (e agtype);
-- Example

SELECT *
FROM cypher('graph_name', $$
MATCH (a:Person), (b:Person)
WHERE a.name = 'Node A' AND b.name = 'Node B'
CREATE (a)-[e:RELTYPE {name:a.name + '<->' + b.name}]->(b)
RETURN e
$$) as (e agtype);

```
32 changes: 22 additions & 10 deletions example/catalog.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
apiVersion: catalog.kubedb.com/v1alpha1
kind: PostgresVersion
metadata:
name: "15.3-alpine-tds-fdw"
name: 15.5-bookworm
spec:
archiver:
addon:
name: postgres-addon
tasks:
manifestBackup:
name: manifest-backup
manifestRestore:
name: manifest-restore
volumeSnapshot:
name: volume-snapshot
walg:
image: ghcr.io/kubedb/postgres-archiver:v0.6.0_15.5-bookworm
coordinator:
image: ghcr.io/kubedb/pg-coordinator:v0.20.0
image: ghcr.io/kubedb/pg-coordinator:v0.29.0
db:
baseOS: alpine
image: ghcr.io/kubedb/postgres:15.3-alpine-tds_fdw
baseOS: debian
image: souravbiswassanto/postgres:15.5-bookworm-age
distribution: Official
exporter:
image: prometheuscommunity/postgres-exporter:v0.9.0
image: prometheuscommunity/postgres-exporter:v0.15.0
initContainer:
image: ghcr.io/kubedb/postgres-init:0.9.0
image: ghcr.io/kubedb/postgres-init:0.12.0
podSecurityPolicies:
databasePolicyName: postgres-db
securityContext:
runAsAnyNonRoot: false
runAsUser: 70
runAsAnyNonRoot: true
runAsUser: 999
stash:
addon:
backupTask:
Expand All @@ -26,5 +38,5 @@ spec:
name: postgres-restore-15.1
updateConstraints:
allowlist:
- "14.2"
version: "15.3"
- "14.2"
version: "15.5"
12 changes: 5 additions & 7 deletions example/demo.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
apiVersion: kubedb.com/v1alpha2
kind: Postgres
metadata:
name: demo-tds-fdw
namespace: default
name: ha-postgres
namespace: demo
spec:
version: "15.3-alpine-tds-fdw"
version: "15.5-bookworm"
replicas: 3
standbyMode: Hot
storageType: Durable
storage:
storageClassName: "linode-block-storage"
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
terminationPolicy: WipeOut
storage: 1Gi
52 changes: 0 additions & 52 deletions example/pgadmin.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions example/setup.sql

This file was deleted.

Loading

0 comments on commit 01824e9

Please sign in to comment.