15
15
export PATH=$PATH :/path/to/vault
16
16
```
17
17
18
- * Modify Docker compose configuration on this file: ` docker-compose.yaml `
18
+ ### Modify Docker compose configuration on this file: ` docker-compose.yaml `
19
19
20
20
``` yaml
21
21
version : ' 3'
@@ -37,7 +37,7 @@ services:
37
37
entrypoint : vault server -config=/vault/config/vault.hcl
38
38
` ` `
39
39
40
- * Create a Vault server configuration file named: ` vault.hcl`
40
+ ### Create a Vault server configuration file named: ` vault.hcl`
41
41
42
42
` ` ` hcl
43
43
storage "file" {
@@ -56,7 +56,7 @@ default_lease_ttl = "12h"
56
56
api_addr = "http://127.0.0.1:8200"
57
57
` ` `
58
58
59
- * Create volumes and copy any certificate/key that you have
59
+ # ## Create volumes and copy any certificate/key that you have
60
60
61
61
` ` ` shell
62
62
# Create volumes on your local filesystem, for cloud environments you'll need a private volume
@@ -246,86 +246,98 @@ api_addr = "http://127.0.0.1:8200"
246
246
EOF
247
247
` ` `
248
248
249
- * Create an AppRole with role_id and secret_id
249
+ # # Create an AppRole with role_id and secret_id
250
250
251
- ` ` ` shell
252
- # Policy indicates the permissions and scopes an AppRole will have
253
- vault policy write my-policy my-policy-permissions.hcl
251
+ ` ` ` shell
252
+ # Policy indicates the permissions and scopes an AppRole will have
253
+ vault policy write my-policy my-policy-permissions.hcl
254
254
255
- # Create an AppRole, usually one per application
256
- vault write auth/approle/role/my-role secret_id_ttl="720h" token_ttl="12h"\
257
- token_max_tll="12h" policies="my-policy"
255
+ # Create an AppRole, usually one per application
256
+ vault write auth/approle/role/my-role secret_id_ttl="720h" token_ttl="12h"\
257
+ token_max_tll="12h" policies="my-policy"
258
258
259
- # Get the AppRole role-id
260
- vault read auth/approle/role/my-role/role-id
259
+ # Get the AppRole role-id
260
+ vault read auth/approle/role/my-role/role-id
261
261
262
- # Get the initial secret-id tied to the role-id
263
- vault write -f auth/approle/role/my-role/secret-id
262
+ # Get the initial secret-id tied to the role-id
263
+ vault write -f auth/approle/role/my-role/secret-id
264
264
` ` `
265
265
266
- * Enable kubernetes auth method and create a role
266
+ # # Enable kubernetes auth method and create a role
267
267
268
- ` ` ` shell
269
- # Enable kubernetes auth method and mount it on default auth/kubernetes
270
- vault auth enable kubernetes
271
-
272
- # Get you K8s cluster info
273
- kubectl cluster-info
274
-
275
- # Configure a service account for the vault
276
- kubectl apply -f ./tests/k8s-service-account.yaml
277
-
278
- # Find out the vault-auth service account token
279
- kubectl get secret <secret_name> -o jsonpath={.data.token} | base64 -d
280
-
281
- # Configure Vault K8s auth method
282
- vault write auth/kubernetes/config \
283
- token_reviewer_jwt="<your reviewer service account JWT>" \
284
- kubernetes_host=https://192.168.99.119:8443 \
285
-
286
-
287
- # Create a named role
288
- vault write auth/kubernetes/role/my-role \
289
- bound_service_account_names=vault-auth \
290
- bound_service_account_namespaces=default \
291
- policies=default \
292
- ttl=1h
293
-
294
- # Test a login using K8s auth method
295
- vault write auth/kubernetes/login \
296
- role=my-role \
297
- jwt="<your reviewer service account JWT>"
298
- ` ` `
268
+ ` ` ` shell
269
+ # Enable kubernetes auth method and mount it on default auth/kubernetes
270
+ vault auth enable kubernetes
299
271
300
- * Enable TLS cert auth method and create a cert
272
+ # Get you K8s cluster info
273
+ kubectl cluster-info
301
274
302
- ` ` ` shell
303
- # Enable TLS Certificate auth method
304
- vault auth enable cert
305
-
306
- # Create a PKI role to issue certificates
307
- vault write pki_int/roles/vault-cert \
308
- allow_any_name=true \
309
- max_ttl=720h \
310
- generate_lease=true
311
-
312
- # Create a policy for the certificates issued
313
- vault policy write cert-policy ./policies/cert-policy.hcl
314
-
315
- # Issue a certificate based on the create role
316
- vault write -format=json pki_int/issue/vault-cert \
317
- common_name=vault-cert | tee \
318
- >(jq -r .data.certificate > vault-cert-certificate.pem) \
319
- >(jq -r .data.issuing_ca > vault-cert-issuing-ca.pem) \
320
- >(jq -r .data.private_key > vault-cert-private-key.pem)
321
-
322
- # Create a cert for authentication
323
- vault write auth/cert/certs/vault-cert \
324
- display_name=vault-cert \
325
- policies=cert \
326
-
327
-
328
- # Test cert login
329
- vault login -method=cert -client-cert=vault-cert-certificate.pem \
330
- -client-key=vault-cert-private-key.pem
331
- ` ` `
275
+ # Configure a service account for the vault
276
+ kubectl apply -f ./tests/k8s-service-account.yaml
277
+
278
+ # Find out the vault-auth service account token
279
+ kubectl get secret <secret_name> -o jsonpath={.data.token} | base64 -d
280
+
281
+ # Configure Vault K8s auth method
282
+ vault write auth/kubernetes/config \
283
+ token_reviewer_jwt="<your reviewer service account JWT>" \
284
+ kubernetes_host=https://192.168.99.119:8443 \
285
+
286
+
287
+ # Create a named role
288
+ vault write auth/kubernetes/role/my-role \
289
+ bound_service_account_names=vault-auth \
290
+ bound_service_account_namespaces=default \
291
+ policies=default \
292
+ ttl=1h
293
+
294
+ # Test a login using K8s auth method
295
+ vault write auth/kubernetes/login \
296
+ role=my-role \
297
+ jwt="<your reviewer service account JWT>"
298
+ ` ` `
299
+
300
+ # # Enable TLS cert auth method and create a cert
301
+
302
+ ` ` ` shell
303
+ # Enable TLS Certificate auth method
304
+ vault auth enable cert
305
+
306
+ # Create a PKI role to issue certificates
307
+ vault write pki_int/roles/vault-cert \
308
+ allow_any_name=true \
309
+ max_ttl=720h \
310
+ generate_lease=true
311
+
312
+ # Create a policy for the certificates issued
313
+ vault policy write cert-policy ./policies/cert-policy.hcl
314
+
315
+ # Issue a certificate based on the create role
316
+ vault write -format=json pki_int/issue/vault-cert \
317
+ common_name=vault-cert | tee \
318
+ >(jq -r .data.certificate > vault-cert-certificate.pem) \
319
+ >(jq -r .data.issuing_ca > vault-cert-issuing-ca.pem) \
320
+ >(jq -r .data.private_key > vault-cert-private-key.pem)
321
+
322
+ # Create a cert for authentication
323
+ vault write auth/cert/certs/vault-cert \
324
+ display_name=vault-cert \
325
+ policies=cert \
326
+
327
+
328
+ # Test cert login
329
+ vault login -method=cert -client-cert=vault-cert-certificate.pem \
330
+ -client-key=vault-cert-private-key.pem
331
+ ` ` `
332
+
333
+ # # Enable AD secret engine and configure it
334
+
335
+ ` ` ` shell
336
+ vault write ad/config \
337
+ binddn="cn=admin,dc=chatopsknight,dc=com" \
338
+ bindpass=$LDAP_ADMIN_PASSWORD \
339
+ url=ldaps://ldap.chatopsknight.com \
340
+ userdn="dc=chatopsknight,dc=com" \
341
+
342
+ insecure_tls=false
343
+ ` ` `
0 commit comments