Skip to content

Commit 9c09e2f

Browse files
Merge pull request #48 from GitGuardian/fperucki/-/fix-hcv-k8s
docs(hashicorp): improve hashicorp kube authentication method doc
2 parents b869517 + 873bc5b commit 9c09e2f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

charts/ggscout/examples/hashicorpvault-k8s/README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,36 @@
22

33
This example demonstrates how to configure ggscout to authenticate with HashiCorp Vault using Kubernetes authentication when running in a Kubernetes cluster.
44

5-
## Prerequisites
6-
7-
1. HashiCorp Vault with Kubernetes auth method enabled
8-
2. Proper Vault policies and roles configured
9-
3. ggscout deployed in a Kubernetes cluster
10-
115
## Vault Configuration
126

137
### 1. Enable Kubernetes Auth Method
148

159
```bash
1610
# Enable Kubernetes auth method
17-
vault auth enable kubernetes
11+
vault auth enable kubernetes --path=kubernetes
1812
```
1913

14+
Note: the `--path` argument is not mandatory but lets you rename your authentication path, which must be unique, in case you have multiple kubernetes authentication methods configured.
15+
2016
See HashiCorp Vault reference [documentation](https://developer.hashicorp.com/vault/docs/auth/kubernetes#configuration)
2117

2218
### 2. Configure Kubernetes Auth Method
2319

2420
```bash
21+
22+
CA_CRT=$(kubectl get cm kube-root-ca.crt -o jsonpath="{['data']['ca\.crt']}")
23+
2524
# Configure the Kubernetes auth method
2625
vault write auth/kubernetes/config \
27-
token_reviewer_jwt="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
28-
kubernetes_host="https://$KUBERNETES_PORT_443_TCP_ADDR:443" \
29-
kubernetes_ca_cert=@/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
26+
kubernetes_host="https://$KUBERNETES_ADDR" \
27+
kubernetes_ca_cert="$CA_CRT"
3028
```
3129

30+
Note: replace `auth/kubernetes` with `auth/yourpath` if you used the `--path` argument in the `vault auth enable` command above.
31+
32+
If your Vault is running in Kubernetes, you need add `disable_local_ca_jwt=true` in the command above. For more details, follow (these steps)[https://developer.hashicorp.com/vault/docs/auth/kubernetes#use-the-vault-client-s-jwt-as-the-reviewer-jwt] from the HashiCorp documentation.
33+
34+
3235
### 3. Create Vault Policy
3336

3437
```bash
@@ -60,6 +63,7 @@ vault write auth/kubernetes/role/ggscout \
6063
ttl=24h
6164
```
6265

66+
6367
## Deployment
6468

6569
### 1. Update Configuration

charts/ggscout/examples/hashicorpvault-k8s/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ inventory:
1111
auth_mode: "k8s"
1212
k8s:
1313
role: "${VAULT_K8S_ROLE}"
14+
mount: "kubernetes" # This is the default; if the authentication path has changed, this must be updated
1415
fetch_all_versions: true # Fetch all versions of secrets or not
1516
path: "secret/dev" # Vault path or unspecified
1617
mode: "read/write" # Can be `read`, `write` or `read/write` depending on wether fetch and/or sync are enabled

0 commit comments

Comments
 (0)