diff --git a/.DS_Store b/.DS_Store index df74ac8..25e87e4 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/2023/day39.md b/2023/day39.md index aadcdd9..b71098c 100644 --- a/2023/day39.md +++ b/2023/day39.md @@ -131,122 +131,67 @@ We must now exec into our vault-0 pod to enable the secret engine. `kubectl exec --stdin=true --tty=true vault-0 -n vault -- /bin/sh` -We will now have to authenticate and login using `vault login` and provide the token we discovered with root_token in a previous step. - ![](images/day39-7.png) -We will now run the following commands the first will enable the secret engine and the second will create secret at the path. -``` -vault secrets enable -path=secret kv-v2 +`vault secrets enable -path=secret kv-v2` -vault kv put secret/webapp/config username="static-user" password="static-password" -``` -You can then verify with the following command +`vault kv put secret/devwebapp/config username='giraffe' password='salsa'` -`vault kv get secret/webapp/config` - -So far we have used our root token this root user can peform any operation at any path and as you can expect best practices states that we dont or should not use this account other than initial setup and configuration. - -You should still be in your vault-0 pod. We are going to enable the Kubernetes authentication method with the following command: +`vault kv get secret/devwebapp/config` `vault auth enable kubernetes` -***Vault accepts this service token from any client within the Kubernetes cluster. During authentication, Vault verifies that the service account token is valid by querying a configured Kubernetes endpoint.*** - -Next we need to configure the Kubernetes authentication method to use the location of the Kubernetes API. - ``` vault write auth/kubernetes/config \ kubernetes_host="https://$KUBERNETES_PORT_443_TCP_ADDR:443" ``` - -## Creating a Vault Policy - -For a client or application to access the secret data defined, at secret/webapp/config, requires that the read capability be granted for the path secret/data/webapp/config. - ``` -vault policy write webapp - < devwebapp.yaml < -n webapp 8080:8080 -``` +`kubectl exec --stdin=true --tty=true devwebapp -n devwebapp -c devwebapp -- cat /vault/secrets/credentials.txt` diff --git a/2023/day39/cluster-keys.json b/2023/day39/cluster-keys.json index d5ac010..86e0575 100644 --- a/2023/day39/cluster-keys.json +++ b/2023/day39/cluster-keys.json @@ -1,9 +1,9 @@ { "unseal_keys_b64": [ - "qZiqjl0/r8zgnoCU8j9tdr5eN8W56rXb6xFpGmGumUs=" + "s/zg7van3BR5U55FXJchQCZrA5IRA2mLAwVklF/lExM=" ], "unseal_keys_hex": [ - "a998aa8e5d3fafcce09e8094f23f6d76be5e37c5b9eab5dbeb11691a61ae994b" + "b3fce0eef6a7dc1479539e455c972140266b03921103698b030564945fe51313" ], "unseal_shares": 1, "unseal_threshold": 1, @@ -11,5 +11,5 @@ "recovery_keys_hex": [], "recovery_keys_shares": 0, "recovery_keys_threshold": 0, - "root_token": "hvs.SyXEwWlOzmBnQxe4xr6r337P" + "root_token": "hvs.p1rm1RK7193dXelo4q3wSjDu" } diff --git a/2023/day39/deployment-01-webapp.yml b/2023/day39/deployment-01-webapp.yml index b9703b1..c703f2d 100644 --- a/2023/day39/deployment-01-webapp.yml +++ b/2023/day39/deployment-01-webapp.yml @@ -3,13 +3,11 @@ apiVersion: v1 kind: ServiceAccount metadata: name: vault - namespace: webapp --- apiVersion: apps/v1 kind: Deployment metadata: name: webapp - namespace: webapp labels: app: webapp spec: diff --git a/2023/day39/devwebapp.yaml b/2023/day39/devwebapp.yaml new file mode 100644 index 0000000..1f09ae5 --- /dev/null +++ b/2023/day39/devwebapp.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + name: devwebapp + labels: + app: devwebapp + annotations: + vault.hashicorp.com/agent-inject: "true" + vault.hashicorp.com/role: "devweb-app" + vault.hashicorp.com/agent-inject-secret-credentials.txt: "secret/data/devwebapp/config" +spec: + serviceAccountName: internal-app + containers: + - name: devwebapp + image: jweissig/app:0.0.1