-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path03-deploy-yelb.sh
72 lines (63 loc) · 1.95 KB
/
03-deploy-yelb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Variables
source ./00-variables.sh
# Check if namespace exists in the cluster
result=$(kubectl get namespace -o jsonpath="{.items[?(@.metadata.name=='$NAMESPACE')].metadata.name}")
if [[ -n $result ]]; then
echo "$NAMESPACE namespace already exists in the cluster"
else
echo "$NAMESPACE namespace does not exist in the cluster"
echo "creating $NAMESPACE namespace in the cluster..."
kubectl create namespace $NAMESPACE
fi
# Create the Secret Provider Class object
echo "Creating the secret provider class object..."
cat <<EOF | kubectl apply -f -
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
namespace: $NAMESPACE
name: yelb
spec:
provider: azure
secretObjects:
- secretName: $TLS_SECRET_NAME
type: kubernetes.io/tls
data:
- objectName: $KEY_VAULT_CERTIFICATE_NAME
key: tls.key
- objectName: $KEY_VAULT_CERTIFICATE_NAME
key: tls.crt
parameters:
usePodIdentity: "false"
useVMManagedIdentity: "true"
userAssignedIdentityID: $KEY_VAULT_SECRET_PROVIDER_IDENTITY_CLIENT_ID
keyvaultName: $KEY_VAULT_NAME
objects: |
array:
- |
objectName: $KEY_VAULT_CERTIFICATE_NAME
objectType: secret
tenantId: $TENANT_ID
EOF
# Apply the YAML configuration
kubectl apply -f yelb.yml
echo "waiting for secret $TLS_SECRET_NAME in namespace $namespace..."
while true; do
if kubectl get secret -n $NAMESPACE $TLS_SECRET_NAME >/dev/null 2>&1; then
echo "secret $TLS_SECRET_NAME found!"
break
else
printf "."
sleep 3
fi
done
# Create chat-ingress
cat ingress.yml |
yq "(.spec.ingressClassName)|="\""$INGRESS_CLASS_NAME"\" |
yq "(.spec.tls[0].hosts[0])|="\""$SUBDOMAIN.$DNS_ZONE_NAME"\" |
yq "(.spec.tls[0].secretName)|="\""$TLS_SECRET_NAME"\" |
yq "(.spec.rules[0].host)|="\""$SUBDOMAIN.$DNS_ZONE_NAME"\" |
kubectl apply -f -
# Check the deployed resources within the yelb namespace:
kubectl get all -n yelb