From 2510f89863f2089f0646fa31c1662e53110eb353 Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Thu, 5 Mar 2015 14:38:06 +0000 Subject: [PATCH] Create Azure storage account if needed --- .../coreos/azure/create-kubernetes-cluster.js | 1 + .../coreos/azure/lib/azure_wrapper.js | 19 +++++++++++++++++++ .../coreos/azure/package.json | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/getting-started-guides/coreos/azure/create-kubernetes-cluster.js b/docs/getting-started-guides/coreos/azure/create-kubernetes-cluster.js index b9f19ddef4887..e05bbc061a89c 100755 --- a/docs/getting-started-guides/coreos/azure/create-kubernetes-cluster.js +++ b/docs/getting-started-guides/coreos/azure/create-kubernetes-cluster.js @@ -7,6 +7,7 @@ azure.create_config('kubernetes', { 'etcd': 3, 'kube': 3 }); azure.run_task_queue([ azure.queue_default_network(), + azure.queue_storage_if_needed(), azure.queue_machines('etcd', 'stable', kube.create_etcd_cloud_config), azure.queue_machines('kube', 'stable', diff --git a/docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js b/docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js index de39b74f1992c..c34a79b12bcdc 100644 --- a/docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js +++ b/docs/getting-started-guides/coreos/azure/lib/azure_wrapper.js @@ -161,6 +161,22 @@ exports.queue_default_network = function () { '--address-space=172.16.0.0', conf.resources['vnet'], ]); +} + +exports.queue_storage_if_needed = function() { + if (!process.env['AZURE_STORAGE_ACCOUNT']) { + conf.storage_account = util.rand_suffix; + task_queue.push([ + 'storage', 'account', 'create', + get_location(), + conf.storage_account, + ]); + process.env['AZURE_STORAGE_ACCOUNT'] = conf.storage_account; + } else { + // Preserve it for resizing, so we don't create a new one by accedent, + // when the environment variable is unset + conf.storage_account = process.env['AZURE_STORAGE_ACCOUNT']; + } }; exports.queue_machines = function (name_prefix, coreos_update_channel, cloud_config_creator) { @@ -232,6 +248,8 @@ exports.destroy_cluster = function (state_file) { task_queue.push(['network', 'vnet', 'delete', '--quiet', conf.resources['vnet']]); + // TODO: add storage deletion when AZURE_STORAGE_ACCOUNT is unset (depends on Azure/azure-xplat-cli#1615) + exports.run_task_queue(); }; @@ -247,4 +265,5 @@ exports.load_state_for_resizing = function (state_file, node_type, new_nodes) { conf.nodes[node_type] += new_nodes; hosts.collection = conf.hosts; hosts.ssh_port_counter += conf.hosts.length; + process.env['AZURE_STORAGE_ACCOUNT'] = conf.storage_account; } diff --git a/docs/getting-started-guides/coreos/azure/package.json b/docs/getting-started-guides/coreos/azure/package.json index 4e54ffe0a16f6..2644c5d17e265 100644 --- a/docs/getting-started-guides/coreos/azure/package.json +++ b/docs/getting-started-guides/coreos/azure/package.json @@ -9,7 +9,7 @@ "author": "Ilya Dmitrichenko ", "license": "Apache 2.0", "dependencies": { - "azure-cli": "^0.8.14", + "azure-cli": "^0.8.15", "colors": "^1.0.3", "js-yaml": "^3.2.5", "openssl-wrapper": "^0.2.1",