Skip to content

Commit 7de1b3b

Browse files
ChrisJBurnsdanbarr
andauthored
adds docs for using different secrets managers in k8s (#171)
* adds docs for using different secrets managers in k8s Signed-off-by: ChrisJBurns <[email protected]> * adds vault secret injection docs Signed-off-by: ChrisJBurns <[email protected]> * corrects name of k8s docs Signed-off-by: ChrisJBurns <[email protected]> * Update wording, rewrite the Vault section Signed-off-by: Dan Barr <[email protected]> --------- Signed-off-by: ChrisJBurns <[email protected]> Signed-off-by: Dan Barr <[email protected]> Co-authored-by: Dan Barr <[email protected]>
1 parent d44e055 commit 7de1b3b

File tree

7 files changed

+104
-20
lines changed

7 files changed

+104
-20
lines changed

docs/toolhive/guides-cli/advanced-cicd.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,6 @@ When implementing advanced CI/CD patterns:
313313
## Related information
314314

315315
- [Build MCP server containers](./build-containers.mdx)
316-
- [Run MCP servers in Kubernetes](../guides-k8s/run-mcp-k8s.md)
316+
- [Run MCP servers in Kubernetes](../guides-k8s/run-mcp-k8s.mdx)
317317
- [`thv build` command reference](../reference/cli/thv_build.md)
318318
- [Secrets management](./secrets-management.mdx)

docs/toolhive/guides-cli/build-containers.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ thv build --tag my-server:dev go:///path/to/my-project
316316

317317
- Use built containers with [`thv run`](./run-mcp-servers.mdx) for local
318318
development
319-
- Deploy pre-built containers to [Kubernetes](../guides-k8s/run-mcp-k8s.md)
319+
- Deploy pre-built containers to [Kubernetes](../guides-k8s/run-mcp-k8s.mdx)
320320
- Set up [CI/CD pipelines](#cicd-integration) for automated building
321321
- Learn about [container registry workflows](#custom-image-tagging)
322322

323323
## Related information
324324

325325
- [`thv build` command reference](../reference/cli/thv_build.md)
326326
- [Run MCP servers](./run-mcp-servers.mdx)
327-
- [Run MCP servers in Kubernetes](../guides-k8s/run-mcp-k8s.md)
327+
- [Run MCP servers in Kubernetes](../guides-k8s/run-mcp-k8s.mdx)
328328
- [Custom permissions](./custom-permissions.mdx)
329329

330330
## Troubleshooting

docs/toolhive/guides-k8s/deploy-operator-helm.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ create it.
257257

258258
## Next steps
259259

260-
See [Run MCP servers in Kubernetes](./run-mcp-k8s.md) to learn how to create and
261-
manage MCP servers using the ToolHive operator in your Kubernetes cluster. The
262-
operator supports deploying MCPServer resources based on the deployment mode
260+
See [Run MCP servers in Kubernetes](./run-mcp-k8s.mdx) to learn how to create
261+
and manage MCP servers using the ToolHive operator in your Kubernetes cluster.
262+
The operator supports deploying MCPServer resources based on the deployment mode
263263
configured during installation.
264264

265265
## Related information

docs/toolhive/guides-k8s/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ Kubernetes cluster. Helm simplifies the installation process and lets you manage
5757
the operator using Helm charts.
5858

5959
Once the operator is installed, you can create and manage MCP servers using the
60-
[`MCPServer` custom resource](./run-mcp-k8s.md).
60+
[`MCPServer` custom resource](./run-mcp-k8s.mdx).

docs/toolhive/guides-k8s/run-mcp-k8s.md renamed to docs/toolhive/guides-k8s/run-mcp-k8s.mdx

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,25 @@ process.
255255

256256
### Run a server with secrets
257257

258-
For MCP servers that require authentication tokens or other secrets, add the
259-
`secrets` field to the `MCPServer` resource. This example shows how to use a
260-
Kubernetes secret to pass a GitHub personal access token to the `github` MCP
261-
server.
258+
When your MCP servers require authentication tokens or other secrets, ToolHive
259+
supports multiple secrets management methods to fit your existing
260+
infrastructure. Choose the method that best suits your needs:
261+
262+
<Tabs groupId='secret-manager' queryString='secret-manager'>
263+
<TabItem value='kubernetes-native' label='Kubernetes secrets' default>
264+
265+
ToolHive can reference existing Kubernetes secrets to inject sensitive data into
266+
your MCP server pods as environment variables. This example demonstrates how to
267+
pass a GitHub personal access token to the `github` MCP server.
268+
269+
First, create the secret. The secret must exist in the same namespace as your
270+
MCP server and the key must match what you specify in the `MCPServer` resource.
271+
272+
```bash
273+
kubectl -n production create secret generic github-token --from-literal=token=<YOUR_TOKEN>
274+
```
275+
276+
Next, define the `MCPServer` resource to reference the secret:
262277

263278
```yaml {13-16} title="my-mcpserver-with-secrets.yaml"
264279
apiVersion: toolhive.stacklok.dev/v1alpha1
@@ -279,20 +294,88 @@ spec:
279294
targetEnvName: GITHUB_PERSONAL_ACCESS_TOKEN
280295
```
281296

282-
First, create the secret. Note that the secret must be created in the same
283-
namespace as the MCP server and the key must match the one specified in the
284-
`MCPServer` resource.
297+
Finally, apply the MCPServer resource:
285298

286299
```bash
287-
kubectl -n production create secret generic github-token --from-literal=token=<YOUR_TOKEN>
300+
kubectl apply -f my-mcpserver-with-secrets.yaml
288301
```
289302

290-
Apply the MCPServer resource:
303+
</TabItem>
304+
<TabItem value='eso' label='External Secrets Operator'>
305+
306+
[External Secrets Operator](https://external-secrets.io/) is a Kubernetes
307+
operator that integrates external secret management systems and syncs secrets
308+
into Kubernetes as native resources. This example demonstrates how to use
309+
ESO-managed secrets with your MCP server.
310+
311+
:::note
312+
313+
When you use the External Secrets Operator, your MCP server definition will look
314+
the same as the Kubernetes-native example. This is because the External Secrets
315+
Operator creates standard Kubernetes secrets from external sources.
316+
317+
:::
318+
319+
First, create a secret using the
320+
[ExternalSecret resource](https://external-secrets.io/latest/api/externalsecret/).
321+
The exact configuration depends on your external secret management system. The
322+
secret must exist in the same namespace as your MCP server and the key must
323+
match what you specify in the `MCPServer` resource.
324+
325+
Next, define the `MCPServer` resource to reference the secret:
326+
327+
```yaml {13-16} title="my-mcpserver-with-secrets-eso.yaml"
328+
apiVersion: toolhive.stacklok.dev/v1alpha1
329+
kind: MCPServer
330+
metadata:
331+
name: github
332+
namespace: production # Can be any namespace
333+
spec:
334+
image: ghcr.io/github/github-mcp-server
335+
transport: stdio
336+
port: 8080
337+
permissionProfile:
338+
type: builtin
339+
name: network
340+
secrets:
341+
- name: github-token
342+
key: token
343+
targetEnvName: GITHUB_PERSONAL_ACCESS_TOKEN
344+
```
345+
346+
Finally, apply the MCPServer resource:
291347

292348
```bash
293-
kubectl apply -f my-mcpserver-with-secrets.yaml
349+
kubectl apply -f my-mcpserver-with-secrets-eso.yaml
294350
```
295351

352+
</TabItem>
353+
<TabItem value='vault' label='HashiCorp Vault'>
354+
355+
HashiCorp Vault provides multiple integration methods for Kubernetes
356+
environments:
357+
358+
1. [Vault Sidecar Agent Injector](https://developer.hashicorp.com/vault/docs/deploy/kubernetes/injector),
359+
which injects a sidecar container into your pod to fetch and renew secrets
360+
2. [Vault Secrets Operator](https://developer.hashicorp.com/vault/docs/deploy/kubernetes/vso),
361+
which creates Kubernetes secrets from Vault secrets (similar to the External
362+
Secrets Operator)
363+
3. [Vault CSI Provider](https://developer.hashicorp.com/vault/docs/deploy/kubernetes/csi),
364+
which mounts secrets directly into your pod as files
365+
366+
ToolHive supports the first two methods. When you use the Vault Secrets
367+
Operator, your MCP server definition will look the same as the Kubernetes-native
368+
example because the Vault Secrets Operator creates standard Kubernetes secrets
369+
from Vault.
370+
371+
The Vault Sidecar Agent Injector requires additional configuration in your
372+
`MCPServer` resource to add the required annotations. For a complete example,
373+
see the
374+
[HashiCorp Vault integration tutorial](../tutorials/vault-integration.mdx).
375+
376+
</TabItem>
377+
</Tabs>
378+
296379
### Mount a volume
297380

298381
You can mount volumes into the MCP server pod to provide persistent storage or

docs/toolhive/guides-mcp/filesystem.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ outbound network access (see the
109109
<TabItem value='k8s' label='Kubernetes'>
110110

111111
Create a Kubernetes manifest to deploy the Filesystem MCP server with a
112-
[persistent volume](../guides-k8s/run-mcp-k8s.md#mount-a-volume).
112+
[persistent volume](../guides-k8s/run-mcp-k8s.mdx#mount-a-volume).
113113

114114
Update the `podTemplateSpec` section to include your specific volume claim and
115115
mount path:

docs/toolhive/tutorials/quickstart-k8s.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,9 @@ operator.
432432

433433
Here are some next steps to explore:
434434

435-
- Learn about [advanced MCP server configurations](../guides-k8s/run-mcp-k8s.md)
436-
for production deployments
435+
- Learn about
436+
[advanced MCP server configurations](../guides-k8s/run-mcp-k8s.mdx) for
437+
production deployments
437438
- Learn more about
438439
[Helm deployment options](../guides-k8s/deploy-operator-helm.md) and
439440
configuration

0 commit comments

Comments
 (0)