Installing PostgreSQL (pgvector)

Note:
  • SKIP this step if AI Pilot is enabled, as AI Agentic Builder is already configured to use a PGVector-enabled PostgreSQL instance deployed by UnO AI Pilot.
  • If you set up PostgreSQL using the Installation and Configuration section, update the values under uno.agenticAIBuilder.common.postgres in the values.yaml file to match your setup. No changes are needed if you are using the pgvector-enabled PostgreSQL instance deployed by UnO AI Pilot.

To set up a PostgreSQL database with pgvector support, follow these steps:

  1. Generate Secure Passwords: You will need three unique, secure, base64-encoded passwords. Run the following command three times and save the output each time.
    head /dev/urandom | tr -dc A-Za-z0-9 | head -c32 | base64
  2. Create password-secret.yaml

    Create a file named password-secret.yaml with the following content.

    Replace <base64-encoded-passwordX> with the actual passwords you generated in the previous step.

    apiVersion: v1
    kind: Secret
    metadata:
      name: postgres-password-secret
      labels:
        app: postgres-password-secret
      annotations:
        helm.sh/resource-policy: keep
    data:
      password: <base64-encoded-password1>
      postgres-password: <base64-encoded-password2>
      replication-password: <base64-encoded-password3>
  3. Create values.yaml for Helm Deployment

    Create a file named values.yaml with the following configuration. This uses a pre-built image that includes the pgvector extension.

    auth:
      enablePostgresUser: true
      existingSecret: "postgres-password-secret"
      username: "pguser"
    
    tls:
      enabled: true
      autoGenerated: true
    
    # This section uses a pre-built image with pgvector included.
    # If you need to build your own custom image, see the optional steps below.
    image:
      registry: hclcr.io
      repository: uno/pgvector
      tag: 17
      pullSecrets: [] # 🔑 Replace with your actual image pull secret(s), e.g., ["hclcr-pull-secret"]
    
  4. Deploy PostgreSQL Using Helm- First, ensure you have set your Kubernetes namespace as the $NAMESPACE environment variable. Then, run the following commands to apply the secret and deploy the database.
    kubectl --namespace $NAMESPACE apply -f ./password-secret.yaml
    
    helm --namespace $NAMESPACE upgrade --install postgresdb \
      oci://registry-1.docker.io/bitnamicharts/postgresql \
      -f values.yaml
  5. Optional: Enable Long-Term Memory Support with a custom image This guide already includes pgvector via the image in Step 3. However, if you want to build your own custom image instead of using the prebuilt one, follow these steps:
    • Build Your Own pgvector-Enabled Image:
      Create a Dockerfile with the following content:
      FROM pgvector/pgvector:pg16 AS builder
      
      FROM bitnami/postgresql-repmgr:16
      
      COPY --from=builder /usr/lib/postgresql/16/lib/vector.so /opt/bitnami/postgresql/lib/
      COPY --from=builder /usr/share/postgresql/16/extension/vector* /opt/bitnami/postgresql/share/extension/
      
    • Build and Push the Image:

      Build this image and push it to a container registry.

    • Update values.yaml:

      Replace the image: section in your values.yaml with your custom registry, repository, and tag.