CrunchyData / postgres-operator

Production PostgreSQL for Kubernetes, from high availability Postgres clusters to full-scale database-as-a-service.
https://access.crunchydata.com/documentation/postgres-operator/v5/
Apache License 2.0
3.93k stars 591 forks source link

Is it possible to switch timescaledb extension license with images of v5 ? #2692

Closed gjeusel closed 1 year ago

gjeusel commented 3 years ago

Trying to modify it using patroni:

  patroni:
    dynamicConfiguration:
      postgresql:
        parameters:
          shared_preload_libraries: timescaledb
          timescaledb.license: timescale  # instead of apache by default in crunchy

Result in:

postgres@localhost:tutorial> create extension timescaledb cascade;
could not access file "$libdir/timescaledb-tsl-2.4.0": No such file or directory

And indeed, this file does not exists at:

bash-4.4$ ls /usr/pgsql-13/lib/ | grep -i timescale
timescaledb-2.4.0.so
timescaledb.so

Would it be possible to build the docker images with this additional file ? Even though I understand the reasons for the license to be kept as "apache" by default.

gjeusel commented 3 years ago

Sorry, maybe it would be more appropriate to open this issue at https://github.com/CrunchyData/crunchy-containers ?

gjeusel commented 3 years ago

A sample of customized dockerfile to get latest timescaledb is actually found in another unrelated issue.

Still, the question remains, would it be possible to add the tsl file in the official image ? 🙏

ludzzz commented 3 years ago

Hi, I bumped into this issue as well. at first, I tried to use timescaledb function. But got this error:

 ERROR: function "time_bucket_gapfill" is not supported under the current "apache" license
  Hint: Upgrade your license to 'timescale' to use this free community feature.

To fix that I found that we can do (what @gjeusel was doing in config):

ALTER SYSTEM SET timescaledb.license = 'timescale';
-- reload setting changes
SELECT pg_reload_conf();

And got the error:

 ERROR: could not access file "$libdir/timescaledb-tsl-2.4.0": No such file or directory

Same as @gjeusel Would it be possible to add that lib?

ludzzz commented 3 years ago

Hi guys,

No update on this issue? @gjeusel did you find a workaround?

johanjk commented 3 years ago

@ludzzz The workaround refered to by gjeusel works.

Here is a complete working example:

Dockerfile:

ARG VERSION
FROM registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis-ha:${VERSION}

USER root

RUN curl -sSL -o /etc/yum.repos.d/timescale_timescaledb.repo "https://packagecloud.io/install/repositories/timescale/timescaledb/config_file.repo?os=el&dist=8" && \
    yum --disablerepo=crunchypg13 update -y && \
    yum --disablerepo=crunchypg13 install -y timescaledb-2-postgresql-13 && \
    yum clean all
USER 26
# magical user used here: https://github.com/CrunchyData/crunchy-containers/blob/master/build/postgres-gis/Dockerfile

Build and push your dockerfile to a repository.

Operator yaml:

apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
  name: example-cluster
spec:
  image: {{ .Values.image }}
  imagePullSecrets:
   - name: dockersecret
  patroni:
    dynamicConfiguration:
      postgresql:
        parameters:
          shared_preload_libraries: timescaledb
          timescaledb.license: timescale  

imagePullSecrets is only required If you are using a private repository for your image.

yash-kalwani commented 2 years ago

@johanjk i tried using your dockerfile but it fails with the following logs

ERROR: MODE environment variable is not set, aborting.

any idea what might be going wrong

johanjk commented 2 years ago

I assume the log is an output from when you ran the container standalone using docker run, not through the crd of the operator? In that case, see https://crunchydata.github.io/crunchy-containers/stable/container-specifications/crunchy-postgres/#running-modes to set the mode env var.

kbmanseau commented 2 years ago

Hello, is this something that progress might be made on? I am attempting to build a custom image as mentioned in this thread however I am hitting:

`#5 1.922 CentOS Linux 8 - AppStream 146 B/s | 38 B 00:00

5 1.933 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist`

I assume this is related to centos8 being EOL?

@yash-kalwani were you able to build the image successfully?

kbmanseau commented 2 years ago

For anyone coming across the issue I was facing, adding --disablerepo=crunchypg13,appstream,baseos to the yum commands allowed me to download the timescaldb version as described above. It's not ideal but is a workaround

benjamin-bergia commented 2 years ago

I am hitting the license issue too. The compression is not available with the Apache version. Honestly, without compression TS is pretty much unusable in production.

kbmanseau commented 2 years ago

@benjamin-bergia, I was able to get past this by building my own image. I have the following DOCKERFILE:

FROM registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.5-0
USER  root
RUN  curl  -sSL  -o  /etc/yum.repos.d/timescale_timescaledb.repo  "https://packagecloud.io/install/repositories/timescale/timescaledb/config_file.repo?os=el&dist=8"  &&  \
yum  --disablerepo=crunchypg13,appstream,baseos  update  -y  &&  \
yum  --disablerepo=crunchypg13,appstream,baseos  install  -y  timescaledb-2-postgresql-13  &&  \
yum  clean  all

USER  26
benjamin-bergia commented 2 years ago

Thanks a lot @kbmanseau !

I still to have some issues afterward:

 ALTER SYSTEM SET timescaledb.license = 'timescale';
