Skip to content

Commit 31d423d

Browse files
committed
adds vault secret injection docs
Signed-off-by: ChrisJBurns <[email protected]>
1 parent dd83ddf commit 31d423d

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

docs/toolhive/guides-k8s/run-mcp-k8s.mdx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,66 @@ kubectl apply -f my-mcpserver-with-secrets-eso.yaml
346346
This example shows how to use [Vault](https://developer.hashicorp.com/vault) to
347347
inject secrets into the ToolHive containers for consumption.
348348

349-
Chris to flesh out with Jakub
349+
Injecting secrets using Vault is done with its agent sidecar container, but
350+
before you can start injecting secrets into the container there are some steps
351+
to do before hand. This includes setting up Vault to be able to authenticate and
352+
pull the necessary secrets. We will not detail here how to do this as there are
353+
some very helpful
354+
[Vault guides](https://developer.hashicorp.com/vault/tutorials/kubernetes/kubernetes-sidecar)
355+
on setting this up, but before we can inject secrets into the ToolHive
356+
containers we need to have the following:
357+
358+
- Vault available
359+
- Vault configured for Kubernetes authentication
360+
- Vault policy created to be able to read the desired secrets
361+
- Vault role created that is bound to the ToolHive ProxyRunner Service Account
362+
in order to enable authentication
363+
364+
```yaml {23-33} title="my-mcpserver-with-vault-secrets-injection.yaml"
365+
apiVersion: toolhive.stacklok.dev/v1alpha1
366+
kind: MCPServer
367+
metadata:
368+
name: github-vault-generic
369+
namespace: toolhive-system
370+
spec:
371+
image: ghcr.io/github/github-mcp-server:latest
372+
transport: stdio
373+
port: 9095
374+
permissionProfile:
375+
type: builtin
376+
name: network
377+
resources:
378+
limits:
379+
cpu: '100m'
380+
memory: '128Mi'
381+
requests:
382+
cpu: '50m'
383+
memory: '64Mi'
384+
resourceOverrides:
385+
proxyDeployment:
386+
podTemplateMetadataOverrides:
387+
annotations:
388+
# Enable Vault Agent injection
389+
vault.hashicorp.com/agent-inject: 'true'
390+
vault.hashicorp.com/role: '<ROLE_NAME_CREATE_IN_VAULT>'
391+
392+
# Inject GitHub configuration secret
393+
vault.hashicorp.com/agent-inject-secret-github-config: 'workload-secrets/data/github-mcp/config'
394+
vault.hashicorp.com/agent-inject-template-github-config: |
395+
{{- with secret "workload-secrets/data/github-mcp/config" -}}
396+
GITHUB_PERSONAL_ACCESS_TOKEN={{ .Data.data.token }}
397+
{{- end -}}
398+
```
399+
400+
Apply the MCPServer resource:
401+
402+
```bash
403+
kubectl apply -f my-mcpserver-with-vault-secrets-injection.yaml
404+
```
405+
406+
The Vault agent sidecar will now inject secrets from the
407+
`workload-secrets/data/github-mcp/config` inside of Vault, into the ProxyRunner
408+
container.
350409

351410
</TabItem>
352411
</Tabs>

0 commit comments

Comments
 (0)