diff --git a/4/bookworm/Dockerfile b/4/bookworm/Dockerfile index 6134894..edd295c 100644 --- a/4/bookworm/Dockerfile +++ b/4/bookworm/Dockerfile @@ -21,7 +21,7 @@ RUN mkdir /docker-entrypoint-initdb.d # Set environment variables for IvorySQL ENV IVORY_MAJOR 4 -ENV IVORY_VERSION 4.5 +ENV IVORY_VERSION 4.6 ARG USE_CHINA_MIRROR=false # Use China mirror if specified @@ -116,7 +116,7 @@ COPY --from=builder /var/local/ivorysql /var/local/ivorysql/ COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu ENV IVORY_MAJOR 4 -ENV IVORY_VERSION 4.5 +ENV IVORY_VERSION 4.6 ARG USE_CHINA_MIRROR=false RUN mkdir /docker-entrypoint-initdb.d diff --git a/4/trixie/Dockerfile b/4/trixie/Dockerfile index edd72ca..1cace98 100644 --- a/4/trixie/Dockerfile +++ b/4/trixie/Dockerfile @@ -21,7 +21,7 @@ RUN mkdir /docker-entrypoint-initdb.d # Set environment variables for IvorySQL ENV IVORY_MAJOR 4 -ENV IVORY_VERSION 4.5 +ENV IVORY_VERSION 4.6 ARG USE_CHINA_MIRROR=false # Use China mirror if specified @@ -116,7 +116,7 @@ COPY --from=builder /var/local/ivorysql /var/local/ivorysql/ COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu ENV IVORY_MAJOR 4 -ENV IVORY_VERSION 4.5 +ENV IVORY_VERSION 4.6 ARG USE_CHINA_MIRROR=false RUN mkdir /docker-entrypoint-initdb.d diff --git a/4/ubi8/Dockerfile b/4/ubi8/Dockerfile index 148afc2..51f901e 100644 --- a/4/ubi8/Dockerfile +++ b/4/ubi8/Dockerfile @@ -19,7 +19,7 @@ RUN groupadd -g 1000 ivorysql; \ RUN mkdir /docker-entrypoint-initdb.d ENV IVORY_MAJOR 4 -ENV IVORY_VERSION 4.5 +ENV IVORY_VERSION 4.6 RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo; \ sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo @@ -87,7 +87,7 @@ COPY --from=builder /var/local/ivorysql /var/local/ivorysql/ COPY --from=builder /usr/local/bin/gosu /usr/local/bin/gosu ENV IVORY_MAJOR 4 -ENV IVORY_VERSION 4.5 +ENV IVORY_VERSION 4.6 RUN mkdir /docker-entrypoint-initdb.d diff --git a/docker-cluster/Dockerfile b/docker-cluster/Dockerfile new file mode 100644 index 0000000..7570e86 --- /dev/null +++ b/docker-cluster/Dockerfile @@ -0,0 +1,110 @@ +FROM redhat/ubi8:latest as builder + +# explicitly set user/group IDs +RUN groupadd -g 1000 ivorysql; \ + useradd -u 1000 -g ivorysql -d /var/local/ivorysql -s /bin/sh ivorysql; \ + mkdir -p /var/local/ivorysql; \ + mkdir -p /usr/src/ivorysql; \ + mkdir -p /var/lib/ivorysql; \ + chown -R ivorysql:ivorysql /var/local/ivorysql; \ + chown -R ivorysql:ivorysql /usr/src/ivorysql; \ + chown -R ivorysql:ivorysql /var/lib/ivorysql + +RUN mkdir /docker-entrypoint-initdb.d +# install ivorysql 4.6 +ENV IVORY_MAJOR 4 +ENV IVORY_VERSION 4.6 + +RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo; \ + sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo + +RUN mkdir -p /usr/src/ivorysql; \ + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm; \ + dnf install -y epel-release;\ + dnf install -y \ + make \ + readline-devel \ + zlib-devel \ + openssl-devel \ + flex \ + wget \ + dpkg; \ + dnf groupinstall -y "Development Tools";\ + dnf install -y \ + llvm-toolset llvm-devel lz4 lz4-devel lz4-libs clang-devel \ + krb5-devel libselinux-devel libxml2-devel cyrus-sasl-gssapi \ + libicu-devel e2fsprogs-devel selinux-policy systemd-devel \ + libxslt-devel openldap-devel openssl-devel pam-devel \ + libuuid-devel python3-devel readline-devel tcl-devel zlib-devel \ + perl perl-devel perl-ExtUtils-Embed;\ + dnf install -y --enablerepo=*ower*ools perl-IPC-Run perl-Time-HiRes perl-Test-Simple uuid-devel;\ + wget -O ivorysql.tar.gz "https://github.com/IvorySQL/IvorySQL/archive/refs/tags/IvorySQL_$IVORY_VERSION.tar.gz"; \ + tar \ + --extract \ + --file ivorysql.tar.gz \ + --directory /usr/src/ivorysql \ + --strip-components 1 \ + ; \ + rm ivorysql.tar.gz; \ + cd /usr/src/ivorysql; \ + wget https://repo.almalinux.org/almalinux/8/PowerTools/$(arch)/os/Packages/bison-devel-3.0.4-10.el8.$(arch).rpm; \ + dnf install -y bison-devel-3.0.4-10.el8.$(arch).rpm; \ + wget https://repo.almalinux.org/almalinux/8/AppStream/$(arch)/os/Packages/bison-3.0.4-10.el8.$(arch).rpm; \ + dnf install -y bison-3.0.4-10.el8.$(arch).rpm; \ + ./configure \ + --prefix=/var/local/ivorysql/ivorysql-$IVORY_MAJOR \ + --enable-cassert --enable-debug --enable-rpath --with-tcl \ + --with-python --with-gssapi --with-pam --with-ldap \ + --with-openssl --with-libedit-preferred --with-uuid=e2fs \ + --with-ossp-uuid --with-libxml --with-libxslt --with-perl \ + --with-icu \ + ; \ + make && make install; \ + rm -rf \ + /usr/src/ivorysql \ + /usr/local/share/doc \ + /usr/local/share/man + +FROM redhat/ubi8:latest + +RUN useradd -u 1000 ivorysql + +COPY --from=builder --chown=ivorysql:ivorysql /var/local/ivorysql /var/local/ivorysql/ + +ENV IVORY_MAJOR 4 +ENV IVORY_VERSION 4.6 + +RUN dnf install -y \ + lz4 lz4-devel lz4-libs krb5-devel libxslt-devel libicu-devel && dnf -y clean all + +#install patroni 4.0.6 +env PATRONI_VER 4.0.6 + +RUN dnf -y install --nodocs \ + --setopt=skip_missing_names_on_install=False \ + python3-pip \ + python3-psutil \ + python3-psycopg2 \ + && dnf -y clean all + +RUN pip3 install --upgrade python-dateutil \ + && pip3 install patroni[etcd]=="${PATRONI_VER}" + +ENV PGDATA /var/local/ivorysql/ivorysql-$IVORY_MAJOR/data +ENV PATRONICONF /var/local/ivorysql/ivorysql-$IVORY_MAJOR/patroni +# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) +RUN mkdir -p "$PGDATA" && chown -R ivorysql:ivorysql "$PGDATA" && chmod 750 "$PGDATA" +RUN mkdir -p "$PATRONICONF" && chown -R ivorysql:ivorysql "$PATRONICONF" && chmod 1777 "$PATRONICONF" + +COPY docker-entrypoint.sh / +RUN chmod +x docker-entrypoint.sh + +VOLUME $PGDATA $PATRONICONF + +ENV PATH $PATH:/var/local/ivorysql/ivorysql-$IVORY_MAJOR/bin + +EXPOSE 5432 5866 1521 + +USER ivorysql + +ENTRYPOINT ["/bin/sh", "/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker-cluster/docker-compose/docker-compose-etcd1.yml b/docker-cluster/docker-compose/docker-compose-etcd1.yml new file mode 100644 index 0000000..f326551 --- /dev/null +++ b/docker-cluster/docker-compose/docker-compose-etcd1.yml @@ -0,0 +1,17 @@ +services: + etcd: + image: quay.io/coreos/etcd:v3.5.8 + container_name: etcd + environment: + - ETCD_NAME=etcd1 + - ETCD_DATA_DIR=/etcd-data + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://:2379 + - ETCD_LISTEN_PEER_URLS=http://:2380 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://:2380,etcd2=http://:2380,etcd3=http://:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster + network_mode: host + volumes: + - /home/ivorysql/etcd:/etcd-data diff --git a/docker-cluster/docker-compose/docker-compose-etcd2.yml b/docker-cluster/docker-compose/docker-compose-etcd2.yml new file mode 100644 index 0000000..d2564fc --- /dev/null +++ b/docker-cluster/docker-compose/docker-compose-etcd2.yml @@ -0,0 +1,17 @@ +services: + etcd: + image: quay.io/coreos/etcd:v3.5.8 + container_name: etcd + environment: + - ETCD_NAME=etcd2 + - ETCD_DATA_DIR=/etcd-data + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://:2379 + - ETCD_LISTEN_PEER_URLS=http://:2380 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://:2380,etcd2=http://:2380,etcd3=http://:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster + network_mode: host + volumes: + - /home/ivorysql/etcd:/etcd-data diff --git a/docker-cluster/docker-compose/docker-compose-etcd3.yml b/docker-cluster/docker-compose/docker-compose-etcd3.yml new file mode 100644 index 0000000..9f8b3d5 --- /dev/null +++ b/docker-cluster/docker-compose/docker-compose-etcd3.yml @@ -0,0 +1,17 @@ +services: + etcd: + image: quay.io/coreos/etcd:v3.5.8 + container_name: etcd + environment: + - ETCD_NAME=etcd3 + - ETCD_DATA_DIR=/etcd-data + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://:2379 + - ETCD_LISTEN_PEER_URLS=http://:2380 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://:2380,etcd2=http://:2380,etcd3=http://:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster + network_mode: host + volumes: + - /home/ivorysql/etcd:/etcd-data diff --git a/docker-cluster/docker-compose/docker-compose-ivypatroni_1.yml b/docker-cluster/docker-compose/docker-compose-ivypatroni_1.yml new file mode 100644 index 0000000..54540dd --- /dev/null +++ b/docker-cluster/docker-compose/docker-compose-ivypatroni_1.yml @@ -0,0 +1,17 @@ +services: + ivypatroni1: + image: ivorysql/docker-compose-ha-cluster:4.6-4.0.6-ubi8 + restart: always + container_name: ivyhac1 + user: "ivorysql" + environment: + PATRONI_SCOPE: ivory-cluster + ETCD_HOSTS: :2379,:2379,:2379 + IVORYSQL_PASSWORD: 123456 + IVORYSQL_HOST_AUTH_METHOD: md5 + PATRONI_SERVICE_NAME: ivypatroni1 + IVORYSQL_HOST: + network_mode: host + volumes: + - /home/ivorysql/patroni:/var/local/ivorysql/ivorysql-4/patroni/ + - /home/ivorysql/ivydata:/var/local/ivorysql/ivorysql-4/data/ diff --git a/docker-cluster/docker-compose/docker-compose-ivypatroni_2.yml b/docker-cluster/docker-compose/docker-compose-ivypatroni_2.yml new file mode 100644 index 0000000..cacd07d --- /dev/null +++ b/docker-cluster/docker-compose/docker-compose-ivypatroni_2.yml @@ -0,0 +1,17 @@ +services: + ivypatroni2: + image: ivorysql/docker-compose-ha-cluster:4.6-4.0.6-ubi8 + restart: always + container_name: ivyhac2 + user: "ivorysql" + environment: + PATRONI_SCOPE: ivory-cluster + ETCD_HOSTS: :2379,:2379,:2379 + IVORYSQL_PASSWORD: 123456 + IVORYSQL_HOST_AUTH_METHOD: md5 + PATRONI_SERVICE_NAME: ivypatroni2 + IVORYSQL_HOST: + network_mode: host + volumes: + - /home/ivorysql/patroni:/var/local/ivorysql/ivorysql-4/patroni/ + - /home/ivorysql/ivydata:/var/local/ivorysql/ivorysql-4/data/ diff --git a/docker-cluster/docker-compose/docker-compose-ivypatroni_3.yml b/docker-cluster/docker-compose/docker-compose-ivypatroni_3.yml new file mode 100644 index 0000000..bba9463 --- /dev/null +++ b/docker-cluster/docker-compose/docker-compose-ivypatroni_3.yml @@ -0,0 +1,17 @@ +services: + ivypatroni3: + image: ivorysql/docker-compose-ha-cluster:4.6-4.0.6-ubi8 + restart: always + container_name: ivyhac3 + user: "ivorysql" + environment: + PATRONI_SCOPE: ivory-cluster + ETCD_HOSTS: :2379,:2379,:2379 + IVORYSQL_PASSWORD: 123456 + IVORYSQL_HOST_AUTH_METHOD: md5 + PATRONI_SERVICE_NAME: ivypatroni3 + IVORYSQL_HOST: + network_mode: host + volumes: + - /home/ivorysql/patroni:/var/local/ivorysql/ivorysql-4/patroni/ + - /home/ivorysql/ivydata:/var/local/ivorysql/ivorysql-4/data/ diff --git a/docker-cluster/docker-entrypoint.sh b/docker-cluster/docker-entrypoint.sh new file mode 100644 index 0000000..69dd5d6 --- /dev/null +++ b/docker-cluster/docker-entrypoint.sh @@ -0,0 +1,92 @@ +if [ ! -f $PATRONICONF/patroni.yml ]; then +echo "there is no patroni.yml, will generate patroni.yml " +cat > $PATRONICONF/patroni.yml <<__EOF__ +scope: ${PATRONI_SCOPE} +name: ${PATRONI_SERVICE_NAME} +namespace: /service/ + +restapi: + listen: 0.0.0.0:8008 + connect_address: ${IVORYSQL_HOST}:8008 + +etcd3: + hosts: ${ETCD_HOSTS} +bootstrap: + dcs: + ttl: 30 + loop_wait: 10 + retry_timeout: 10 + maximum_lag_on_failover: 1048576 + master_start_timeout: 300 + synchronous_mode: false + postgresql: + use_pg_rewind: true + parameters: + wal_level: replica + hot_standby: "on" + wal_keep_size: 100 + max_wal_senders: 10 + max_replication_slots: 10 + wal_log_hints: "on" + archive_mode: "off" + archive_timeout: 1800s + logging_collector: "on" + initdb: + - encoding: 'UTF8' + - locale: 'C' + - auth: '${IVORYSQL_HOST_AUTH_METHOD}' + +postgresql: + database: ivorysql + listen: 0.0.0.0:5432 + connect_address: ${IVORYSQL_HOST}:5432 + bin_dir: /var/local/ivorysql/ivorysql-$IVORY_MAJOR/bin + data_dir: $PGDATA + config_dir: $PGDATA + pgpass: /tmp/.pgpass + + + authentication: + replication: + username: ivorysql + password: '${IVORYSQL_PASSWORD}' + rewind: + username: ivorysql + password: '${IVORYSQL_PASSWORD}' + superuser: + username: ivorysql + password: '${IVORYSQL_PASSWORD}' + + parameters: + ssl: 'off' + logging_collector: on + log_directory: 'log' + ivorysql.listen_addresses: '*' + + pg_hba: + - local all all peer + - host all all 0.0.0.0/0 ${IVORYSQL_HOST_AUTH_METHOD} + - host all all ::1/128 ${IVORYSQL_HOST_AUTH_METHOD} + - local replication all peer + - host replication all 0.0.0.0/0 ${IVORYSQL_HOST_AUTH_METHOD} + - host replication all ::1/128 ${IVORYSQL_HOST_AUTH_METHOD} + +tags: + nofailover: false + noloadbalance: false + clonefrom: false + nosync: false + +log: + level: INFO + traceback_level: INFO + dir: $PATRONICONF +__EOF__ + +else + echo "will substitute patroni.yml with real value" +fi + + +echo "will start patroni......" +patroni $PATRONICONF/patroni.yml \ No newline at end of file diff --git a/docker-cluster/docker-swarm/docker-swarm-etcd.yml b/docker-cluster/docker-swarm/docker-swarm-etcd.yml new file mode 100644 index 0000000..641d863 --- /dev/null +++ b/docker-cluster/docker-swarm/docker-swarm-etcd.yml @@ -0,0 +1,69 @@ +version: '3.8' + +services: + etcd1: + image: quay.io/coreos/etcd:v3.5.8 + deploy: + replicas: 1 + placement: + constraints: + - node.role == manager + environment: + - ETCD_NAME=etcd1 + - ETCD_DATA_DIR=/etcd-data + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd1:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://etcd1:2379 + - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster + ports: + - "2379:2379" + - "2380:2380" + networks: + - etcd-net + + etcd2: + image: quay.io/coreos/etcd:v3.5.8 + deploy: + replicas: 1 + placement: + constraints: + - node.role == manager + environment: + - ETCD_NAME=etcd2 + - ETCD_DATA_DIR=/etcd-data + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd2:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://etcd2:2379 + - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster + networks: + - etcd-net + + etcd3: + image: quay.io/coreos/etcd:v3.5.8 + deploy: + replicas: 1 + placement: + constraints: + - node.role == manager + environment: + - ETCD_NAME=etcd3 + - ETCD_DATA_DIR=/etcd-data + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd3:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://etcd3:2379 + - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://etcd1:2380,etcd2=http://etcd2:2380,etcd3=http://etcd3:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster + networks: + - etcd-net + +networks: + etcd-net: + driver: overlay diff --git a/docker-cluster/docker-swarm/docker-swarm-ivypatroni.yml b/docker-cluster/docker-swarm/docker-swarm-ivypatroni.yml new file mode 100644 index 0000000..1b784fd --- /dev/null +++ b/docker-cluster/docker-swarm/docker-swarm-ivypatroni.yml @@ -0,0 +1,64 @@ +version: '3.7' + +services: + ivypatroni1: + image: ivorysql/docker-swarm-ha-cluster:4.6-4.0.6-ubi8 + environment: + IVORYSQL_PASSWORD: 123456 + PATRONI_SCOPE: hgdb-cluster1 + PATRONI_SERVICE_NAME: ivypatroni1 + IVORYSQL_DB_MODE: oracle + IVORYSQL_HOST_AUTH_METHOD: scram-sha-256 + ETCD_HOSTS: etcd1:2379,etcd2:2379,etcd3:2379 + IVORYSQL_HOST: ivypatroni1 + volumes: + - /home/ivorysql/data:/var/local/ivorysql/ivorysql-4/data + - /home/ivorysql/patroni:/var/local/ivorysql/ivorysql-4/patroni + networks: + - ivoryhac-etcd_etcd-net + deploy: + replicas: 1 + resources: + limits: + cpus: "0.5" + memory: 512M + restart_policy: + condition: on-failure + placement: + constraints: [node.hostname == manager-node1] + ports: + - "5432:5432" + - "1521:1521" + + ivypatroni2: + image: ivorysql/docker-swarm-ha-cluster:4.6-4.0.6-ubi8 + environment: + IVORYSQL_PASSWORD: 123456 + PATRONI_SCOPE: hgdb-cluster1 + PATRONI_SERVICE_NAME: ivypatroni2 + IVORYSQL_DB_MODE: oracle + IVORYSQL_HOST_AUTH_METHOD: scram-sha-256 + ETCD_HOSTS: etcd1:2379,etcd2:2379,etcd3:2379 + IVORYSQL_HOST: ivypatroni2 + volumes: + - /home/ivorysql/data:/var/local/ivorysql/ivorysql-4/data + - /home/ivorysql/patroni:/var/local/ivorysql/ivorysql-4/patroni + networks: + - ivoryhac-etcd_etcd-net + deploy: + replicas: 1 + resources: + limits: + cpus: "0.5" + memory: 512M + restart_policy: + condition: on-failure + placement: + constraints: [node.hostname == manager-node2] + ports: + - "5433:5432" + - "1522:1521" + +networks: + ivoryhac-etcd_etcd-net: + external: true diff --git a/k8s-cluster/ha-cluster/Dockerfile b/k8s-cluster/ha-cluster/Dockerfile new file mode 100644 index 0000000..8f17a72 --- /dev/null +++ b/k8s-cluster/ha-cluster/Dockerfile @@ -0,0 +1,111 @@ +FROM redhat/ubi8:latest as builder + +# explicitly set user/group IDs +RUN groupadd -g 1000 ivorysql; \ + useradd -u 1000 -g ivorysql -d /var/local/ivorysql -s /bin/sh ivorysql; \ + mkdir -p /var/local/ivorysql; \ + mkdir -p /usr/src/ivorysql; \ + mkdir -p /var/lib/ivorysql; \ + chown -R ivorysql:ivorysql /var/local/ivorysql; \ + chown -R ivorysql:ivorysql /usr/src/ivorysql; \ + chown -R ivorysql:ivorysql /var/lib/ivorysql + +RUN mkdir /docker-entrypoint-initdb.d +# install ivorysql 4.6 +ENV IVORY_MAJOR 4 +ENV IVORY_VERSION 4.6 + +RUN curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo; \ + sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo + +RUN mkdir -p /usr/src/ivorysql; \ + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm; \ + dnf install -y epel-release;\ + dnf install -y \ + make \ + readline-devel \ + zlib-devel \ + openssl-devel \ + flex \ + wget \ + dpkg; \ + dnf groupinstall -y "Development Tools";\ + dnf install -y \ + llvm-toolset llvm-devel lz4 lz4-devel lz4-libs clang-devel \ + krb5-devel libselinux-devel libxml2-devel cyrus-sasl-gssapi \ + libicu-devel e2fsprogs-devel selinux-policy systemd-devel \ + libxslt-devel openldap-devel openssl-devel pam-devel \ + libuuid-devel python3-devel readline-devel tcl-devel zlib-devel \ + perl perl-devel perl-ExtUtils-Embed;\ + dnf install -y --enablerepo=*ower*ools perl-IPC-Run perl-Time-HiRes perl-Test-Simple uuid-devel;\ + wget -O ivorysql.tar.gz "https://github.com/IvorySQL/IvorySQL/archive/refs/tags/IvorySQL_$IVORY_VERSION.tar.gz"; \ + tar \ + --extract \ + --file ivorysql.tar.gz \ + --directory /usr/src/ivorysql \ + --strip-components 1 \ + ; \ + rm ivorysql.tar.gz; \ + cd /usr/src/ivorysql; \ + wget https://repo.almalinux.org/almalinux/8/PowerTools/$(arch)/os/Packages/bison-devel-3.0.4-10.el8.$(arch).rpm; \ + dnf install -y bison-devel-3.0.4-10.el8.$(arch).rpm; \ + wget https://repo.almalinux.org/almalinux/8/AppStream/$(arch)/os/Packages/bison-3.0.4-10.el8.$(arch).rpm; \ + dnf install -y bison-3.0.4-10.el8.$(arch).rpm; \ + ./configure \ + --prefix=/var/local/ivorysql/ivorysql-$IVORY_MAJOR \ + --enable-cassert --enable-debug --enable-rpath --with-tcl \ + --with-python --with-gssapi --with-pam --with-ldap \ + --with-openssl --with-libedit-preferred --with-uuid=e2fs \ + --with-ossp-uuid --with-libxml --with-libxslt --with-perl \ + --with-icu \ + ; \ + make && make install; \ + rm -rf \ + /usr/src/ivorysql \ + /usr/local/share/doc \ + /usr/local/share/man + +FROM redhat/ubi8:latest + +RUN useradd -u 1000 ivorysql + +COPY --from=builder --chown=ivorysql:ivorysql /var/local/ivorysql /var/local/ivorysql/ + +ENV IVORY_MAJOR 4 +ENV IVORY_VERSION 4.6 + +RUN dnf install -y \ + lz4 lz4-devel lz4-libs krb5-devel libxslt-devel libicu-devel && dnf -y clean all + +#install patroni 4.0.6 +env PATRONI_VER 4.0.6 + +RUN dnf -y install --nodocs \ + --setopt=skip_missing_names_on_install=False \ + python3-pip \ + python3-psutil \ + python3-psycopg2 \ + && dnf -y clean all + +RUN pip3 install --upgrade python-dateutil \ + && pip3 install patroni[kubernetes]=="${PATRONI_VER}" + +ENV PGDATA /var/local/ivorysql/ivorysql-$IVORY_MAJOR/data +ENV PATRONICONF /var/local/ivorysql/ivorysql-$IVORY_MAJOR/patroni +ENV IVORYHOME /var/local/ivorysql/ivorysql-$IVORY_MAJOR +# this 1777 will be replaced by 0700 at runtime (allows semi-arbitrary "--user" values) +RUN mkdir -p "$PGDATA" && chown -R ivorysql:ivorysql "$PGDATA" && chmod 750 "$PGDATA" +RUN mkdir -p "$PATRONICONF" && chown -R ivorysql:ivorysql "$PATRONICONF" && chmod 1777 "$PATRONICONF" + +COPY docker-entrypoint.sh / +RUN chmod +x docker-entrypoint.sh + +VOLUME $PGDATA $PATRONICONF + +ENV PATH $PATH:/var/local/ivorysql/ivorysql-$IVORY_MAJOR/bin + +EXPOSE 5432 5866 1521 + +USER ivorysql + +ENTRYPOINT ["/bin/sh", "/docker-entrypoint.sh"] \ No newline at end of file diff --git a/k8s-cluster/ha-cluster/docker-entrypoint.sh b/k8s-cluster/ha-cluster/docker-entrypoint.sh new file mode 100644 index 0000000..b54e4e2 --- /dev/null +++ b/k8s-cluster/ha-cluster/docker-entrypoint.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# set patroni.yml +if [ ! -f $PATRONICONF/patroni.yml ]; then +cat > $PATRONICONF/patroni.yml <<__EOF__ +bootstrap: + dcs: + postgresql: + use_pg_rewind: true + initdb: + - encoding: 'UTF8' + - locale: 'C' + - auth: '${IVORYSQL_HOST_AUTH_METHOD}' + - dbmode: '${IVORYSQL_COMPATIBLE_MODE}' +#restapi: + #connect_address: '${PATRONI_KUBERNETES_POD_IP}:8008' +postgresql: + #connect_address: '${PATRONI_KUBERNETES_POD_IP}:5432' + database: ivorysql + listen: 0.0.0.0:5432 + port: 5432 + authentication: + replication: + username: '${PATRONI_REPLICATOR_USERNAME}' + password: '${PATRONI_REPLICATOR_PASSWORD}' + rewind: + username: '${PATRONI_REWIND_USERNAME}' + password: '${PATRONI_REWIND_PASSWORD}' + superuser: + username: ivorysql + password: '${IVORYSQL_PASSWORD}' + + parameters: + ssl: 'off' + logging_collector: on + log_directory: 'log' + ivorysql.listen_addresses: '*' + +__EOF__ +fi +# edit patroni.yml +FILE="$PATRONICONF/patroni.yml" +if ! grep -q "pg_hba:" "$FILE"; then + cat $PATRONICONF/pg_hba.txt | sed 's/^/ /' >> $PATRONICONF/patroni.yml + echo "pg_hba.txt added." +fi +if ! grep -q "tags:" "$FILE"; then + cat $PATRONICONF/tags.txt >> $PATRONICONF/patroni.yml + echo "tags.txt added." +fi +if ! grep -q "log:" "$FILE"; then + cat $PATRONICONF/log.txt >> $PATRONICONF/patroni.yml + echo "log.txt added." +fi + +echo "patroni start." +patroni $PATRONICONF/patroni.yml diff --git a/k8s-cluster/ha-cluster/helm_charts/Chart.yaml b/k8s-cluster/ha-cluster/helm_charts/Chart.yaml new file mode 100644 index 0000000..f32ebfc --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: ivorysql-patroni-hac +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/_helpers.tpl b/k8s-cluster/ha-cluster/helm_charts/templates/_helpers.tpl new file mode 100644 index 0000000..b238afa --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "ivorysql-patroni-hac.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "ivorysql-patroni-hac.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "ivorysql-patroni-hac.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "ivorysql-patroni-hac.labels" -}} +helm.sh/chart: {{ include "ivorysql-patroni-hac.chart" . }} +{{ include "ivorysql-patroni-hac.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "ivorysql-patroni-hac.selectorLabels" -}} +app.kubernetes.io/name: {{ include "ivorysql-patroni-hac.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "ivorysql-patroni-hac.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "ivorysql-patroni-hac.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/clusterrole.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/clusterrole.yaml new file mode 100644 index 0000000..cc9c596 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/clusterrole.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ .Values.clusterRoleName }} + namespace: {{ .Values.namespace }} +rules: +- apiGroups: + - "" + resources: + - endpoints + resourceNames: + - kubernetes + verbs: + - get diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/clusterrolebinding.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..2f17e05 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/clusterrolebinding.yaml @@ -0,0 +1,14 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ .Values.clusterRoleName }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ .Values.clusterRoleName }} +subjects: +- kind: ServiceAccount + name: {{ .Values.svcAccountName }} +# The namespace must be specified explicitly. +# # If deploying to the different namespace you have to change it. + namespace: {{ .Values.namespace }} diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/configmap.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/configmap.yaml new file mode 100644 index 0000000..1b9b0ed --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/configmap.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.configMapName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} +data: + pg_hba.txt: |- + pg_hba: + - local all all {{ .Values.encryption }} + - host all all 0.0.0.0/0 {{ .Values.encryption }} + - host all all ::1/128 {{ .Values.encryption }} + - local replication all {{ .Values.encryption }} + - host replication all 0.0.0.0/0 {{ .Values.encryption }} + - host replication all ::1/128 {{ .Values.encryption }} + + + tags.txt: |- + + tags: + nofailover: false + noloadbalance: false + clonefrom: false + log.txt: |- + + log: + level: ERROR + traceback_level: ERROR + dir: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/patroni/ \ No newline at end of file diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/role.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/role.yaml new file mode 100644 index 0000000..3ac1505 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/role.yaml @@ -0,0 +1,55 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ .Values.roleName }} + namespace: {{ .Values.namespace }} +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - create + - get + - list + - patch + - update + - watch + # delete and deletecollection are required only for 'patronictl remove' + - delete + - deletecollection +- apiGroups: + - "" + resources: + - endpoints + verbs: + - get + - patch + - update + # the following three privileges are necessary only when using endpoints + - create + - list + - watch + # delete and deletecollection are required only for for 'patronictl remove' + - delete + - deletecollection +- apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - patch + - update + - watch +# The following privilege is only necessary for creation of headless service +# for ivorysql-patroni-hac-config endpoint, in order to prevent cleaning it up by the +# k8s master. You can avoid giving this privilege by explicitly creating the +# service like it is done in this manifest (lines 2..10) +- apiGroups: + - "" + resources: + - services + verbs: + - create diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/rolebinding.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/rolebinding.yaml new file mode 100644 index 0000000..a4ad6d9 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Values.roleBindingName }} + namespace: {{ .Values.namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: {{ .Values.roleName }} +subjects: +- kind: ServiceAccount + name: {{ .Values.svcAccountName }} diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/secret.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/secret.yaml new file mode 100644 index 0000000..2eae2e2 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/secret.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.clusterName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} +type: Opaque +data: + ivorysql-password: SGVsbG9AMTIz + replicator-password: SGVsbG9AMTIz + rewind-password: SGVsbG9AMTIz +# 默认密码:SGVsbG9AMTIz base64 decode后为 Hello@123 \ No newline at end of file diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/service.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/service.yaml new file mode 100644 index 0000000..d8b9d13 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/service.yaml @@ -0,0 +1,85 @@ +# headless service to avoid deletion of ivorysql-patroni-hac-config endpoint +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.serviceConfigName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} +spec: + clusterIP: None + selector: + application: {{ .Values.applicationName }} + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.databaseServiceName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} +spec: + type: NodePort + selector: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + role: primary + ports: + - protocol: TCP + name: ivorysql + port: 5432 + targetPort: 5432 + - protocol: TCP + name: ivorysql-oracle + port: 1521 + targetPort: 1521 + +# nodePort: {{ .Values.port.dbPort }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.ivyHacReplicaServiceName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + role: replica +spec: + type: NodePort + selector: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + role: replica + ports: + - protocol: TCP + name: ivorysql + port: 5432 + targetPort: 5432 + - protocol: TCP + name: ivorysql-oracle + port: 1521 + targetPort: 1521 +# nodePort: {{ .Values.port.dbReplPort }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.podServiceName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + +spec: + type: ClusterIP + selector: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + clusterIP: None + internalTrafficPolicy: Cluster + sessionAffinity: None + publishNotReadyAddresses: true diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/serviceaccount.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/serviceaccount.yaml new file mode 100644 index 0000000..034113f --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ .Values.svcAccountName }} + namespace: {{ .Values.namespace }} diff --git a/k8s-cluster/ha-cluster/helm_charts/templates/statefulset.yaml b/k8s-cluster/ha-cluster/helm_charts/templates/statefulset.yaml new file mode 100644 index 0000000..ffa96a4 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/templates/statefulset.yaml @@ -0,0 +1,183 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Values.clusterName }} + namespace: {{ .Values.namespace }} + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} +spec: + #persistentVolumeClaimRetentionPolicy: + # whenDeleted: Delete + replicas: {{ .Values.replicaCount }} + serviceName: {{ .Values.podServiceName }} + selector: + matchLabels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + template: + metadata: + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + + spec: + serviceAccountName: {{ .Values.svcAccountName }} + initContainers: + - name: fix-permissions + image: busybox + command: ["sh", "-c", "chown -R 1000:1000 /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/data && chmod -R 750 /var/local/ivorysql/ivorysql-{{ .Values.majorVersion}}/data "] + volumeMounts: + - name: pgdata + mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/data + containers: + - name: {{ .Values.clusterName }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["/bin/bash"] + args: ["-c","/docker-entrypoint.sh;while true;do echo hello > /dev/null;sleep 1;done"] + + readinessProbe: + httpGet: + scheme: HTTP + path: /readiness + port: 8008 + initialDelaySeconds: 3 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + ports: + - containerPort: 8008 + protocol: TCP + - containerPort: 5432 + protocol: TCP + - containerPort: 1521 + protocol: TCP + volumeMounts: + - mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/data + name: pgdata + - mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/patroni/ + name: ivyhac-config + - mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/patroni/pg_hba.txt + name: ivyhac + subPath: pg_hba.txt + - mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/patroni/tags.txt + name: ivyhac + subPath: tags.txt + - mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/patroni/log.txt + name: ivyhac + subPath: log.txt + - name: secret + mountPath: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/secret + readOnly: true + env: + - name: PATRONI_KUBERNETES_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: PATRONI_KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: PATRONI_KUBERNETES_BYPASS_API_SERVICE + value: 'true' + - name: PATRONI_KUBERNETES_USE_ENDPOINTS + value: 'true' + - name: PATRONI_KUBERNETES_LABELS + value: '{application: ivyhac, cluster-name: ivorysql-patroni-hac}' + - name: PATRONI_KUBERNETES_PORTS + value: '[{"name": "ivorysql", "port": 5432}]' + - name: IVORYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.clusterName }} + key: ivorysql-password + - name: PATRONI_REPLICATOR_USERNAME + value: replicator + - name: PATRONI_REPLICATOR_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.clusterName }} + key: replicator-password + - name: PATRONI_REWIND_USERNAME + value: rewind_user + - name: PATRONI_REWIND_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.clusterName }} + key: rewind-password + - name: PATRONI_SCOPE + value: {{ .Values.clusterName }} + - name: PATRONI_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: PATRONI_POSTGRESQL_CONNECT_ADDRESS + value: $(PATRONI_NAME).{{ .Values.podServiceName }}:5432 + - name: PATRONI_RESTAPI_CONNECT_ADDRESS + value: $(PATRONI_NAME).{{ .Values.podServiceName }}:8008 + - name: PATRONI_POSTGRESQL_DATA_DIR + value: /var/local/ivorysql/ivorysql-{{ .Values.majorVersion }}/data + - name: PATRONI_POSTGRESQL_PGPASS + value: /tmp/.pgpass + - name: PATRONI_POSTGRESQL_LISTEN + value: '0.0.0.0:5432' + - name: PATRONI_RESTAPI_LISTEN + value: '0.0.0.0:8008' + - name: SLEEP_TIME + value: '0' + - name: IVORYSQL_HOST_AUTH_METHOD + value: {{ .Values.encryption }} + - name: IVORYSQL_COMPATIBLE_MODE + value: {{ .Values.compatibleMode }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumes: + - name: ivyhac + configMap: + name: {{ .Values.configMapName }} + items: + - key: pg_hba.txt + path: pg_hba.txt + - key: tags.txt + path: tags.txt + - key: log.txt + path: log.txt + - name: secret + secret: + secretName: {{ .Values.clusterName }} + terminationGracePeriodSeconds: 0 + volumeClaimTemplates: + - metadata: + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + name: pgdata + spec: + storageClassName: {{ .Values.pvc.storageClassName }} + accessModes: + - {{ .Values.pvc.accessModes }} + resources: + requests: + storage: {{ .Values.pvc.storageSize }} + spec: + storageClassName: {{ .Values.pvc.storageClassName }} + accessModes: + - {{ .Values.pvc.accessModes }} + resources: + requests: + storage: {{ .Values.pvc.confStorageSize }} + + - metadata: + labels: + application: {{ .Values.applicationName }} + cluster-name: {{ .Values.clusterName }} + name: ivyhac-config + spec: + storageClassName: {{ .Values.pvc.storageClassName }} + accessModes: + - {{ .Values.pvc.accessModes }} + resources: + requests: + storage: {{ .Values.pvc.confStorageSize }} diff --git a/k8s-cluster/ha-cluster/helm_charts/values.yaml b/k8s-cluster/ha-cluster/helm_charts/values.yaml new file mode 100644 index 0000000..d5140d4 --- /dev/null +++ b/k8s-cluster/ha-cluster/helm_charts/values.yaml @@ -0,0 +1,90 @@ +# Default values for ivorysql-patroni-hac. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 3 +namespace: ivorysql +clusterName: ivorysql-patroni-hac +svcAccountName: ivorysql-patroni-hac +roleName: ivorysql-patroni-hac +endpointName: ivorysql-patroni-hac +roleBindingName: ivorysql-patroni-hac +podServiceName: ivorysql-patroni-hac-pods +clusterRoleName: ivorysql-patroni-hac-ep-access +configMapName: ivyhac +applicationName: ivyhac +serviceConfigName: ivorysql-patroni-hac-config +databaseServiceName: ivorysql-patroni-hac +ivyHacReplicaServiceName: ivorysql-patroni-hac-repl +majorVersion: 4 +compatibleMode: oracle + +image: + repository: ivorysql/k8s-ha-cluster + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "4.6-4.0.6-ubi8" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" +encryption: "md5" +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + port: 80 + db: + type: NodePort +port: + dbPort: 32766 + dbReplPort: 32765 +pvc: + storageClassName: incloud-nfs + accessModes: ReadWriteOnce + storageSize: 1Gi + confStorageSize: 16Mi +ingress: + enabled: false + className: "" + annotations: {} + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + +resources: + limits: + cpu: 1 + memory: 1Gi + requests: + cpu: 200m + memory: 256Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/k8s-cluster/single/statefulset.yaml b/k8s-cluster/single/statefulset.yaml new file mode 100644 index 0000000..ce5c60f --- /dev/null +++ b/k8s-cluster/single/statefulset.yaml @@ -0,0 +1,75 @@ +apiVersion: v1 +kind: Service +metadata: + name: ivorysql-svc + namespace: default + labels: + application: ivorysql +spec: + type: NodePort + selector: + application: ivorysql + ports: + - protocol: TCP + name: ivorysql + port: 5432 + targetPort: 5432 + - protocol: TCP + name: ivorysql-oracle + port: 1521 + targetPort: 1521 +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: ivorysql + namespace: default + labels: + application: ivorysql +spec: + serviceName: ivorysql-svc + selector: + matchLabels: + application: ivorysql + template: + metadata: + labels: + application: ivorysql + spec: + containers: + - name: ivorysql + image: ivorysql/ivorysql:4.6-ubi8 + imagePullPolicy: IfNotPresent + readinessProbe: + exec: + command: + - "pg_isready" + initialDelaySeconds: 3 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + ports: + - containerPort: 5432 + protocol: TCP + - containerPort: 1521 + protocol: TCP + volumeMounts: + - mountPath: /var/local/ivorysql/ivorysql-4/data + name: pgdata + env: + - name: IVORYSQL_PASSWORD + value: 'Hello@123' + terminationGracePeriodSeconds: 0 + volumeClaimTemplates: + - metadata: + labels: + application: ivorysql + name: pgdata + spec: + storageClassName: incloud-nfs + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/versions.json b/versions.json index b8cbba6..fa3cd1d 100644 --- a/versions.json +++ b/versions.json @@ -38,7 +38,7 @@ "arches": [ "amd64" ], - "version": "4.5" + "version": "4.6" }, "redhat": "ubi8", "debian": [ @@ -50,14 +50,14 @@ "amd64", "arm64v8" ], - "version": "4.5" + "version": "4.6" }, "trixie": { "arches": [ "amd64", "arm64v8" ], - "version": "4.5" + "version": "4.6" }, "major": 4, "variants": [ @@ -65,7 +65,7 @@ "bookworm", "trixie" ], - "version": "4.5" + "version": "4.6" }, "1": { "debian": "trixie",