-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path01-deploy-resources.sh
More file actions
executable file
·61 lines (52 loc) · 1.87 KB
/
Copy path01-deploy-resources.sh
File metadata and controls
executable file
·61 lines (52 loc) · 1.87 KB
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
#!/bin/bash
# Variables
source ./00-variables.sh
# Change the current directory to the script's directory
cd "$CURRENT_DIR" || exit
# Create a resource group
echo "Checking if resource group [$RESOURCE_GROUP_NAME] exists in the subscription [$SUBSCRIPTION_NAME]..."
az group show --name $RESOURCE_GROUP_NAME &>/dev/null
if [[ $? != 0 ]]; then
echo "Creating resource group [$RESOURCE_GROUP_NAME]..."
az group create \
--name $RESOURCE_GROUP_NAME \
--location "$LOCATION" \
--only-show-errors 1>/dev/null
if [[ $? == 0 ]]; then
echo "Resource group [$RESOURCE_GROUP_NAME] created."
else
echo "Failed to create resource group [$RESOURCE_GROUP_NAME]."
exit 1
fi
else
echo "Resource group [$RESOURCE_GROUP_NAME] already exists."
fi
# Create the Azure Container Registry
echo "Checking if [$ACR_NAME] Azure Container Registry exists..."
az acr show \
--name "$ACR_NAME" \
--resource-group "$RESOURCE_GROUP_NAME" \
--only-show-errors &>/dev/null
if [[ $? != 0 ]]; then
echo "Creating Azure Container Registry [$ACR_NAME]..."
az acr create \
--name "$ACR_NAME" \
--resource-group "$RESOURCE_GROUP_NAME" \
--location "$LOCATION" \
--sku "$ACR_SKU" \
--admin-enabled "true" \
--only-show-errors 1>/dev/null
if [ $? -eq 0 ]; then
echo "Azure Container Registry [$ACR_NAME] created."
else
echo "Failed to create Azure Container Registry [$ACR_NAME]."
exit 1
fi
else
echo "[$ACR_NAME] Azure Container Registry already exists."
fi
# The PostgreSQL database now runs in-cluster as a StatefulSet (statefulset.yml). Both the StatefulSet and
# the test data are handled by 05-deploy-app.sh, which waits for the primary and seeds the activities table.
# No Azure managed PostgreSQL resource is created here.
echo "Resource group and Azure Container Registry are ready."
echo "Next: build (02) and push (04) the image, then deploy the app + in-cluster PostgreSQL and seed it (05)."