You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will now have to authenticate and login using `vault login` and provide the token we discovered with root_token in a previous step.
135
-
136
134

137
135
138
-
We will now run the following commands the first will enable the secret engine and the second will create secret at the path.
139
-
140
-
```
141
-
vault secrets enable -path=secret kv-v2
142
-
143
-
vault kv put secret/webapp/config username="static-user" password="static-password"
144
-
```
145
136
146
-
You can then verify with the following command
137
+
`vault secrets enable -path=secret kv-v2`
147
138
148
-
`vault kv get secret/webapp/config`
149
139
150
-
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.
140
+
`vault kv put secret/devwebapp/config username='giraffe' password='salsa'`
151
141
152
-
You should still be in your vault-0 pod. We are going to enable the Kubernetes authentication method with the following command:
142
+
`vault kv get secret/devwebapp/config`
153
143
154
144
`vault auth enable kubernetes`
155
145
156
-
***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.***
157
-
158
-
Next we need to configure the Kubernetes authentication method to use the location of the Kubernetes API.
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.
168
-
169
150
```
170
-
vault policy write webapp - <<EOF
171
-
path "secret/data/webapp/config" {
151
+
vault policy write devwebapp - <<EOF
152
+
path "secret/data/devwebapp/config" {
172
153
capabilities = ["read"]
173
154
}
174
155
EOF
175
156
```
176
157
177
-
Our Application shortly will be defined as webapp
178
-
179
-
With the following command we will create a kubernetes authentication role
180
-
181
158
```
182
-
vault write auth/kubernetes/role/webapp \
183
-
bound_service_account_names=vault \
184
-
bound_service_account_namespaces=webapp \
185
-
policies=webapp \
159
+
vault write auth/kubernetes/role/devweb-app \
160
+
bound_service_account_names=internal-app \
161
+
bound_service_account_namespaces=default \
162
+
policies=devwebapp \
186
163
ttl=24h
187
164
```
188
165
189
-
now `exit` from the vault-0 pod and back to the local machine.
166
+
`exit`
190
167
191
-
## Deploying our Application
168
+
`kubectl create ns webdevapp`
192
169
193
-
I am again going to be using the web app that is used in the HashiCorp tutorial mentioned earlier.
194
-
195
-
We will create a deployment yaml that looks like the following.
I also want to note that the helm chart for vault will deploy
243
-
244
-
You can check that the authentication has worked by checking pods in the webapp namespace, if they are not in a running state or not there at all then something is not right as this is communicating with vault to make sure that this service is running.
245
-
246
-
Once the pod is running, we need to port forward our webapp
0 commit comments