Skip to content

Commit a774365

Browse files
mTLS support for Postgres self hosted (#1758)
## Overview - Added to external PG page section for mtls support - Updated existing redis MTLS docs ## Type of change Update Existing documentation ## Related issues/PRs Closes INF-1268 ## Checklist <!-- Put an 'x' in all boxes that apply --> - [X] I have read the [contributing guidelines](README.md) - [X] I have tested my changes locally using `docs dev` - [X] All code examples have been tested and work correctly - [X] I have used **root relative** paths for internal links - [ ] I have updated navigation in `src/docs.json` if needed --------- Co-authored-by: Kathryn May <44557882+katmayb@users.noreply.github.com>
1 parent 0ae83df commit a774365

File tree

2 files changed

+134
-9
lines changed

2 files changed

+134
-9
lines changed

src/langsmith/self-host-external-postgres.mdx

Lines changed: 110 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Connect to an external PostgreSQL database
33
sidebarTitle: Connect to an external PostgreSQL database
44
---
55

6-
LangSmith uses a PostgreSQL database as the primary data store for transactional workloads and operational data (almost everything besides runs). By default, LangSmith Self-Hosted will use an internal PostgreSQL database. However, you can configure LangSmith to use an external PostgreSQL database (). By configuring an external PostgreSQL database, you can more easily manage backups, scaling, and other operational tasks for your database.
6+
LangSmith uses a PostgreSQL database as the primary data store for transactional workloads and operational data (almost everything besides runs). By default, LangSmith Self-Hosted will use an internal PostgreSQL database. However, you can configure LangSmith to use an external PostgreSQL database. By configuring an external PostgreSQL database, you can more easily manage backups, scaling, and other operational tasks for your database.
77

88
## Requirements
99

@@ -17,13 +17,13 @@ LangSmith uses a PostgreSQL database as the primary data store for transactional
1717

1818
* A user with admin access to the PostgreSQL database. This user will be used to create the necessary tables, indexes, and schemas.
1919

20-
* This user will also need to have the ability to create extensions in the database. We use/will try to install the btree\_gin, btree\_gist, pgcrypto, citext, ltree, and pg\_trgm extensions.
20+
* This user will also need to have the ability to create extensions in the database. We use/will try to install the `btree_gin`, `btree_gist`, `pgcrypto`, `citext`, `ltree`, and `pg_trgm` extensions.
2121

2222
* If using a schema other than public, ensure that you do not have any other schemas with the extensions enabled, or you must include that in your search path.
2323

2424
* Support for pgbouncer and other connection poolers is community-based. Community members have reported that pgbouncer has worked with `pool_mode` = `session` and a suitable setting for `ignore_startup_parameters` (as of writing, `search_path` and `lock_timeout` need to be ignored). Care is needed to avoid polluting connection pools; some level of PostgreSQL expertise is advisable. LangChain Inc currently does not have roadmap plans for formal test coverage or commercial support of pgbouncer or amazon rds proxy or any other poolers, but the community is welcome to discuss and collaborate on support through GitHub issues.
2525

26-
* By default, we recommend an instance with at least 2 vCPUs and 8GB of memory. However, the actual requirements will depend on your workload and the number of users you have. We recommend monitoring your PostgreSQL instance and scaling up as needed.
26+
* By default, we recommend an instance with **at least 2 vCPUs and 8GB of memory**. However, the actual requirements will depend on your workload and the number of users you have. We recommend monitoring your PostgreSQL instance and scaling up as needed.
2727

2828
## Connection String
2929

@@ -33,7 +33,7 @@ You will need to provide a connection string to your PostgreSQL database. This c
3333
* Port
3434
* Database
3535
* Username
36-
* Password(Make sure to url encode this if there are any special characters)
36+
* Password (Make sure to url encode this if there are any special characters)
3737
* URL params
3838

3939
This will take the form of:
@@ -75,3 +75,109 @@ POSTGRES_DATABASE_URI="Your connection url"
7575
</CodeGroup>
7676

7777
Once configured, you should be able to reinstall your LangSmith instance. If everything is configured correctly, your LangSmith instance should now be using your external PostgreSQL database.
78+
79+
## TLS with PostgreSQL
80+
81+
Use this section to configure TLS for PostgreSQL connections. For mounting internal/public CAs so LangSmith trusts your PostgreSQL server certificate, see [Configure custom TLS certificates](/langsmith/self-host-custom-tls-certificates#mount-internal-cas-for-tls).
82+
83+
### Server TLS (one-way)
84+
85+
To validate the PostgreSQL server certificate:
86+
87+
- Provide a CA bundle using `config.customCa.secretName` and `config.customCa.secretKey`.
88+
- Use `sslmode=require` or `sslmode=verify-full`, as well as `sslrootcert=system` to your connection URL.
89+
90+
<Warning>
91+
Mount a custom CA only when your PostgreSQL server uses an internal or private CA. Publicly trusted CAs do not require this configuration.
92+
</Warning>
93+
94+
<CodeGroup>
95+
96+
```yaml Helm (server TLS)
97+
config:
98+
customCa:
99+
secretName: "langsmith-custom-ca" # Secret containing your CA bundle
100+
secretKey: "ca.crt" # Key in the Secret with the CA bundle
101+
postgres:
102+
external:
103+
enabled: true
104+
connectionUrl: "myuser:mypassword@myhost:5432/mydatabase?sslmode=verify-full&sslrootcert=system"
105+
customTls: true
106+
```
107+
108+
```yaml Kubernetes Secret (CA bundle)
109+
apiVersion: v1
110+
kind: Secret
111+
metadata:
112+
name: langsmith-custom-ca
113+
type: Opaque
114+
stringData:
115+
ca.crt: |
116+
-----BEGIN CERTIFICATE-----
117+
<ROOT_OR_INTERMEDIATE_CA_CERT_CHAIN>
118+
-----END CERTIFICATE-----
119+
```
120+
121+
</CodeGroup>
122+
123+
### Mutual TLS with Client Auth (mTLS)
124+
125+
As of LangSmith helm chart version **0.12.28**, we support mTLS for PostgreSQL clients. For server-side authentication in mTLS, use the [Server TLS steps](#server-tls-one-way) (custom CA) in addition to the following client certificate configuration.
126+
127+
If your PostgreSQL server requires client certificate authentication:
128+
129+
- Provide a Secret with your client certificate and key.
130+
- Reference it via `postgres.external.clientCert.secretName` and specify the keys with `certSecretKey` and `keySecretKey`.
131+
- Use `sslmode=verify-full` and `sslrootcert=system` in your connection URL.
132+
133+
<CodeGroup>
134+
135+
```yaml Helm (client Auth)
136+
postgres:
137+
external:
138+
enabled: true
139+
connectionUrl: "myuser:mypassword@myhost:5432/mydatabase?sslmode=verify-full&sslrootcert=system"
140+
customTls: true
141+
clientCert:
142+
secretName: "postgres-mtls-secret"
143+
certSecretKey: "tls.crt"
144+
keySecretKey: "tls.key"
145+
```
146+
147+
```yaml Kubernetes Secret (client cert/key)
148+
apiVersion: v1
149+
kind: Secret
150+
metadata:
151+
name: postgres-mtls-secret
152+
type: Opaque
153+
stringData:
154+
tls.crt: |
155+
-----BEGIN CERTIFICATE-----
156+
<CLIENT_CERT>
157+
-----END CERTIFICATE-----
158+
tls.key: |
159+
-----BEGIN PRIVATE KEY-----
160+
<CLIENT_KEY>
161+
-----END PRIVATE KEY-----
162+
```
163+
164+
</CodeGroup>
165+
166+
#### Pod security context for certificate volumes
167+
168+
The certificate volumes mounted for mTLS are protected by file access restrictions. To ensure all LangSmith pods can read the certificate files, you must set `fsGroup: 1000` in the pod security context.
169+
170+
You can configure this in one of two ways:
171+
172+
**Option 1: Use `commonPodSecurityContext`**
173+
174+
Set the `fsGroup` at the top level to apply it to all pods:
175+
176+
```yaml
177+
commonPodSecurityContext:
178+
fsGroup: 1000
179+
```
180+
181+
**Option 2: Add to individual pod security contexts**
182+
183+
If you need more granular control, add the `fsGroup` to each pod's security context individually. See the [mTLS configuration example](https://github.com/langchain-ai/helm/blob/main/charts/langsmith/examples/mtls_config.yaml) for a complete reference.

src/langsmith/self-host-external-redis.mdx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ stringData:
252252

253253
### Mutual TLS with Client Auth (mTLS)
254254

255-
As of LangSmith helm chart version **0.12.26**, we support mTLS for Redis clients. For server-side authentication in mTLS, use the Server TLS steps above (custom CA) in addition to the client certificate configuration below.
255+
As of LangSmith helm chart version **0.12.28**, we support mTLS for Redis clients. For server-side authentication in mTLS, use the Server TLS steps above (custom CA) in addition to the client certificate configuration below.
256256

257257
If your Redis server requires client certificate authentication:
258258

@@ -269,8 +269,8 @@ redis:
269269
enabled: true
270270
clientCert:
271271
secretName: "redis-mtls-secret"
272-
certSecretKey: "client.crt"
273-
keySecretKey: "client.key"
272+
certSecretKey: "tls.crt"
273+
keySecretKey: "tls.key"
274274
# Standalone example:
275275
# connectionUrl: "rediss://host:6380/0?password=<PASSWORD>"
276276
# Or, for Cluster:
@@ -291,14 +291,33 @@ metadata:
291291
name: redis-mtls-secret
292292
type: Opaque
293293
stringData:
294-
client.crt: |
294+
tls.crt: |
295295
-----BEGIN CERTIFICATE-----
296296
<CLIENT_CERT>
297297
-----END CERTIFICATE-----
298-
client.key: |
298+
tls.key: |
299299
-----BEGIN PRIVATE KEY-----
300300
<CLIENT_KEY>
301301
-----END PRIVATE KEY-----
302302
```
303303

304304
</CodeGroup>
305+
306+
#### Pod security context for certificate volumes
307+
308+
The certificate volumes mounted for mTLS are protected by file access restrictions. To ensure all LangSmith pods can read the certificate files, you must set `fsGroup: 1000` in the pod security context.
309+
310+
You can configure this in one of two ways:
311+
312+
**Option 1: Use `commonPodSecurityContext`**
313+
314+
Set the `fsGroup` at the top level to apply it to all pods:
315+
316+
```yaml
317+
commonPodSecurityContext:
318+
fsGroup: 1000
319+
```
320+
321+
**Option 2: Add to individual pod security contexts**
322+
323+
If you need more granular control, add the `fsGroup` to each pod's security context individually. See the [mtls configuration example](https://github.com/langchain-ai/helm/blob/main/charts/langsmith/examples/mtls_config.yaml) for a complete reference.

0 commit comments

Comments
 (0)