3
3
# Global variables
4
4
5
5
```
6
- export suffix =$(echo $RANDOM)
7
- export AKS_GRP=aks-grp-$suffix
8
- export AZ_KV_GRP=kv-grp-$suffix
6
+ export SUFFIX =$(echo $RANDOM)
7
+ export AKS_GRP=aks-grp-$SUFFIX
8
+ export AZ_KV_GRP=kv-grp-$SUFFIX
9
9
export LOC=westeurope
10
- export AKS_NAME=aks-$suffix
11
- export AZ_KV_NAME=kv-$suffix
12
- export SP_NAME=az-aks-kv-sp-$suffix
10
+ export AKS_NAME=aks-$SUFFIX
11
+ export AZ_KV_NAME=kv-$SUFFIX
12
+ export SP_NAME=az-aks-kv-sp-$SUFFIX
13
+ export CSI_STORAGE_CLASS_NAME=nginx-csi-storage-class
13
14
export SP_AKS_SECRET=secrets-store-creds
14
15
export CSI_NAMESPACE=azure-cs-driver
15
16
export TENANTID=$(echo $(az account show) | jq -r '.tenantId')
@@ -30,13 +31,13 @@ export SP_CLIENT_SECRET=$(echo $SPObj | jq -r '.password')
30
31
31
32
# Aks Group create
32
33
```
33
- $ az group create -n $AKS_GRP -l $LOC
34
+ az group create -n $AKS_GRP -l $LOC --tags label=$SUFFIX
34
35
```
35
36
36
37
# Aks Cluster create
37
38
38
39
```
39
- $ az aks create -n $AKS_NAME -g $AKS_GRP --node-count 2 --network-plugin azure --generate-ssh-keys
40
+ az aks create -n $AKS_NAME -g $AKS_GRP --node-count 2 --network-plugin azure --generate-ssh-keys
40
41
```
41
42
42
43
# Get AKS credentials to work with kubectl
@@ -55,17 +56,11 @@ kubectl get nodes -o wide
55
56
kubectl create ns $CSI_NAMESPACE
56
57
```
57
58
58
- # Helm repo add for csi-secrets-store-driver (optional)
59
- ```
60
- $ helm repo add secrets-store-csi-driver https://raw.githubusercontent.com/kubernetes-sigs/secrets-store-csi-driver/master/charts
61
- $ helm install -n $CSI_NAMESPACE csi-secrets-store secrets-store-csi-driver/secrets-store-csi-driver
62
- ```
63
-
64
59
# Helm repo for cs-secret-store-driver-azure-provider.
65
60
*** This helm repo provide both the csi-secrets-store-driver as well as csi-secrets-store-driver-azure-provider as well***
66
61
```
67
- $ helm repo add csi-secrets-store-provider-azure https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/charts
68
- $ helm install -n $CSI_NAMESPACE csi-secrets-store-provider-azure/csi-secrets-store-provider-azure --generate-name
62
+ helm repo add csi-secrets-store-provider-azure https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/charts
63
+ helm install -n $CSI_NAMESPACE csi-secrets-store-provider-azure/csi-secrets-store-provider-azure --generate-name
69
64
```
70
65
71
66
# Make sure azure CSI driver pods are running.
@@ -75,7 +70,7 @@ kubectl get all -n $CSI_NAMESPACE
75
70
76
71
# Create keyvault group
77
72
```
78
- az group create -n $AZ_KV_GRP -l $LOC
73
+ az group create -n $AZ_KV_GRP -l $LOC --tags label=$SUFFIX
79
74
```
80
75
81
76
# Create azure key vault
@@ -101,17 +96,23 @@ kubectl create secret generic $SP_AKS_SECRET --from-literal clientid=$SP_CLIENT_
101
96
102
97
# Populate all the respective details in storageproviderclass yaml file && run
103
98
```
104
- kubectl apply -f azure-kv-provider.yaml
99
+ envsubst < azure-kv-provider.yaml | kubectl apply -f -
105
100
```
106
101
107
102
# Lastly deploy a sample test nginx deployment to test
108
103
```
109
- kubectl apply -f nginx-deployment.yaml
104
+ envsubst < nginx-deployment.yaml | kubectl apply -f -
110
105
```
111
106
112
107
# wait for nginx pod to be up and running and then test the secrets are mounted or not
113
108
```
114
- kubectl exec nginx-app -- ls /mnt/secrets/DB_PASSWORD
109
+ kubectl exec nginx-app -- ls /mnt/secrets/
115
110
kubectl exec nginx-app -- cat /mnt/secrets/DB_PASSWORD
116
111
```
117
112
113
+ # Clean up resources
114
+
115
+ ```
116
+ az ad sp delete --id $SP_CLIENT_ID
117
+ for rg in $(az group list --tag label=$SUFFIX --query '[].name' | jq -r '.[]'); do echo "Delete Resource Group: ${rg}"; az group delete -n ${rg}; done
118
+ ```
0 commit comments