Skip to content

Commit c35f9e8

Browse files
committed
feat(contrib/azure): clean up Azure docs and scripts
1 parent ad85aba commit c35f9e8

3 files changed

Lines changed: 94 additions & 60 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ builder/image/bin/yaml2json-procfile
3434
cache/image/bin
3535
client/dist/
3636
client/makeself/
37+
contrib/azure/azure-user-data
3738
contrib/bumpver/bumpver
3839
deisctl/deisctl
3940
deisctl/dist/

contrib/azure/azure-coreos-cluster

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ if not args.ssh_cert and not args.ssh_thumb:
8585
# Setup custom data
8686
if args.custom_data:
8787
with open(args.custom_data, 'r') as f:
88-
cloud_init = f.read()
88+
if not os.path.exists(args.custom_data):
89+
print "Couldn't find the user-data file. Did you remember to run `create-azure-user-data`?"
90+
sys.exit(1)
91+
cloud_init = f.read()
8992
f.closed
9093
else:
9194
if args.discovery_service_url:
@@ -101,7 +104,7 @@ with open(args.ssh_cert) as f:
101104
service_cert_file_data = base64.b64encode(f.read())
102105
f.closed
103106

104-
def wait_for_async(request_id, operation_name, timeout):
107+
def wait_for_async(request_id, timeout):
105108
count = 0
106109
result = sms.get_operation_status(request_id)
107110
while result.status == 'InProgress':
@@ -110,14 +113,13 @@ def wait_for_async(request_id, operation_name, timeout):
110113
print('Timed out waiting for async operation to complete.')
111114
return
112115
time.sleep(5)
113-
print('.')
116+
print('.'),
117+
sys.stdout.flush()
114118
result = sms.get_operation_status(request_id)
115-
print(vars(result))
116119
if result.error:
117120
print(result.error.code)
118121
print(vars(result.error))
119-
print(result.status)
120-
print(operation_name + ' took:' + str(count*5) + 's')
122+
print result.status + ' in ' + str(count*5) + 's'
121123

