Loading...
Loading...
Wire Vault Kubernetes authentication for a service using hvac. Use this skill when adding or modifying Vault auth in any Kubernetes-deployed service — always read the Vault role and mount path from environment variables, never hardcode them.
npx skill4agent add mitodl/agent-kit vault-k8s-authhvac| Variable | Purpose |
|---|---|
| URL of the Vault server |
| Vault role bound to the pod's Kubernetes service account |
| Vault Kubernetes auth mount path |
import os
import hvac
vault_role = os.environ["VAULT_ROLE"]
vault_mount = os.environ["VAULT_K8S_MOUNT"]
client = hvac.Client(url=os.environ["VAULT_ADDR"])
client.auth.kubernetes.login(
role=vault_role,
jwt=_read_service_account_token(),
mount_point=vault_mount,
)OLEKSAuthBindingenv:
- name: VAULT_ROLE
value: "<service-name>-role"
- name: VAULT_K8S_MOUNT
value: "<mount-path>"
- name: VAULT_ADDR
valueFrom:
secretKeyRef:
name: vault-config
key: addr