สคริปต์เริ่มต้นและการกำหนดค่าแบบกำหนดเองของ PostgreSQL — helm แบบสังเคราะห์
core/datastore/postgres เปิดinit_scripts (SQL หรือ shell ที่custom_config (ส่วนpostgresql.conf) ใน
Releases สอง
release-bare.yaml(aggregate-bare.yaml) — ไม่ได้ ตั้ง ค่า init_scriptsและcustom_configrelease-config.yaml(aggregate-config.yaml) — ตั้งค่า ทั้ง สอง
ร่างตัวอย่าง
คุณ
เขียน
aggrega draft --example postgres-init-configจาก
cd postgres-init-configบิลด์
aggrega build --release release-bare.yaml --auto-pullaggrega build --release release-config.yaml --auto-pullแค็ตตาล็อก.aggrega-config.yaml จึง--catalog และ --auto-pull เขียนdist/helm/helm/ ส่วน Release ที่dist/helm/helm/db/
กับผู้ช่วย AI
ผู้
ใช้เครื่องมือของ Aggrega เท่านั้น และอย่าสร้างโฟลเดอร์เอง หากโฟลเดอร์พื้นที่ทำงานยังไม่มีโฟลเดอร์ `postgres-init-config` ให้เรียกเครื่องมือ `draft` หนึ่งครั้งโดยตั้ง `example` เป็น `postgres-init-config` และไม่ระบุ `dir` เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `postgres-init-config` ใหม่ จากนั้นเรียกเครื่องมือ `build` หนึ่งครั้งต่อ Release ตามลำดับนี้ — `release-bare.yaml` และ `release-config.yaml` — โดยทุกครั้งตั้ง `workspace_root` เป็น `postgres-init-config` ตั้ง `release` เป็นไฟล์นั้น ตั้ง `auto_pull` เป็น true และตั้ง `write` เป็น true บอกฉันว่าการบิลด์แต่ละครั้งเขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใน `postgres-init-config/dist/`แบบเปล่า — ฐานอ้างอิงแบบเพิ่มเติม
aggregate-bare.yaml ไม่configmap ไม่มี
dist/helm/helm/db-statefulset.yamldist/helm/helm/db-default-service.yamldist/helm/helm/db-headless-service.yamlเนื่องจาก
ที่กำหนดค่าไว้ — เมานต์สคริปต์และการกำหนดค่า
aggregate-config.yaml ตั้ง
values: init_scripts: 01-schema.sql: | CREATE TABLE app_users ( ... ); 02-seed.sql: | INSERT INTO app_users (email) VALUES ('founder@example.com'); custom_config: | max_connections = 200 shared_buffers = 256MBตอน
dist/helm/helm/db/initdb-configmap.yamldist/helm/helm/db/config-configmap.yamlทั้งdb/ ซึ่งartifacts: ของ
ทั้ง
init_scripts→ ConfigMapdb-initdbซึ่งมี คีย์ ข้อมูล หนึ่ง คีย์ ต่อ สคริปต์ ( 01-schema.sql,02-seed.sql) วอลุ่มconfigmapเมานต์ ConfigMap นั้นที่ /docker-entrypoint-initdb.dซึ่ง PostgreSQL รันไฟล์ เหล่า นั้น หนึ่ง ครั้ง ตอน เริ่ม ต้น ครั้ง แรก ตาม ลำดับ ตัว อักษร ของ คีย์ custom_config→ ConfigMapdb-configซึ่งมี คีย์ ข้อมูล หนึ่ง คีย์ คือ postgresql.confอีกวอลุ่ม configmapหนึ่งเมานต์ ConfigMap นั้น ที่ /etc/postgresqlและargs:ของคอนเทนเนอร์ ชี้ เซิร์ฟเวอร์ ไป ที่ ไฟล์ นั้น: postgres -c config_file=/etc/postgresql/postgresql.confการตั้ง ค่าที่ ส่วน ย่อย ละไว้ จะ คง ค่า เริ่ม ต้น ที่ มี มา ใน ตัว
# db-statefulset.yaml (container)containers: - name: main image: postgres:16 args: - postgres - -c - config_file=/etc/postgresql/postgresql.conf [… omitted: the container's port, environment and resources] volumeMounts: - name: data mountPath: /var/lib/postgresql/data - name: initdb mountPath: /docker-entrypoint-initdb.d - name: pgconf mountPath: /etc/postgresql [… omitted: the liveness and readiness probes]volumes: - name: initdb configMap: name: db-initdb - name: pgconf configMap: name: db-configอาร์กิวเมนต์args: ไม่ใช่ command: และargs: ส่งcommand: แทนที่ entrypoint นั้น entrypoint นั้นPOSTGRES_* และ/docker-entrypoint-initdb.d การpostgresql.conf ที่
การcustom_config
Compose
Recipe ของ Compose สำหรับ core/datastore/postgres อ่าน Component เดียวกัน และconfigs: ระดับ
init_scripts→ หนึ่งรายการ config ต่อ คีย์ โดย แต่ละ รายการ เมานต์ ที่ ชื่อ ไฟล์ ของ ตน ใต้ /docker-entrypoint-initdb.dอิมเมจรัน ไฟล์ ที่ พบ ที่ นั่น หนึ่ง ครั้ง ตาม ลำดับ ชื่อ ไฟล์ และ เฉพาะ เมื่อ ไดเรกทอรี ข้อมูล ว่าง เท่านั้น — ฐาน ข้อมูล ที่ มี ข้อมูล อยู่ แล้ว จะ ไม่ ถูก แตะ ต้อง custom_config→ หนึ่งรายการ config เมานต์ เป็น ไฟล์ เดียว คือ /etc/postgresql/postgresql.confโดยใช้ อาร์กิวเมนต์ postgres -c config_file=…ชุดเดียวกัน ที่ ชี้ เซิร์ฟเวอร์ ไป ที่ ไฟล์ นั้น การ ตั้ง ค่าที่ ส่วน ย่อย ละไว้ จะ คง ค่า เริ่ม ต้น ที่ มี มา ใน ตัว
แต่ละ
มีcustom_config สำหรับlisten_addresses ซึ่ง
Manifest ในcore/datastore/postgres ไปcompose/postgres แทน ค่า