Reorganized for new stable/waypoint versioning design.
This commit is contained in:
19
postgres/versions/1/README.md
Normal file
19
postgres/versions/1/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# PostgreSQL
|
||||
|
||||
PostgreSQL is a powerful, open-source relational database system. This deploys a shared PostgreSQL instance used by many Wild Cloud apps.
|
||||
|
||||
## Dependencies
|
||||
|
||||
None. PostgreSQL is a standalone infrastructure service.
|
||||
|
||||
## Configuration
|
||||
|
||||
Key settings configured through your instance's `config.yaml`:
|
||||
|
||||
- **storage** - Persistent volume size (default: `20Gi`)
|
||||
- **port** - Service port (default: `5432`)
|
||||
- **timezone** - Server timezone (default: `UTC`)
|
||||
|
||||
## Usage
|
||||
|
||||
Apps that depend on PostgreSQL (such as Immich, Gitea, Discourse, Mastodon, and others) will connect to it at `postgres.postgres.svc.cluster.local:5432`. Each app creates its own database and user via a db-init job during deployment. Root credentials are managed through the secrets system.
|
||||
56
postgres/versions/1/deployment.yaml
Normal file
56
postgres/versions/1/deployment.yaml
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: postgres-deployment
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: "pgvector/pgvector:pg15"
|
||||
args:
|
||||
[
|
||||
"-c",
|
||||
"tcp_keepalives_idle=600",
|
||||
"-c",
|
||||
"tcp_keepalives_interval=30",
|
||||
"-c",
|
||||
"tcp_keepalives_count=3",
|
||||
"-c",
|
||||
"statement_timeout=300000",
|
||||
"-c",
|
||||
"idle_in_transaction_session_timeout=600000",
|
||||
]
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: PGDATA
|
||||
value: /var/lib/postgresql/data/pgdata
|
||||
- name: TZ
|
||||
value: "UTC"
|
||||
- name: POSTGRES_DB
|
||||
value: "{{ .database }}"
|
||||
- name: POSTGRES_USER
|
||||
value: "{{ .user }}"
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secrets
|
||||
key: password
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- name: postgres-data
|
||||
persistentVolumeClaim:
|
||||
claimName: postgres-pvc
|
||||
11
postgres/versions/1/doctor/kustomization.yaml
Normal file
11
postgres/versions/1/doctor/kustomization.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: postgres
|
||||
resources:
|
||||
- test-job.yaml
|
||||
labels:
|
||||
- includeSelectors: true
|
||||
pairs:
|
||||
app: postgres-doctor
|
||||
managedBy: kustomize
|
||||
partOf: wild-cloud
|
||||
77
postgres/versions/1/doctor/test-job.yaml
Normal file
77
postgres/versions/1/doctor/test-job.yaml
Normal file
@@ -0,0 +1,77 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: postgres-doctor
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres-doctor
|
||||
image: pgvector/pgvector:pg15
|
||||
command: ["/bin/bash", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "=== Postgres Doctor - Starting Tests ==="
|
||||
echo "Timestamp: $(date)"
|
||||
echo "Password from env: [${POSTGRES_PASSWORD}]"
|
||||
echo "Job pod IP: $(hostname -i)"
|
||||
echo "Postgres service resolves to: $(getent hosts postgres.postgres.svc.cluster.local | awk '{print $1}')"
|
||||
echo
|
||||
|
||||
# Test 1: Local connection (trust auth)
|
||||
echo "TEST 1: Local connection with trust authentication"
|
||||
if psql -h localhost -U postgres -c "SELECT 'Local connection: SUCCESS' as test_result;" 2>&1; then
|
||||
echo "✓ Local connection: SUCCESS"
|
||||
else
|
||||
echo "✗ Local connection: FAILED"
|
||||
fi
|
||||
echo
|
||||
|
||||
# Test 2: Remote connection with password
|
||||
echo "TEST 2: Remote connection with password authentication"
|
||||
if PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "SELECT 'Remote connection: SUCCESS' as test_result;" 2>&1; then
|
||||
echo "✓ Remote connection: SUCCESS"
|
||||
else
|
||||
echo "✗ Remote connection: FAILED"
|
||||
fi
|
||||
echo
|
||||
|
||||
# Test 3: Check postgres version and extensions
|
||||
echo "TEST 3: Check postgres version and available extensions"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "SELECT version();"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "SELECT name FROM pg_available_extensions WHERE name IN ('vector', 'cube', 'earthdistance') ORDER BY name;"
|
||||
echo
|
||||
|
||||
# Test 4: List all databases
|
||||
echo "TEST 4: List all databases"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "\l"
|
||||
echo
|
||||
|
||||
# Test 5: List all users
|
||||
echo "TEST 5: List all users and their attributes"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "\du"
|
||||
echo
|
||||
|
||||
# Test 6: Check authentication configuration
|
||||
echo "TEST 6: Check pg_hba.conf authentication rules"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "SELECT type, database, user_name, address, auth_method FROM pg_hba_file_rules WHERE auth_method IS NOT NULL ORDER BY line_number;"
|
||||
echo
|
||||
|
||||
# Test 7: Check active connections
|
||||
echo "TEST 7: Check active database connections"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "SELECT datname, usename, client_addr, state, query_start FROM pg_stat_activity WHERE state IS NOT NULL ORDER BY query_start DESC;"
|
||||
echo
|
||||
|
||||
# Test 9: Check for long-running queries
|
||||
echo "TEST 9: Check for long-running queries (> 30 seconds)"
|
||||
PGPASSWORD="${POSTGRES_PASSWORD}" psql -h postgres.postgres.svc.cluster.local -U postgres -c "SELECT pid, now() - pg_stat_activity.query_start AS duration, query FROM pg_stat_activity WHERE query_start IS NOT NULL AND now() - pg_stat_activity.query_start > interval '30 seconds' ORDER BY duration DESC;"
|
||||
echo
|
||||
|
||||
echo "=== Postgres Doctor - Tests Complete ==="
|
||||
env:
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secrets
|
||||
key: apps.postgres.password
|
||||
restartPolicy: Never
|
||||
14
postgres/versions/1/kustomization.yaml
Normal file
14
postgres/versions/1/kustomization.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: postgres
|
||||
labels:
|
||||
- includeSelectors: true
|
||||
pairs:
|
||||
app: postgres
|
||||
managedBy: kustomize
|
||||
partOf: wild-cloud
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- namespace.yaml
|
||||
- service.yaml
|
||||
- pvc.yaml
|
||||
10
postgres/versions/1/manifest.yaml
Normal file
10
postgres/versions/1/manifest.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
version: 1.0.0-1
|
||||
defaultConfig:
|
||||
namespace: postgres
|
||||
host: postgres.postgres.svc.cluster.local
|
||||
port: 5432
|
||||
database: postgres
|
||||
user: postgres
|
||||
storage: 10Gi
|
||||
defaultSecrets:
|
||||
- key: password
|
||||
4
postgres/versions/1/namespace.yaml
Normal file
4
postgres/versions/1/namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: {{ .namespace }}
|
||||
12
postgres/versions/1/pvc.yaml
Normal file
12
postgres/versions/1/pvc.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: postgres-pvc
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: longhorn
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .storage }}
|
||||
10
postgres/versions/1/service.yaml
Normal file
10
postgres/versions/1/service.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres
|
||||
spec:
|
||||
ports:
|
||||
- port: 5432
|
||||
selector:
|
||||
app: postgres
|
||||
Reference in New Issue
Block a user