forked from cyz/Maratona-Kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2. container-services.sh
59 lines (41 loc) · 1.59 KB
/
2. container-services.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
RESOURCE=k8s-course-1
ACR=k8scourse
REGISTRY=${ACR}.azurecr.io
MONGO_DNS=mongodb
APP_NAME=api-heroes
IMAGE_NAME=$REGISTRY/$APP_NAME
LOCATION=eastus
sudo az group create --name $RESOURCE --location $LOCATION
echo '--------------------CONTAINER REGISTRY------------------------------'
az acr create --resource-group $RESOURCE --name $ACR --sku Basic --admin-enabled true
az acr login --name $ACR
#sudo docker tag api $IMAGE_NAME
sudo docker push $IMAGE_NAME
echo '--------------------CONTAINER SERVICES------------------------------'
echo 'creating mongodb'
az container create --resource-group $RESOURCE\
--name $MONGO_DNS --image mongo:3.5 \
--cpu 1 --memory 1 \
--port 27017 \
--ip-address public
az acr update -n $ACR --admin-enabled true
echo 'getting acr pass'
ACR_PASS=$(az acr credential show -n $ACR --query passwords[0].value)
ACR_PASS="${ACR_PASS//\"}"
echo 'getting mongoDb IP'
MONGO_IP=$(az container show --resource-group $RESOURCE --name $MONGO_DNS --query ipAddress.ip)
MONGO_IP="${MONGO_IP//\"}"
echo 'creating application'
az container create --resource-group $RESOURCE\
--name $APP_NAME --image $IMAGE_NAME\
--cpu 1 --memory 1 \
--registry-username $ACR\
--registry-password $ACR_PASS \
--port 3000 \
--environment-variables MONGO_URL=$MONGO_IP\
--ip-address public
az container logs --resource-group $RESOURCE --name $APP_NAME
az container show --resource-group $RESOURCE --name $APP_NAME
az container delete --name $APP_NAME --resource-group $RESOURCE --yes
az container delete --name $MONGO_DNS --resource-group $RESOURCE --yes
az group delete -n $RESOURCE --yes