-
Notifications
You must be signed in to change notification settings - Fork 0
/
acs_deploy.sh
executable file
·72 lines (60 loc) · 2.5 KB
/
acs_deploy.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
# You need to have already created an SPN to use this script in a non-interactive session. See local_scripts/create_serviceprincipal.md for more info.
echo "Reloading bashrc profile..."
. ~/.bashrc
echo "Successfully reloaded bashrc profile..."
# Read User Input to capture variables needed for deployment
echo "This script will deploy a Docker Swarm Cluster for Azure Container Service to Microsoft Azure."
echo
echo "Enter a name for your Resource Group and press [ENTER]: "
read Resource
echo "The Resource Group Name you entered is $Resource."
echo "Enter a location for your deployment and press [ENTER]: "
read Location
echo "The Location you entered is $Location."
echo "Enter a Servicename for your Docker Swarm Cluster and press [ENTER]: "
read Servicename
echo "The service name you entered is $Servicename."
echo "Enter a DNS prefix for your DNS and press [ENTER]: "
read Dnsprefix
echo "The DNS prefix you entered is $Dnsprefix."
echo
echo "Thank you for your input. Now proceeding with ACS Swarm Deployment..."
#login
az login \
--service-principal \
-u $spn \
-p $password \
--tenant $tenant
# Group creation
az group create \
-l $Location \
-n $Resource
echo "Created Resource Group:" $Resource
echo "Beginning Azure Container Service creation now. Please note this can take more than 20 minutes to complete."
# ACS Creation for Docker Swarm
az acs create \
-g $Resource \
-n $Servicename \
-d $Dnsprefix \
--orchestrator-type Swarm \
--generate-ssh-keys \
--verbose
# Space for readabilty
echo
# Outputs
# Code to capture ACS master info
master_fqdn=$(az acs show -n $Servicename -g $Resource | jq -r '.masterProfile | .fqdn')
# Code to capture ACS agents info
agents_fqdn=$(az acs show -n $Servicename -g $Resource | jq -r '.agentPoolProfiles[0].fqdn')
# Set ssh connection string addt'l info
admin_username=$(az acs show -n $Servicename -g $Resource | jq -r '.linuxProfile.adminUsername')
# Print results
echo "------------------------------------------------------------------"
echo "Important information:"
echo
echo "SSH Connection String: ssh $admin_username@$master_fqdn -A -p 2200"
echo "Master FQDN: $master_fqdn"
echo "Agents FQDN: $agents_fqdn"
echo "Your web applications can be viewed at $agents_fqdn."
echo "------------------------------------------------------------------"