122124
def linux_config(hostname, args):
123125
pk = PublicKey(args.ssh_thumb,
@@ -163,15 +165,24 @@ def data_hd(target_container_url, target_blob_name, target_lun, target_disk_size
163165
sms = ServiceManagementService(args.subscription, args.azure_cert)
164166

165167
#Create the cloud service
166-
sms.create_hosted_service(
167-
args.cloud_service_name, label=args.cloud_service_name, location=args.location)
168-
print('created service ' + args.cloud_service_name)
169-
time.sleep(2)
168+
try:
169+
print 'Creating the hosted service...',
170+
sys.stdout.flush()
171+
sms.create_hosted_service(
172+
args.cloud_service_name, label=args.cloud_service_name, location=args.location)
173+
print('Successfully created hosted service ' + args.cloud_service_name)
174+
sys.stdout.flush()
175+
time.sleep(2)
176+
except WindowsAzureConflictError:
177+
print "Hosted service {} already exists. Delete it or try again with a different name.".format(args.cloud_service_name)
178+
sys.exit(1)
170179

171180
#upload ssh cert to cloud-service
181+
print 'Uploading SSH certificate...',
182+
sys.stdout.flush()
172183
result = sms.add_service_certificate(args.cloud_service_name,
173184
service_cert_file_data, SERVICE_CERT_FORMAT, '')
174-
wait_for_async(result.request_id, 'upload cert', 15)
185+
wait_for_async(result.request_id, 15)
175186

176187
def get_vm_name(args, i):
177188
return args.cloud_service_name + '-' + args.vm_name_prefix + '-' + str(i)
@@ -199,19 +210,31 @@ for i in range(args.num_nodes):
199210
else:
200211
data_disks = None
201212

202-
if i == 0:
203-
result = sms.create_virtual_machine_deployment(
204-
args.cloud_service_name, deployment_name=args.cloud_service_name,
205-
deployment_slot='production', label=vm_name,
206-
role_name=vm_name, system_config=system, os_virtual_hard_disk=os_hd,
207-
role_size=args.vm_size, network_config=network, data_virtual_hard_disks=data_disks)
208-
else:
209-
result = sms.add_role(
210-
args.cloud_service_name, deployment_name=args.cloud_service_name,
211-
role_name=vm_name,
212-
system_config=system, os_virtual_hard_disk=os_hd,
213-
role_size=args.vm_size, network_config=network, data_virtual_hard_disks=data_disks)
214-
wait_for_async(result.request_id, 'create VM' + vm_name, 30)
213+
try:
214+
if i == 0:
215+
result = sms.create_virtual_machine_deployment(
216+
args.cloud_service_name, deployment_name=args.cloud_service_name,
217+
deployment_slot='production', label=vm_name,
218+
role_name=vm_name, system_config=system, os_virtual_hard_disk=os_hd,
219+
role_size=args.vm_size, network_config=network, data_virtual_hard_disks=data_disks)
220+
else:
221+
result = sms.add_role(
222+
args.cloud_service_name, deployment_name=args.cloud_service_name,
223+
role_name=vm_name,
224+
system_config=system, os_virtual_hard_disk=os_hd,
225+
role_size=args.vm_size, network_config=network, data_virtual_hard_disks=data_disks)
226+
except WindowsAzureError as e:
227+
if "Forbidden" in str(e):
228+
print "Unable to use this CoreOS image. This usually means a newer image has been published."
229+
print "See https://coreos.com/docs/running-coreos/cloud-providers/azure/ for the latest stable image,"
230+
print "and supply it to this script with --coreos-image. If it works, please open a pull request to update this script."
231+
sys.exit(1)
232+
else:
233+
pass
234+
235+
print 'Creating VM ' + vm_name + '...',
236+
sys.stdout.flush()
237+
wait_for_async(result.request_id, 30)
215238
vms.append({'name':vm_name,
216239
'host':args.cloud_service_name + '.cloudapp.net',
217240
'port':ssh_port,
@@ -229,18 +252,30 @@ def get_ips(service_name, deployment_name):
229252
if args.pip:
230253
ips = []
231254
ips = get_ips(args.cloud_service_name, args.cloud_service_name)
232-
print 'dns file ----'
255+
print ''
256+
print '-------'
257+
print "You'll need to configure DNS records for a domain you wish to use with your Deis cluster."
258+
print 'For convenience, the public IP addresses are printed below, along with sane DNS timeouts.'
259+
print ''
233260
for ip in ips:
234261
print '@ 10800 IN A ' + ip
235262
print '* 10800 IN CNAME @'
236-
print 'end dns file ----'
263+
print '-------'
264+
print 'For more information, see: http://docs.deis.io/en/latest/managing_deis/configure-dns/'
265+
print ''
237266

238267
#print ~/.ssh/config
239-
print '~/.ssh/config ----'
268+
print ''
269+
print '-------'
270+
print "Instances on Azure don't use typical SSH ports. It is recommended to configure ~/.ssh/config"
271+
print 'so the instances can easily be referenced when logging in via SSH. For convenience, the config'
272+
print 'directives for your instances are below:'
273+
print ''
240274
for vm in vms:
241275
print 'Host ' + vm['name']
242276
print ' HostName ' + vm['host']
243277
print ' Port ' + str(vm['port'])
244278
print ' User ' + vm['user']
245279
print ' IdentityFile ' + vm['identity']
246-
print 'end ~/.ssh/config ----'
280+
print '-------'
281+
print ''

docs/installing_deis/azure.rst

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,29 @@ Microsoft Azure
88

99
This section will show you how to create a 3-node Deis cluster on Microsoft Azure.
1010

11-
Before you start, :ref:`get the Deis source <get_the_source>` and change directory into `contrib/azure`_ while following this documentation.
11+
Before you start, :ref:`get the Deis source <get_the_source>` and change directory into `contrib/azure`_
12+
while following this documentation.
1213

1314

1415
Install Python and Azure SDK for Python
1516
---------------------------------------
1617

17-
The cluster creation tool uses Python and the Python Azure library to create a CoreOS cluster. If you haven't already, install these on your development machine:
18+
The cluster creation tool uses Python and the Python Azure library to create a CoreOS cluster.
19+
If you haven't already, install these on your development machine:
1820

1921
.. code-block:: console
2022
2123
$ brew install python
22-
...
23-
24-
$ sudo pip install azure
25-
...
26-
27-
28-
And check to make sure they are configured correctly:
29-
30-
.. code-block:: console
31-
32-
$ python -c "import azure; print(azure.__version__)"
33-
0.9.0 <-- everything working ok!
24+
$ sudo pip install azure pyyaml
3425
3526
Generate Certificates
3627
---------------------
3728

38-
The azure-coreos-cluster creation tool uses the Azure management REST API to create the CoreOS cluster which uses a management certificate to authenticate.
29+
The azure-coreos-cluster creation tool uses the Azure management REST API to create the CoreOS
30+
cluster which uses a management certificate to authenticate.
3931

40-
If you don't have a management certificate already configured, the script generate-mgmt-cert.sh can create this certificate for you. Otherwise, you can skip to the next section.
32+
If you don't have a management certificate already configured, the script generate-mgmt-cert.sh can
33+
create this certificate for you. Otherwise, you can skip to the next section.
4134

4235
If you need to create a certificate, edit cert.conf in contrib/azure with your company's details and then run:
4336

@@ -48,48 +41,58 @@ If you need to create a certificate, edit cert.conf in contrib/azure with your c
4841
Upload Management Cert
4942
----------------------
5043

51-
If you haven't uploaded your management certificate to Azure (azure-cert.cer if you used the script in the previous section), do that now using the `management certificates tab`_ of the Azure portal's Settings.
44+
If you haven't uploaded your management certificate to Azure (azure-cert.cer if you used the script
45+
in the previous section), do that now using the `management certificates tab`_ of the
46+
Azure portal's Settings.
5247

5348
Also copy the Azure subscription id from this table and save it for the cluster creation script below.
5449

5550
Create Cluster Cloud Config
5651
---------------------------
5752

58-
Before we can create a cluster, we need to create a cloud config for it. The script create-azure-user-data does this for you. This script takes the stock cluster instance config in ../coreos/user-data.example and customizes it for Azure and inserts a unique cluster discovery url:
53+
Before we can create a cluster, we need to create a cloud config for it. The script
54+
``create-azure-user-data`` does this for you. This script takes the stock cluster instance config
55+
in ``../coreos/user-data.example``, customizes it for Azure, and inserts a unique cluster discovery
56+
endpoint:
5957

6058
.. code-block:: console
6159
6260
$ ./create-azure-user-data $(curl -s https://discovery.etcd.io/new)
6361
64-
This will create a azure-user-data cloud config file. We'll use this with the script in the next section during cluster creation.
62+
This will create a azure-user-data cloud config file. We'll use this with the script in the next
63+
section during cluster creation.
6564

6665
Create CoreOS Cluster
6766
---------------------
6867

6968
With the management certificate and cloud config in place, we are ready to create our cluster.
7069

71-
* Create a container called 'vhds' within a storage account in the same region as your cluster using the Azure portal. Note the URL of the container for the cluster creation script below.
70+
* Create a container called ``vhds`` within a storage account in the same region as your cluster using the Azure portal. Note the URL of the container for the cluster creation script below.
7271
* Choose a cloud service name for your Deis cluster for the script below. The script will automatically create this cloud service for you.
72+
* Choose an Azure `region`_ to use. Supply it in quotes with the ``--location`` parameter. The default is "West US".
7373

7474
With that, let's run the azure-coreos-cluster script which will create the CoreOS cluster. Fill in the bracketed values with the values for your deployment you created above.
7575

7676
.. code-block:: console
7777
7878
$ ./azure-coreos-cluster [cloud service name]
7979
--subscription [subscription id]
80-
--azure-cert azure-cert.pem
80+
--azure-cert azure-cert.pem
8181
--num-nodes 3
82-
--location "West US"
83-
--vm-size Large
82+
--location "[location]"
83+
--vm-size Large
8484
--pip
8585
--deis
8686
--blob-container-url https://[blob container].blob.core.windows.net/vhds/
8787
--data-disk
8888
--custom-data azure-user-data
8989
90-
This script will by default provision a 3 node cluster but you can increase this with the --num-nodes parameter. Likewise, you can increase the vm size using the --vm-size. It is not recommended that you use smaller than Large (A3) sized instances.
90+
This script will by default provision a 3 node cluster but you can increase this with the
91+
``--num-nodes`` parameter. Likewise, you can increase the VM size using ``--vm-size``.
92+
It is not recommended that you use smaller than Large (A3) sized instances.
9193

92-
Note that for scheduling to work properly, clusters must consist of at least 3 nodes and always have an odd number of members. For more information, see `optimal etcd cluster size`_.
94+
Note that for scheduling to work properly, clusters must consist of at least 3 nodes and always
95+
have an odd number of members. For more information, see `etcd disaster recovery`_.
9396

9497

9598
Configure DNS
@@ -104,13 +107,8 @@ Install Deis Platform
104107
Now that you've finished provisioning a cluster, please refer to :ref:`install_deis_platform` to
105108
start installing the platform.
106109

107-
IMPORTANT NOTE: Once you have installed deisctl, you will need to use a customized deis-builder component for Azure since Azure uses routable IP addresses for each instance. Configure this using the following command before you run 'deisctl install platform':
108-
109-
.. code-block:: console
110-
111-
$ deisctl config builder set image=deis/builder:v1.1.1-azure
112-
113110
.. _`management certificates tab`: https://manage.windowsazure.com/#Workspaces/AdminTasks/ListManagementCertificates
114111
.. _`contrib/azure`: https://github.com/deis/deis/tree/master/contrib/azure
115112
.. _`etcd`: https://github.com/coreos/etcd
116-
.. _`optimal etcd cluster size`: https://github.com/coreos/etcd/blob/master/Documentation/optimal-cluster-size.md
113+
.. _`etcd disaster recovery`: https://github.com/coreos/etcd/blob/master/Documentation/admin_guide.md#disaster-recovery
114+
.. _`region`: http://azure.microsoft.com/en-us/regions/

0 commit comments

Comments
 (0)