ERROR:  could not access file "$libdir/timescaledb-tsl-2.5.0": No such file or directory
promscale=# CREATE EXTENSION promscale;
ERROR:  could not access file "$libdir/timescaledb-tsl-2.5.0": No such file or directory
promscale=# CREATE EXTENSION timescaledb;
ERROR:  extension "timescaledb" has already been loaded with another version
DETAIL:  The loaded version is "2.5.0".
HINT:  Start a new session and execute CREATE EXTENSION as the first command. Make sure to pass the "-X" flag to psql.
promscale=# 

I modified the dockerfile slightly to add the promscale extension:

FROM registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.5-0
USER  root
RUN  curl  -sSL  -o  /etc/yum.repos.d/timescale_timescaledb.repo  "https://packagecloud.io/install/repositories/timescale/timescaledb/config_file.repo?os=el&dist=8"  &&  \
yum  --disablerepo=crunchypg13,appstream,baseos update -y &&  \
yum  --disablerepo=crunchypg13,appstream,baseos install -y timescaledb-2-postgresql-13  &&  \
curl -sSL -O https://github.com/timescale/promscale_extension/releases/download/0.3.0/promscale_extension-0.3.0.pg13.x86_64.rpm && \
yum --disablerepo=crunchypg13,appstream,baseos localinstall -y promscale_extension-0.3.0.pg13.x86_64.rpm && \
rm promscale_extension-0.3.0.pg13.x86_64.rpm && \
yum clean all
USER 26

and here is my cluster config:

  patroni:
    dynamicConfiguration:
      postgresql:
        parameters:
          shared_preload_libraries: timescaledb,promscale
          timescaledb.license: timescale
benjamin-bergia commented 2 years ago

Got it to work!

The version of the packages to install has to be 2.5.0: timescaledb-2-postgresql-13-2.5.0 timescaledb-2-loader-postgresql-13-2.5.0. I tried with 2.5.2 and it doesn't work. By default, when not specifying the version, it defaults to 2.6.0.

New Dockerfile:

FROM registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.5-0

USER  root

RUN  curl  -sSL  -o  /etc/yum.repos.d/timescale_timescaledb.repo  "https://packagecloud.io/install/repositories/timescale/timescaledb/config_file.repo?os=el&dist=8"  &&  \
yum  --disablerepo=crunchypg13,appstream,baseos update -y &&  \
yum  --disablerepo=crunchypg13,appstream,baseos install -y timescaledb-2-postgresql-13-2.5.0 timescaledb-2-loader-postgresql-13-2.5.0 &&  \
curl -sSL -O https://github.com/timescale/promscale_extension/releases/download/0.3.0/promscale_extension-0.3.0.pg13.x86_64.rpm && \
yum --disablerepo=crunchypg13,appstream,baseos localinstall -y promscale_extension-0.3.0.pg13.x86_64.rpm && \
rm promscale_extension-0.3.0.pg13.x86_64.rpm && \
yum clean all

USER 26

Thanks again everyone

mariusstaicu commented 2 years ago

Any idea how to install the tsl extension in a ubi8 container ?

johanjk commented 2 years ago

@mariusstaicu the following works for me (note it resembles previously posted dockerfiles in this thread very closely)

ARG VERSION
FROM registry.developers.crunchydata.com/crunchydata/crunchy-postgres-gis:${VERSION}

USER root

RUN curl -sSL -o /etc/yum.repos.d/timescale_timescaledb.repo "https://packagecloud.io/install/repositories/timescale/timescaledb/config_file.repo?os=el&dist=8" && \
    microdnf --disablerepo=crunchypg14 update -y && \
    microdnf --disablerepo=crunchypg14 install -y timescaledb-2-postgresql-14 && \
    microdnf --disablerepo=crunchypg14 install -y timescaledb-toolkit-postgresql-14 && \
    microdnf clean all
USER 26
# magical user used here: https://github.com/CrunchyData/crunchy-containers/blob/master/build/postgres-gis/Dockerfile

working with -build-arg VERSION=ubi8-14.4-3.2-0

mariusstaicu commented 2 years ago

thanks @johanjk, meanwhile I managed to do it also using microdnf in a similar fashion

dberardo-com commented 1 year ago

i confirm this is working also with version ubi8-14.5-1

however, this will not work if the cluster already exists, it needs to be run on bootstrap, before running CREATE EXTENSION ... timescaledb ...

prlaurence commented 1 year ago

Closing this thread out. As noted in the thread, we include the TimescaleDB Apache 2 Edition in our container images. The TimescaleDB Community Edition is subject to the Timescale License Agreement and as a result not something that Crunchy Data packages or distributes. There are some comments in this thread regarding approaches to modifying the container images to add the TimescaleDB Community Edition extension. Crunchy Data has not validated these approaches.

David-Angel commented 1 year ago
FROM registry.developers.crunchydata.com/crunchydata/crunchy-postgres:${CRUNCHY_POSTGRES_VERSION}

USER root

RUN curl -sSL -o /etc/yum.repos.d/timescale_timescaledb.repo "https://packagecloud.io/install/repositories/timescale/timescaledb/config_file.repo?os=el&dist=8" && \
    microdnf update -y && \
    microdnf install -y timescaledb-2-loader-postgresql-14-2.11.0 && \
    microdnf install -y timescaledb-2-postgresql-14-2.11.0 && \
    microdnf install -y timescaledb-toolkit-postgresql-14-1.16.0 && \
    microdnf clean all

USER 26

Here is a version that works and uses a specific version of timescale. If you don't do this you get a new version every time you build and that can cause minor product upgrades to be incompatible.

jaitaiwan commented 10 months ago

I found the answer to the original question that was posted here - this should probably be closed and locked. Long-story short licencing issues means roll your own containers.