Home Assistant uses PostgreSQL for recording the history of entity states. Since we had been using the in-cluster database server for this, the data were migrated to the new external PostgreSQL server automatically when the backup from the former was restored on the latter. It follows, then, that we can point Home Assistant to the new server as well. Home Assistant uses SQLAlchemy, which in turn uses _libpq_ via _psycopg_, as a client for PostgreSQL. It doesn't expose any configuration parameters beyond the "database URL" directly, but we can use the standard environment variables to specify the certificate and private key for authentication. In fact, the empty `postgresql://` URL is sufficient, and indicates that _all_ of the connection parameters should be taken from environment variables. This makes specifying the parameters for both the `wait-for-db` init container and the main container take the exact same environment variables, so we can use YAML anchors to share their definitions.
14 lines
254 B
YAML
14 lines
254 B
YAML
apiVersion: cert-manager.io/v1
|
|
kind: Certificate
|
|
metadata:
|
|
name: postgres-client-cert
|
|
spec:
|
|
commonName: homeassistant
|
|
privateKey:
|
|
algorithm: ECDSA
|
|
secretName: postgres-client-cert
|
|
issuerRef:
|
|
name: postgresql-ca
|
|
kind: ClusterIssuer
|
|
|