PostgreSQL Kubernetes Standard Skill
This skill generates a complete set of Kubernetes manifests for a PostgreSQL deployment, following strict naming and network requirements.
Specifications
- Name Requirement: StatefulSet MUST be named
postgre. - Network Requirement:
hostNetwork: trueMUST be set in the Pod spec. - Service Requirement: A headless service named
postgre-headlessMUST be created. - Secret Requirement: A secret named
postgre-secretMUST be created with a randomPOSTGRES_PASSWORD. - Storage Requirement: PV/PVC MUST be managed via
volumeClaimTemplatesin the StatefulSet.- If a
StorageClassexists in the cluster, it will be used. - If NO
StorageClassis available, a manualPersistentVolume(PV) of the requested size MUST be included as a fallback for the generated PVC (postgre-data-postgre-0).
- If a
- Data Directory (Mount Path):
- For PostgreSQL 17 and below:
/var/lib/postgresql/data - For PostgreSQL 18+ and
latest:/var/lib/postgresql - The generator handles this logic automatically based on the image version.
- For PostgreSQL 17 and below:
- Namespace: Default to
postgre.
Implementation Guide
When triggered:
- Determine if the user has custom storage size or image preferences (Default: 100Gi, Image: postgres:16).
- Execute the generator:
python ~/.agents/skills/postgre-skill/scripts/generate.py [storage] [image] [namespace]. - Provide the output YAML to the user.
Example Request
User: "幫我產生一個標準的 postgre 部署設定" Result: Displays the YAML with postgre Secret, Service, and StatefulSet with hostNetwork and version-aware storage configuration.