Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Render Helm chart

on:
push:
branches: [main]
pull_request:

jobs:
render:
Expand All @@ -18,8 +20,43 @@ jobs:
with:
version: latest

- name: Lint chart
run: helm lint .
- name: Run chart tests
run: ./test/test.sh

- name: Render chart
run: helm template control .
validate-configs:
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
permissions:
contents: read
env:
CONTROL2_IMAGE: ghcr.io/pgdogdev/pgdog-enterprise/control:main-ent

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Helm
uses: azure/setup-helm@v4
with:
version: latest

- name: Install yq
uses: mikefarah/yq@master

- name: Pull control2 image
run: docker pull "$CONTROL2_IMAGE"

- name: Validate generated control configs
run: |
set -eo pipefail
for values_file in test/values-*.yaml; do
name=$(basename "$values_file" .yaml | sed 's/values-//')
echo "==> Validating control config for $name..."
rm -f /tmp/control.toml
./test/generate-config.sh "$values_file" /tmp/control.toml
docker run --rm \
-v /tmp/control.toml:/tmp/control.toml:ro \
"$CONTROL2_IMAGE" \
/usr/local/bin/control2 configcheck --config /tmp/control.toml
done
echo "==> All control configs valid!"
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: pgdog-control
description: PgDog Control
type: application
version: 0.2.11
version: 0.2.12
appVersion: "1a6d7fd0"
13 changes: 12 additions & 1 deletion templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,25 @@ data:
{{- with .evict_after_secs }}
evict_after_secs = {{ . }}
{{- end }}
{{- with .process_notify_interval_secs }}
process_notify_interval_secs = {{ . }}
{{- end }}
{{- with .metrics_retention_secs }}
metrics_retention_secs = {{ . }}
{{- end }}
{{- if hasKey . "query_history_limit" }}
query_history_limit = {{ .query_history_limit }}
{{- end }}
{{- if hasKey . "autoreload" }}
autoreload = {{ .autoreload }}
autoreload = {{ .autoreload | quote }}
{{- end }}
{{- end }}

{{- with $config.autoscaling }}

[autoscaling]
{{- if hasKey . "pool_size" }}
pool_size = {{ .pool_size }}
{{- end }}
{{- end }}

Expand Down
27 changes: 27 additions & 0 deletions test/generate-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -eo pipefail

TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CHART_DIR="$TEST_DIR/.."

if [ -z "$1" ]; then
echo "Usage: $0 <values-file> [output-file]"
echo "Example: $0 values-full.yaml control.toml"
exit 1
fi

VALUES_FILE="$1"

output=$(helm template test-release "$CHART_DIR" -f "$VALUES_FILE" \
| yq -r 'select(.kind == "ConfigMap" and has("data") and .data["control.toml"]) | .data["control.toml"]')

if [ -z "$output" ]; then
echo "FAIL: control.toml not found in rendered ConfigMap"
exit 1
fi

if [ -z "$2" ]; then
echo "$output"
else
echo "$output" > "$2"
fi
18 changes: 18 additions & 0 deletions test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -eo pipefail

TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CHART_DIR="$TEST_DIR/.."

echo "==> Linting Helm chart..."
helm lint "$CHART_DIR"

for values_file in "$TEST_DIR"/values-*.yaml; do
name=$(basename "$values_file" .yaml | sed 's/values-//')
echo ""
echo "==> Rendering $name..."
helm template test-release "$CHART_DIR" -f "$values_file" > /dev/null
done

echo ""
echo "==> All chart tests passed!"
6 changes: 6 additions & 0 deletions test/values-autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
control:
config:
store:
process_notify_interval_secs: 30
autoscaling:
pool_size: true
1 change: 1 addition & 0 deletions test/values-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
72 changes: 72 additions & 0 deletions test/values-full.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
control:
aws:
roleArn: arn:aws:iam::123456789012:role/pgdog-control
region: us-west-2
rbac:
writeNamespaces:
- pgdog
- pgdog-staging
config:
api:
pgdog:
ip_allowlist:
enabled: true
allowed_cidrs:
- 10.0.0.0/8
- 192.168.0.0/16
rds:
refresh_interval_secs: 45
autodiscovery: true
kube:
refresh_interval_secs: 10
dns:
refresh_interval_secs: 20
cloudwatch:
refresh_interval_secs: 60
lookback_secs: 1800
period_secs: 60
store:
tick_secs: 1
stale_after_secs: 5
evict_after_secs: 60
process_notify_interval_secs: 30
metrics_retention_secs: 600
query_history_limit: 500
autoreload: "immediately"
autoscaling:
pool_size: true
helm:
chart: pgdog
repo: pgdogdev
repo_url: https://helm.pgdog.dev
auth:
cookie_secret: test-cookie-secret
redirect_base_url: https://control.example.com
cookie_secure: true
session_max_age_days: 14
state_max_age_min: 5
github:
client_id: github-client
client_secret: github-secret
allowed_orgs:
- pgdogdev
google:
client_id: google-client
client_secret: google-secret
allowed_domains:
- example.com
alerts:
evaluation_window_secs: 120
thresholds:
clients_waiting: 10
cpu: 90.0
memory: 2048
server_connections: 100
incident_io:
api_key: incident-token
slack:
bot_token: slack-token
channel: "#alerts"
redis:
url: redis://redis.example.com:6379
save_interval_secs: 30
3 changes: 3 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ control:
# tick_secs: 1
# stale_after_secs: 5
# evict_after_secs: 60
# process_notify_interval_secs: 60
# metrics_retention_secs: 300
# query_history_limit: 1000
# autoreload: off
autoscaling: {}
# pool_size: false
helm: {}
# chart: pgdog
# repo: pgdogdev
Expand Down
Loading