Skip to content

Commit 1428eb5

Browse files
zhangeamonzhangeamon
authored andcommitted
WIP
1 parent f04b3cf commit 1428eb5

5 files changed

Lines changed: 87 additions & 17 deletions

File tree

Dockerfile

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,36 @@ ARG PYTHON_VERSION="3.13" \
1010

1111
ENV HOME=/data \
1212
PG_MAJOR=18 \
13-
PG_MINOR=1
13+
PG_MINOR=1 \
14+
WAL_G_VERSIONR="3.0.5" \
15+
RCLONE_VERSION="1.71.1"
16+
1417
ENV PGDATA $HOME/$PG_MAJOR
1518

1619
RUN install-packages vim gcc \
1720
&& install-stack python $PYTHON_VERSION \
1821
&& install-stack postgresql $PG_MAJOR.$PG_MINOR \
22+
&& install-stack wal-g $WAL_G_VERSIONR \
23+
&& install-stack rclone $RCLONE_VERSION \
1924
&& install-stack postgres_exporter $POSTGRES_EXPORTER_VERSION \
2025
&& . init-stack \
2126
&& set -eux; pip3 install --disable-pip-version-check --no-cache-dir psycopg[binary] patroni[kubernetes] 2>/dev/null; set +eux \
2227
&& apt-get purge -y --auto-remove gcc \
2328
&& apt-get autoremove -y \
2429
&& apt-get clean -y \
2530
&& rm -rf \
26-
/usr/share/doc \
27-
/usr/share/man \
28-
/usr/share/info \
29-
/usr/share/locale \
30-
/var/lib/apt/lists/* \
31-
/var/log/* \
32-
/var/cache/debconf/* \
33-
/etc/systemd \
34-
/lib/lsb \
35-
/lib/udev \
36-
/usr/lib/`echo $(uname -m)`-linux-gnu/gconv/IBM* \
37-
/usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \
31+
/usr/share/doc \
32+
/usr/share/man \
33+
/usr/share/info \
34+
/usr/share/locale \
35+
/var/lib/apt/lists/* \
36+
/var/log/* \
37+
/var/cache/debconf/* \
38+
/etc/systemd \
39+
/lib/lsb \
40+
/lib/udev \
41+
/usr/lib/`echo $(uname -m)`-linux-gnu/gconv/IBM* \
42+
/usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \
3843
&& mkdir -p /usr/share/man/man{1..8} \
3944
&& mkdir -p $PGDATA \
4045
&& groupadd postgres && useradd -g postgres postgres \

charts/database/templates/_helper.tpl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
11
{{- define "database.envs" }}
22
env:
3+
- name: USE_WALG
4+
value: "true"
5+
{{- if (.Values.storageEndpoint) }}
6+
- name: "DRYCC_STORAGE_BUCKET"
7+
valueFrom:
8+
secretKeyRef:
9+
name: database-creds
10+
key: storage-bucket
11+
- name: "DRYCC_STORAGE_ENDPOINT"
12+
valueFrom:
13+
secretKeyRef:
14+
name: database-creds
15+
key: storage-endpoint
16+
- name: "DRYCC_STORAGE_ACCESSKEY"
17+
valueFrom:
18+
secretKeyRef:
19+
name: database-creds
20+
key: storage-accesskey
21+
- name: "DRYCC_STORAGE_SECRETKEY"
22+
valueFrom:
23+
secretKeyRef:
24+
name: database-creds
25+
key: storage-secretkey
26+
- name: "DRYCC_STORAGE_PATH_STYLE"
27+
valueFrom:
28+
secretKeyRef:
29+
name: database-creds
30+
key: storage-path-style
31+
{{- else if .Values.storage.enabled }}
32+
- name: "DRYCC_STORAGE_BUCKET"
33+
value: "database"
34+
- name: "DRYCC_STORAGE_ENDPOINT"
35+
value: http://drycc-storage:9000
36+
- name: "DRYCC_STORAGE_ACCESSKEY"
37+
valueFrom:
38+
secretKeyRef:
39+
name: storage-creds
40+
key: accesskey
41+
- name: "DRYCC_STORAGE_SECRETKEY"
42+
valueFrom:
43+
secretKeyRef:
44+
name: storage-creds
45+
key: secretkey
46+
- name: "DRYCC_STORAGE_PATH_STYLE"
47+
value: "true"
48+
{{- end }}
349
{{- if eq .Values.debug "true" }}
450
- name: PATRONI_LOG_LEVEL
551
value: DEBUG

charts/database/templates/database-secret-creds.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ data:
1212
replicator-password: {{ include "common.secrets.lookup" (dict "secret" "database-creds" "key" "replicator-password" "defaultValue" (.Values.replicatorPassword | default (randAlphaNum 32) | lower) "context" $) }}
1313
user: {{ include "common.secrets.lookup" (dict "secret" "database-creds" "key" "user" "defaultValue" (.Values.user | default (randAlpha 32) | lower) "context" $) }}
1414
password: {{ include "common.secrets.lookup" (dict "secret" "database-creds" "key" "password" "defaultValue" (.Values.password | default (randAlphaNum 32)) "context" $) }}
15+
{{- if (.Values.storageEndpoint) }}
16+
storage-bucket: {{ .Values.storageBucket | b64enc }}
17+
storage-endpoint: {{ .Values.storageEndpoint | b64enc }}
18+
storage-accesskey: {{ .Values.storageAccesskey | b64enc }}
19+
storage-secretkey: {{ .Values.storageSecretkey | b64enc }}
20+
storage-path-style: {{ .Values.storagePathStyle | b64enc }}
21+
{{- end }}

charts/database/values.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ diagnosticMode:
2020
args:
2121
- infinity
2222

23-
resources: {}
23+
resources:
24+
{}
2425
# limits:
2526
# cpu: 200m
2627
# memory: 50Mi
@@ -32,7 +33,7 @@ nodeAffinityPreset:
3233
key: "drycc.cc/node"
3334
type: "soft"
3435
values:
35-
- "true"
36+
- "true"
3637

3738
podAffinityPreset:
3839
type: ""
@@ -45,7 +46,16 @@ podAntiAffinityPreset:
4546
app: "drycc-database"
4647

4748
debug: "false"
49+
# Patroni pg_ctl timeout
4850
timeout: "1200"
51+
52+
# The following parameters will no longer use the built-in storage component.
53+
storageBucket: "database"
54+
storageEndpoint: ""
55+
storageAccesskey: ""
56+
storageSecretkey: ""
57+
storagePathStyle: "true"
58+
4959
# Service
5060
service:
5161
# Provide any additional service annotations
@@ -66,7 +76,7 @@ persistence:
6676
storageClass: ""
6777
# The username and password to be used by the on-cluster database.
6878
# If left empty they will be generated
69-
# The user name should be set to lowercase letters
79+
# The user name should be set to lowercase letters
7080
superuser: "postgres"
7181
superuserPassword: ""
7282
replicator: "standby"

rootfs/entrypoint.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
/bin/create_bucket
4+
35
if [[ $UID -ge 10000 ]]; then
46
GID=$(id -g)
57
sed -e "s/^postgres:x:[^:]*:[^:]*:/postgres:x:$UID:$GID:/" /etc/passwd > /tmp/passwd
@@ -46,7 +48,7 @@ postgresql:
4648
track_commit_timestamp: "off"
4749
archive_mode: "on"
4850
archive_timeout: 300s
49-
archive_command: "/bin/true"
51+
archive_command: "/usr/share/scripts/wal-g/wal_push.sh %p"
5052
log_min_duration_statement: 1000
5153
log_lock_waits: on
5254
log_statement: 'ddl'

0 commit comments

Comments
 (0)