## Spec schema

PgBouncer Spec defines the selected state of PgBouncer.

```yaml
PgBouncer:
  metadata:
    name: string
  spec:
    accessMode: string
    allowSuperUserAccess: boolean
    dbclusterRef: string
    parameters: object
    port: integer
    serverTLS:
      certSecret:
        name: string
```

| Field Type Required or optional | Description |
|---|---|
| `name` ||
| `string` *Required* | Name of the PgBouncer resource. |
| `accessMode` ||
| `string` *Optional* | Defines `rw` (read-write) or `ro` (read-only) access modes for PgBouncer connections. The default value is `rw`. |
| `allowSuperUserAccess` ||
| `boolean` *Optional* | AllowSuperUserAccess can be set to true or false. |
| `dbclusterRef` ||
| `string` *Required* | DBClusterRef is the DBCluster name that PgBouncer pools the connections for. You must create the PgBouncer object in the same namespace as the DBCluster that it references. This field is required for PgBouncer connection pooling. |
| `parameters` ||
| `object` *Optional* | Specifies key-value pairs for PgBouncer configurations. Enclose all values in quotation marks, for example, `default_pool_size: "20"`. For more information about available options, see the [PgBouncer configuration documentation](https://www.pgbouncer.org/config.html). Commonly used parameters include: - `pool_mode`: Specifies when a database connection can be reused by other clients. - `default_pool_size`: the maximum number of database connections to allow per user-database pair - `max_client_conn`: the maximum number of client connections - `max_db_connections`: the maximum number of database connections |
| `port` ||
| `integer` *Optional* | Specifies the port on which PgBouncer listens for incoming connections. The default value is `6432`. |
| `serverTLS` ||
| `object` *Optional* | ServerTLSSpec defines the certificate secret for encrypted communication used by PgBouncer to connect to the database cluster to fetch authentication credentials. |
| `serverTLS.certSecret` ||
| `object` *Optional* | CertSecret references the certificate secret within the same namespace. The secret must contain entries `ca.crt` (CA certificate), `tls.key` (private key), and `tls.crt` (leaf certificate). The values within this secret are used to populate the `server_tls_ca_file`, `server_tls_cert_file`, and `server_tls_key_file` configs in `pgbouncer.ini` file. The CA certificate must match the CA that signed the database cluster's leaf certificate. The leaf certificate must contain the CommonName `"alloydbpgbouncer"`. |
| `serverTLS.certSecret.name` ||
| `string` *Optional* | Name of the referent. |

## Status schema

PgBouncer Status defines the observed state of PgBouncer.

```yaml
endpoints:
  - name: string
    value: string
phase: string
port: integer
```

| Field Type Required or optional | Description |
|---|---|
| `endpoints` ||
| `array of objects` *Optional* | `endpoints` contains all the endpoints through which you can access this instance. |
| `endpoints.name` ||
| `string` *Required* | Name is the name of the endpoint---for example, `Read-Write`. |
| `endpoints.value` ||
| `string` *Required* | Value contains the endpoint information to connect and access the instance. |
| `phase` ||
| `string` *Required* | `phase` describes the state of PgBouncer Deployment. Values like `WaitingForDeploymentReady`, `Acquiring IP`, and `Ready` appear here. |
| `port` ||
| `integer` *Optional* | The port number exposed by PgBouncer for connections. |