Skip to content

Commit 28d4470

Browse files
committed
Feat(#646): updated centralized vault upgrade script, migrated GCP to k8s 1.25
1 parent 5f01a06 commit 28d4470

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

gcp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The bucket name should be in the output. Please use that to configure the Terraf
4949
6. Run `terraform plan`
5050
7. Run `terraform apply`. Note: the apply will take 10 to 20 minutes depending on the speed of the GCP backplane.
5151
8. Run `export USE_GKE_GCLOUD_AUTH_PLUGIN=True`
52-
9When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`. Note if it errors on a missing plugin to support `kubectl`, then run `gcloud components install gke-gcloud-auth-plugin` and `gcloud container clusters get-credentials wrongsecrets-exercise-cluster` .
52+
9. When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`. Note if it errors on a missing plugin to support `kubectl`, then run `gcloud components install gke-gcloud-auth-plugin` and `gcloud container clusters get-credentials wrongsecrets-exercise-cluster` .
5353
10. Run `./k8s-vault-gcp-start.sh`
5454

5555
### GKE ingres for shared deployment

gcp/k8s-vault-gcp-start.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ echo "This script is based on the steps defined in https://learn.hashicorp.com/t
1313
export GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
1414
#export USE_GKE_GCLOUD_AUTH_PLUGIN=True
1515

16+
echo "Setting up workspace PSA to restricted for default"
17+
kubectl apply -f ../k8s/workspace-psa.yml
18+
1619
kubectl get configmaps | grep 'secrets-file' &>/dev/null
1720
if [ $? == 0 ]; then
1821
echo "secrets config is already installed"

gcp/k8s/secret-challenge-vault-deployment.yml.tpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ spec:
6565
allowPrivilegeEscalation: false
6666
readOnlyRootFilesystem: true
6767
runAsNonRoot: true
68+
capabilities:
69+
drop:
70+
- ALL
71+
seccompProfile:
72+
type: RuntimeDefault
6873
resources:
6974
requests:
7075
memory: '512Mi'
@@ -93,8 +98,8 @@ spec:
9398
secretKeyRef:
9499
name: funnystuff
95100
key: funnier
96-
- name: VAULT_ADDR
97-
value: "http://vault:8200"
101+
- name: SPRING_CLOUD_VAULT_URI
102+
value: "http://vault.vault.svc.cluster.local:8200"
98103
- name: JWT_PATH
99104
value: "/var/run/secrets/kubernetes.io/serviceaccount/token"
100105
volumeMounts:

scripts/install-vault.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ if [ $? == 0 ]; then
44
else
55
helm repo add hashicorp https://helm.releases.hashicorp.com
66
helm repo update hashicorp
7+
fi
8+
9+
kubectl get ns | grep 'vault' $>/dev/null
10+
if [ $? == 0 ]; then
11+
echo "Vault ns is already there"
12+
else
713
kubectl create ns vault
814
helm upgrade --install vault hashicorp/vault --version 0.23.0 --namespace vault --values ../k8s/helm-vault-values.yml
915
fi
1016

17+
1118
isvaultrunning=$(kubectl get pods -n vault --field-selector=status.phase=Running)
1219
while [[ $isvaultrunning != *"vault-0"* ]]; do echo "waiting for Vault0" && sleep 2 && isvaultrunning=$(kubectl get pods -n vault --field-selector=status.phase=Running); done
1320
while [[ $isvaultrunning != *"vault-1"* ]]; do echo "waiting for Vault1" && sleep 2 && isvaultrunning=$(kubectl get pods -n vault --field-selector=status.phase=Running); done
@@ -25,7 +32,7 @@ echo "PLEASE COPY PASTE THE FOLLOWING VALUE: $VAULT_UNSEAL_KEY, you will be aske
2532

2633
kubectl exec -it vault-0 -n vault -- vault operator unseal $VAULT_UNSEAL_KEY
2734
kubectl exec -it vault-1 -n vault -- vault operator unseal $VAULT_UNSEAL_KEY
28-
kubectl exec -it vault-2 -n vault -- vault operator unseal $VAULT_UNSEAL_KEY
35+
kubectl exec -it vault-2 -n vault -- vault operator unseal $VAULT_UNSEAL_KEY
2936

3037
echo "Obtaining root token"
3138
jq .root_token cluster-keys.json >commentedroottoken
@@ -70,3 +77,5 @@ kubectl exec vault-0 -n vault -- vault write auth/kubernetes/role/secret-challen
7077
ttl=24h &&
7178
vault kv put secret/secret-challenge vaultpassword.password="$(openssl rand -base64 16)" &&
7279
vault kv put secret/application vaultpassword.password="$(openssl rand -base64 16)"
80+
81+
kubectl create serviceaccount vault

0 commit comments

Comments
 (0)