Skip to content

Commit 4d0b8b4

Browse files
authored
Merge pull request aws-samples#307 from RenaultAI/fix/config-secrets
Add missing Vault auth and simplify some steps
2 parents a58fb9e + cb8c46a commit 4d0b8b4

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

config-secrets/readme.adoc

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,17 @@ Cluster ID: 89ccbeb4-8af1-7dca-77bb-38f39c423a39
834834
High-Availability Enabled: false
835835
```
836836

837+
. Authenticate against Vault using the root token from the output when starting vault:
838+
+
839+
```
840+
vault auth
841+
Token (will be hidden):
842+
Successfully authenticated! You are now logged in.
843+
token: 4e93b3c6-c459-f166-e7e9-6c48044cfdb6
844+
token_duration: 0
845+
token_policies: [root]
846+
```
847+
837848
=== Configure Kubernetes Service Account
838849

839850
. Create the service account to verify service account token during login:
@@ -860,6 +871,10 @@ Service account token, Kubernetes API server address and the certificate used to
860871
kubectl get secret \
861872
$(kubectl get serviceaccount vault-reviewer -o jsonpath={.secrets[0].name}) \
862873
-o jsonpath={.data.token} | base64 -D -
874+
export REVIEWER_TOKEN=$(kubectl get secret \
875+
$(kubectl get serviceaccount vault-reviewer \
876+
-o jsonpath={.secrets[0].name}) -o jsonpath={.data.token} | base64 -D -)
877+
&& echo $REVIEWER_TOKEN
863878
eyJ . . . reg
864879

865880
. Get the API server address:
@@ -888,7 +903,7 @@ This is the address of API servers currently configured. The first one is for th
888903
.. Configure the auth backend:
889904

890905
$ vault write auth/kubernetes/config \
891-
token_reviewer_jwt=<service-account-token> \
906+
token_reviewer_jwt=$REVIEWER_TOKEN \
892907
kubernetes_host=<api-server> \
893908
kubernetes_ca_cert=@~/.kube/kops.crt
894909
+
@@ -960,9 +975,17 @@ More details about the Docker image used in the Pod is at https://github.com/aru
960975
image: arungupta/vault-kubernetes:latest
961976
env:
962977
- name: VAULT_ADDR
963-
value: http://ec2-54-237-223-40.compute-1.amazonaws.com:8200
978+
valueFrom:
979+
configMapKeyRef:
980+
name: vault
981+
key: address
964982
restartPolicy: Never
965983

984+
. Create the ConfigMap:
985+
986+
$ kubectl create configmap vault --from-literal=address=$VAULT_ADDR
987+
configmap "vault" created
988+
966989
. Deploy the Pod:
967990

968991
$ kubectl apply -f templates/pod-vault.yaml

config-secrets/templates/pod-vault.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ spec:
99
image: arungupta/vault-kubernetes:latest
1010
env:
1111
- name: VAULT_ADDR
12-
value: http://ec2-54-237-223-40.compute-1.amazonaws.com:8200
13-
restartPolicy: Never
12+
valueFrom:
13+
configMapKeyRef:
14+
name: vault
15+
key: address
16+
restartPolicy: Never

0 commit comments

Comments
 (0)