|
2 | 2 |
|
3 | 3 | This example demonstrates how to configure ggscout to authenticate with HashiCorp Vault using Kubernetes authentication when running in a Kubernetes cluster.
|
4 | 4 |
|
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 |
| - |
11 | 5 | ## Vault Configuration
|
12 | 6 |
|
13 | 7 | ### 1. Enable Kubernetes Auth Method
|
14 | 8 |
|
15 | 9 | ```bash
|
16 | 10 | # Enable Kubernetes auth method
|
17 |
| -vault auth enable kubernetes |
| 11 | +vault auth enable kubernetes --path=kubernetes |
18 | 12 | ```
|
19 | 13 |
|
| 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 | + |
20 | 16 | See HashiCorp Vault reference [documentation](https://developer.hashicorp.com/vault/docs/auth/kubernetes#configuration)
|
21 | 17 |
|
22 | 18 | ### 2. Configure Kubernetes Auth Method
|
23 | 19 |
|
24 | 20 | ```bash
|
| 21 | + |
| 22 | +CA_CRT=$(kubectl get cm kube-root-ca.crt -o jsonpath="{['data']['ca\.crt']}") |
| 23 | + |
25 | 24 | # Configure the Kubernetes auth method
|
26 | 25 | 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" |
30 | 28 | ```
|
31 | 29 |
|
| 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 | + |
32 | 35 | ### 3. Create Vault Policy
|
33 | 36 |
|
34 | 37 | ```bash
|
@@ -60,6 +63,7 @@ vault write auth/kubernetes/role/ggscout \
|
60 | 63 | ttl=24h
|
61 | 64 | ```
|
62 | 65 |
|
| 66 | + |
63 | 67 | ## Deployment
|
64 | 68 |
|
65 | 69 | ### 1. Update Configuration
|
|
0 commit comments