We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/IBM/mcp-context-forge'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
deployment-postgres.yaml•8.99 kB
{{/* -------------------------------------------------------------------
DEPLOYMENT - Postgres
-------------------------------------------------------------------
- Pods are labelled <release>-mcp-stack-postgres so the Service
selector (also templated) matches correctly.
- Adds exec-based readiness & liveness probes (pg_isready).
- Adds resource requests / limits pulled from values.yaml.
------------------------------------------------------------------- */}}
{{- $targetVersion := .Values.postgres.upgrade.targetVersion | toString -}}
{{- $postgresImage := "" -}}
{{- if and .Values.postgres.upgrade.enabled (eq $targetVersion "18") -}}
{{- $postgresImage = printf "%s:18" .Values.postgres.image.repository -}}
{{- else -}}
{{- $postgresImage = printf "%s:%s" .Values.postgres.image.repository .Values.postgres.image.tag -}}
{{- end -}}
{{- if and .Values.postgres.enabled (not .Values.postgres.external.enabled) }}
apiVersion: apps/v1
kind: Deployment
metadata:
# <release>-mcp-stack-postgres
name: {{ include "mcp-stack.fullname" . }}-postgres
labels:
{{- include "mcp-stack.labels" . | nindent 4 }}
app: {{ include "mcp-stack.fullname" . }}-postgres
spec:
replicas: 1 # one DB pod; use StatefulSet if you ever scale
selector:
matchLabels:
app: {{ include "mcp-stack.fullname" . }}-postgres
{{- if and .Values.postgres.upgrade.enabled (eq $targetVersion "18") }}
# For PostgreSQL 18 upgrade, we need to perform a rolling update
strategy:
type: Recreate # Recreate strategy to ensure clean transition during upgrade
{{- end }}
template:
metadata:
labels:
app: {{ include "mcp-stack.fullname" . }}-postgres
spec:
# Image pull secrets
{{- if .Values.global.imagePullSecrets }}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "mcp-stack.serviceAccountName" . }}
initContainers:
{{- if and .Values.postgres.upgrade.enabled (eq $targetVersion "18") .Values.postgres.upgrade.backupCompleted }}
# Init container to upgrade PostgreSQL data from version 17 to 18
- name: postgres-restore
image: "{{ .Values.postgres.image.repository }}:17" # Use PostgreSQL 17 image to access the old data
command:
- /bin/bash
- -c
- |
#!/bin/bash
set -e
PGDATA="/var/lib/postgresql/data/pgdata"
INITDB_DONE_FILE="$PGDATA/.initdb_done"
echo "Checking PostgreSQL data directory..."
if [ -d "$PGDATA" ]; then
ls -la "$PGDATA" | head -20
else
echo "Data directory does not exist yet"
exit 0
fi
# Check if this is a data upgrade scenario (PG_VERSION file exists with version 17)
if [ -f "$PGDATA/PG_VERSION" ]; then
CURRENT_VERSION=$(cat "$PGDATA/PG_VERSION" 2>/dev/null || echo "")
echo "Found PG_VERSION file with version: $CURRENT_VERSION"
if [ "$CURRENT_VERSION" = "17" ]; then
echo "PostgreSQL 17 data detected - this should be removed to allow PostgreSQL 18 to initialize fresh and reload from dump"
# Install MinIO client and jq
apt-get update && apt-get install -y wget jq
wget https://dl.min.io/client/mc/release/linux-amd64/mc -O /tmp/mc
chmod +x /tmp/mc
# Configure MinIO client
/tmp/mc alias set minio http://{{ include "mcp-stack.fullname" . }}-minio:{{ .Values.minio.service.apiPort }} $MINIO_ROOT_USER $MINIO_ROOT_PASSWORD
# List and find the latest backup file
LATEST_BACKUP=$(/tmp/mc ls --json minio/postgres-backups/ | jq -r '"\(.time) \(.key)"' | sort -r | head -n1 | cut -d' ' -f2-)
if [ -z "$LATEST_BACKUP" ]; then
echo "No backup file found in MinIO - cannot perform upgrade"
exit 0 # Allow to continue but no dump will be loaded
fi
echo "Found backup file: $LATEST_BACKUP"
# Download the backup file to the initdb directory
/tmp/mc cp minio/postgres-backups/$LATEST_BACKUP /docker-entrypoint-initdb.d/
# Remove the old data directory to allow PostgreSQL 18 to initialize fresh
echo "Removing old PostgreSQL 17 data to allow fresh initialization with PG18..."
# Move current data to backup directory first
mv "$PGDATA" "/tmp/postgres-data-old"
# Create new data directory
mkdir -p "$PGDATA"
# Set proper ownership
chown -R postgres:postgres /var/lib/postgresql/data
chown -R postgres:postgres /docker-entrypoint-initdb.d
echo "Old data backed up and directory prepared for PostgreSQL 18 initialization"
else
echo "Data version ($CURRENT_VERSION) is not 17, skipping removal"
# Still touch the initdb_done file to indicate this is not a fresh install
touch "$PGDATA/.initdb_done"
fi
else
echo "No PG_VERSION file found - this is likely a fresh install"
# Create the directory if doesn't exist
mkdir -p "$PGDATA"
touch "$PGDATA/.initdb_done"
fi
echo "Init container completed successfully"
env:
- name: MINIO_ROOT_USER
valueFrom:
secretKeyRef:
name: {{ if .Values.minio.existingSecret }}{{ .Values.minio.existingSecret }}{{ else }}{{ include "mcp-stack.fullname" . }}-minio{{ end }}
key: MINIO_ROOT_USER
- name: MINIO_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ if .Values.minio.existingSecret }}{{ .Values.minio.existingSecret }}{{ else }}{{ include "mcp-stack.fullname" . }}-minio{{ end }}
key: MINIO_ROOT_PASSWORD
- name: PGUSER
valueFrom:
secretKeyRef:
name: {{ include "mcp-stack.postgresSecretName" . | trim }}
key: POSTGRES_USER
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mcp-stack.postgresSecretName" . | trim }}
key: POSTGRES_PASSWORD
volumeMounts:
- name: postgredb
mountPath: /var/lib/postgresql/data
- name: postgres-initdb
mountPath: /docker-entrypoint-initdb.d
securityContext:
runAsUser: 0 # Run as root to have permission to move files
{{- end }}
containers:
- name: postgres
image: "{{ $postgresImage }}"
imagePullPolicy: "{{ .Values.postgres.image.pullPolicy }}"
# Expose Postgres TCP port inside the pod
ports:
- containerPort: {{ .Values.postgres.service.port }}
# ─── Readiness probe ───
{{- with .Values.postgres.probes.readiness }}
readinessProbe:
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
{{- end }}
# ─── Liveness probe ───
{{- with .Values.postgres.probes.liveness }}
livenessProbe:
{{- include "helpers.renderProbe" (dict "probe" . "root" $) | nindent 12 }}
{{- end }}
# ConfigMap holds non-secret tuning (postgresql.conf, etc.)
# Secret stores POSTGRES_USER / POSTGRES_PASSWORD.
envFrom:
- configMapRef:
name: postgres-config
- secretRef:
name: {{ include "mcp-stack.postgresSecretName" . | trim | quote }}
# Set PGDATA to a subdirectory to avoid mount point issues
env:
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
# Mount PVC for data durability
volumeMounts:
- name: postgredb
mountPath: /var/lib/postgresql/data
- name: postgres-initdb
mountPath: /docker-entrypoint-initdb.d
# ─── Resource limits & requests ───
resources:
{{- toYaml .Values.postgres.resources | nindent 12 }}
volumes:
- name: postgredb
{{- if .Values.postgres.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "mcp-stack.fullname" . }}-postgres-pvc
{{- else }}
emptyDir: {}
{{- end }}
- name: postgres-initdb
emptyDir: {}
{{- end }}