Dagweave catalog

Run a PostgreSQL query

postgres-queryv1.0.0updated 2026-07-171 version

Run a SQL query against a PostgreSQL database with psql, using a password read from a Kubernetes Secret.

Install v1.0.0

Installs the template into your Argo namespace. The URL is pinned to this version.

kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml

Or with the Argo CLI:

argo template create -n argo https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml

Facts

Category
Databases
Tags
databases postgres
Entrypoint
query
Template SHA-256
c10e75ebc3180354c57921b4de6e9965f579c421f5b245f6ff835c804bc19ee6
Source
postgres-query at catalog commit 67458f7
API
item document, latest template.yaml

Images and provenance

Every image is pinned by digest, so a rebuilt tag can never change what this version runs.

RepositoryTagDigest
postgres19-alpinesha256:8b0ff4cdf221f0c53d7fcda681d3b461be725c492cd881c5ec9c0ad25023f188

Parameters

NameDescriptionDefault
database required Database name to connect to. none
host required PostgreSQL server host.
Example db.internal
none
query required The SQL query to run.
Example SELECT count(*) FROM orders;
none
user required User to authenticate as. none
password-secret-key Key within the Secret that holds the password. password
password-secret-name Name of the Kubernetes Secret holding the user's password. postgres-password
port PostgreSQL server port. 5432

WorkflowTemplate

Download template.yaml

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: postgres-query
  labels:
    dagweave.io/catalog-item: postgres-query
  annotations:
    # The catalog semver this manifest was authored at. The dagweave app records
    # (catalog-item-id, semver) -> content-hash -> base-vN when it mints the tenant
    # cluster name via ResolveOrMint. Keep in sync with metadata.yaml `version`.
    dagweave.io/catalog-version: "1.0.0"
    dagweave.io/catalog-category: "Databases"
spec:
  entrypoint: query
  templates:
    - name: query
      inputs:
        parameters:
          # The SQL query to run.
          - name: query
          # PostgreSQL server host.
          - name: host
          # PostgreSQL server port.
          - name: port
            default: "5432"
          # Database name to connect to.
          - name: database
          # User to authenticate as.
          - name: user
          # Name of the Kubernetes Secret holding the user's password. Defaults let a
          # user leave them blank in the Inspector.
          - name: password-secret-name
            default: postgres-password
          - name: password-secret-key
            default: password
      container:
        # Pinned by digest per the catalog convention: an image rebuild can never
        # silently change the behaviour of an already-released item version.
        # postgres:19-alpine
        image: postgres@sha256:8b0ff4cdf221f0c53d7fcda681d3b461be725c492cd881c5ec9c0ad25023f188
        command: [sh, -c]
        # The connection values and the query are passed as env vars (below), never
        # interpolated into the shell, so a query containing quotes or shell
        # metacharacters is safe. psql reads PGHOST/PGPORT/PGDATABASE/PGUSER/PGPASSWORD
        # from the environment. ON_ERROR_STOP makes a bad query fail the step.
        args:
          - |
            set -eu
            psql -v ON_ERROR_STOP=1 -c "$QUERY"
        env:
          - name: PGHOST
            value: "{{inputs.parameters.host}}"
          - name: PGPORT
            value: "{{inputs.parameters.port}}"
          - name: PGDATABASE
            value: "{{inputs.parameters.database}}"
          - name: PGUSER
            value: "{{inputs.parameters.user}}"
          - name: QUERY
            value: "{{inputs.parameters.query}}"
          - name: PGPASSWORD
            valueFrom:
              secretKeyRef:
                name: "{{inputs.parameters.password-secret-name}}"
                key: "{{inputs.parameters.password-secret-key}}"

Version history

Read from the item's changelog. Each version has its own JSON document; the pinned catalogue vendors the manifest of the latest one, so that is the version that installs.

  1. 1.0.0 latest 2026-07-17

    Initial release.

    kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml
    argo template create -n argo https://catalog.dagweave.com/api/v1/items/postgres-query/1.0.0/template.yaml

    version document, template.yaml

Run it once

After installing, from the command line.

argo submit -n argo --from workflowtemplate/postgres-query \
  -p database=... \
  -p host=db.internal \
  -p query='SELECT count(*) FROM orders;' \
  -p user=...

Workflow that references it

A Workflow with the required parameters filled from the examples.

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: postgres-query-
spec:
  workflowTemplateRef:
    name: postgres-query
  arguments:
    parameters:
      - name: database
        value: "..."
      - name: host
        value: "db.internal"
      - name: query
        value: "SELECT count(*) FROM orders;"
      - name: user
        value: "..."

As a step of a larger workflow

steps:
  - - name: postgres-query
      templateRef:
        name: postgres-query
        template: query