No description
  • Shell 52.4%
  • Python 41.3%
  • Just 6.3%
Find a file
2026-11-24 13:13:49 +01:00
loadtest-app Add demo app, manifests and deploy script 2026-11-24 13:13:49 +01:00
pgbench Initial commit 2026-11-24 15:50:19 +01:00
demo.sh add demo.sh 2026-11-24 14:53:32 +00:00
justfile Initial commit 2026-11-24 15:50:19 +01:00
README.md Add demo app, manifests and deploy script 2026-11-24 13:13:49 +01:00
test.just Initial commit 2026-11-24 15:50:19 +01:00

Databases

Deploy kube-prometheus-stack

# Create secret with Grafana credentials
kubectl create namespace monitoring --dry-run=client -o yaml | kubectl apply -f -
kubectl -n monitoring create secret generic grafana-admin \
  --from-literal=admin-user="$GRAFANA_USERNAME" \
  --from-literal=admin-password="$GRAFANA_PASSWORD" \
  --dry-run=client -o yaml | kubectl apply -f -
# Deploy `prometheus-operator`, Prometheus and Grafana
helm upgrade --install kube-prometheus-stack \
  oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack \
  --version 93.9.0 \
  --namespace monitoring --create-namespace \
  --values - <<'EOF'
alertmanager:
  enabled: false
defaultRules:
  create: false
nodeExporter:
  enabled: false
kubeStateMetrics:
  enabled: false
prometheus:
  prometheusSpec:
    podMonitorSelectorNilUsesHelmValues: false
    serviceMonitorSelectorNilUsesHelmValues: false
    ruleSelectorNilUsesHelmValues: false
grafana:
  defaultDashboardsEnabled: false
  grafana.ini:
    server:
      root_url: https://course-7.network.garden
  route:
    main:
      enabled: true
      hostnames:
        - course-7.network.garden
      parentRefs:
        - name: traefik-gateway
          namespace: traefik
          sectionName: websecure
  admin:
    existingSecret: grafana-admin
    userKey: admin-user
    passwordKey: admin-password
EOF
# Add the cloudnative-pg Dashboard to Grafana
helm upgrade --install cnpg-dashboard-cluster \
  oci://ghcr.io/cloudnative-pg/grafana-dashboards/cluster \
  --version 0.0.5 \
  --namespace monitoring --create-namespace 

Install cloudnative-pg

helm upgrade --install cloudnative-pg oci://ghcr.io/cloudnative-pg/charts/cloudnative-pg \
  --version 0.29.1 \
  --namespace database --create-namespace \
  --values - <<'EOF'
config:
  clusterWide: true
crds:
  create: true
monitoring:
  podMonitorEnabled: true
EOF

Create Cluster and Database

kubectl apply -f - <<'EOF'
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: test-postgres
  namespace: database
spec:
  imageName: ghcr.io/cloudnative-pg/postgresql:18.6-minimal-trixie
  instances: 4
  primaryUpdateMethod: switchover
  primaryUpdateStrategy: unsupervised
  storage:
    size: 5Gi
    storageClass: local-path
EOF
# Enable PodMonitor to actually scrape those cluster metrics
kubectl apply -f - <<'EOF'
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: test-postgres
  namespace: database
spec:
  selector:
    matchLabels:
      cnpg.io/cluster: test-postgres
  podMetricsEndpoints:
    - port: metrics
      interval: 15s
EOF

Services:

  • test-postgres-rw (primary)
  • test-postgres-ro (replicas only)
  • test-postgres-r (any instance)

Connect:

kubectl -n database get secret test-postgres-app -o jsonpath='{.data.uri}' | base64 -d; echo
kubectl -n database exec -it test-postgres-1 -- psql -U postgres -d app

Testing with pgbench

just test init
just test rw
just test ro
just test failover
just test clean

Testing with own loadtest tool

deploy.sh (re)deploys the demo app: one writer pod and a reader pod with configurable load.

chmod +x deploy.sh   # once
./deploy.sh          # deploy / redeploy with defaults (60 reader threads)
./deploy.sh --threads 100 --retries false

Check the logs and stop the app:

kubectl -n database logs deploy/demo-writer --tail=20
kubectl -n database scale deploy/demo-writer deploy/demo-reader --replicas=0

Run ./deploy.sh --help for all options.