зеркало из https://github.com/Azure/aztack.git
(terraform): build VM image from VHD blob and pass as module
This commit is contained in:
Родитель
13c4b98c2c
Коммит
19e5fd7830
|
@ -26,7 +26,7 @@ export CLUSTER_NAME ?= mycluster
|
|||
|
||||
export AZURE_VM_KEY_NAME ?= acstack-$(CLUSTER_NAME)
|
||||
export AZURE_VM_KEY_PATH := ${DIR_KEY_PAIR}/${AZURE_VM_KEY_NAME}.pem
|
||||
export AZURE_IMAGE_NAME ?= acstack-ubuntu-17.10-1522339580
|
||||
export AZURE_VHD_URI ?= https://acstackimages.blob.core.windows.net/system/Microsoft.Compute/Images/acs-vhds/acstack-1522124889-osDisk.8d0e099c-0ed0-483e-9d53-053057eb13b0.vhd
|
||||
export INTERNAL_TLD := ${CLUSTER_NAME}.acs
|
||||
|
||||
export HYPERKUBE_IMAGE ?= quay.io/coreos/hyperkube
|
||||
|
|
|
@ -26,7 +26,7 @@ variable "node_count" {
|
|||
}
|
||||
|
||||
variable "name" {}
|
||||
variable "azure_image_name" {}
|
||||
variable "azure_vhd_uri" {}
|
||||
|
||||
variable "cidr" {
|
||||
default = {
|
||||
|
|
|
@ -44,18 +44,28 @@ module "dns" {
|
|||
name = "${ var.name }"
|
||||
}
|
||||
|
||||
module "bastion" {
|
||||
source = "./modules/bastion"
|
||||
depends-id = "${ module.vnet.depends-id }"
|
||||
module "image" {
|
||||
source = "./modules/image"
|
||||
depends-id = "${ module.rg.depends-id }"
|
||||
|
||||
# variables
|
||||
name = "${ var.name }"
|
||||
azure_image_name = "${ var.azure_image_name }"
|
||||
location = "${ var.location }"
|
||||
name = "${ var.name }"
|
||||
location = "${ var.location }"
|
||||
azure_vhd_uri = "${ var.azure_vhd_uri }"
|
||||
}
|
||||
|
||||
module "bastion" {
|
||||
source = "./modules/bastion"
|
||||
depends-id = "${ module.image.depends-id }"
|
||||
|
||||
# variables
|
||||
name = "${ var.name }"
|
||||
location = "${ var.location }"
|
||||
|
||||
# modules
|
||||
private-subnet-id = "${ module.vnet.private-subnet-id }"
|
||||
storage_endpoint = "${ module.storage_account.primary_blob_endpoint }"
|
||||
image_id = "${ module.image.image_id }"
|
||||
}
|
||||
|
||||
module "master" {
|
||||
|
@ -63,15 +73,14 @@ module "master" {
|
|||
depends-id = "${ module.bastion.depends-id }"
|
||||
|
||||
# variables
|
||||
name = "${ var.name }"
|
||||
azure_image_name = "${ var.azure_image_name }"
|
||||
location = "${ var.location }"
|
||||
instances = "${ length( split(",", var.etcd-ips) ) }"
|
||||
etcd-ips = "${ var.etcd-ips }"
|
||||
name = "${ var.name }"
|
||||
location = "${ var.location }"
|
||||
etcd-ips = "${ var.etcd-ips }"
|
||||
|
||||
# modules
|
||||
private-subnet-id = "${ module.vnet.private-subnet-id }"
|
||||
storage_endpoint = "${ module.storage_account.primary_blob_endpoint }"
|
||||
image_id = "${ module.image.image_id }"
|
||||
}
|
||||
|
||||
module "node" {
|
||||
|
@ -79,14 +88,14 @@ module "node" {
|
|||
depends-id = "${ module.bastion.depends-id }"
|
||||
|
||||
# variables
|
||||
name = "${ var.name }"
|
||||
azure_image_name = "${ var.azure_image_name }"
|
||||
location = "${ var.location }"
|
||||
node_count = "${ var.node_count }"
|
||||
etcd-ips = "${ var.etcd-ips }"
|
||||
name = "${ var.name }"
|
||||
location = "${ var.location }"
|
||||
node_count = "${ var.node_count }"
|
||||
etcd-ips = "${ var.etcd-ips }"
|
||||
|
||||
# modules
|
||||
private-subnet-id = "${ module.vnet.private-subnet-id }"
|
||||
bastion-ip = "${ module.bastion.public-ip }"
|
||||
storage_endpoint = "${ module.storage_account.primary_blob_endpoint }"
|
||||
image_id = "${ module.image.image_id }"
|
||||
}
|
||||
|
|
|
@ -2,11 +2,6 @@ data "azurerm_resource_group" "image" {
|
|||
name = "ACStackImages"
|
||||
}
|
||||
|
||||
data "azurerm_image" "image" {
|
||||
name = "${ var.azure_image_name }"
|
||||
resource_group_name = "${data.azurerm_resource_group.image.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "bastion" {
|
||||
name = "bastion"
|
||||
location = "${ var.location }"
|
||||
|
@ -45,7 +40,7 @@ resource "azurerm_virtual_machine" "bastion" {
|
|||
delete_data_disks_on_termination = true
|
||||
|
||||
storage_image_reference {
|
||||
id = "${data.azurerm_image.image.id}"
|
||||
id = "${ var.image_id }"
|
||||
}
|
||||
|
||||
storage_os_disk {
|
||||
|
|
|
@ -3,7 +3,7 @@ variable "location" {}
|
|||
variable "private-subnet-id" {}
|
||||
variable "depends-id" {}
|
||||
variable "storage_endpoint" {}
|
||||
variable "azure_image_name" {}
|
||||
variable "image_id" {}
|
||||
|
||||
output "depends-id" {
|
||||
value = "${null_resource.dummy_dependency.id}"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
resource "azurerm_image" "acs" {
|
||||
name = "${ var.name }"
|
||||
location = "${ var.location }"
|
||||
resource_group_name = "${ var.name }"
|
||||
|
||||
os_disk {
|
||||
os_type = "Linux"
|
||||
os_state = "Generalized"
|
||||
blob_uri = "${ var.azure_vhd_uri }"
|
||||
size_gb = 30
|
||||
}
|
||||
}
|
||||
|
||||
resource "null_resource" "dummy_dependency" {
|
||||
depends_on = [
|
||||
"azurerm_image.acs",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
variable "name" {}
|
||||
variable "location" {}
|
||||
variable "depends-id" {}
|
||||
variable "azure_vhd_uri" {}
|
||||
|
||||
output "depends-id" {
|
||||
value = "${null_resource.dummy_dependency.id}"
|
||||
}
|
||||
|
||||
output "image_id" {
|
||||
value = "${ azurerm_image.acs.id }"
|
||||
}
|
|
@ -7,10 +7,9 @@ variable "etcd-ips" {}
|
|||
variable "name" {}
|
||||
variable "location" {}
|
||||
variable "private-subnet-id" {}
|
||||
variable "instances" {}
|
||||
variable "depends-id" {}
|
||||
variable "storage_endpoint" {}
|
||||
variable "azure_image_name" {}
|
||||
variable "image_id" {}
|
||||
|
||||
output "depends-id" {
|
||||
value = "${null_resource.dummy_dependency.id}"
|
||||
|
|
|
@ -2,11 +2,6 @@ data "azurerm_resource_group" "image" {
|
|||
name = "ACStackImages"
|
||||
}
|
||||
|
||||
data "azurerm_image" "image" {
|
||||
name = "${ var.azure_image_name }"
|
||||
resource_group_name = "${data.azurerm_resource_group.image.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_network_interface" "master" {
|
||||
name = "master${ count.index + 1 }"
|
||||
location = "${ var.location }"
|
||||
|
@ -38,7 +33,7 @@ resource "azurerm_virtual_machine" "master" {
|
|||
delete_data_disks_on_termination = true
|
||||
|
||||
storage_image_reference {
|
||||
id = "${data.azurerm_image.image.id}"
|
||||
id = "${ var.image_id }"
|
||||
}
|
||||
|
||||
storage_os_disk {
|
||||
|
|
|
@ -11,7 +11,7 @@ variable "node_count" {}
|
|||
variable "depends-id" {}
|
||||
variable "bastion-ip" {}
|
||||
variable "storage_endpoint" {}
|
||||
variable "azure_image_name" {}
|
||||
variable "image_id" {}
|
||||
|
||||
output "depends-id" {
|
||||
value = "${null_resource.dummy_dependency.id}"
|
||||
|
|
|
@ -2,11 +2,6 @@ data "azurerm_resource_group" "image" {
|
|||
name = "ACStackImages"
|
||||
}
|
||||
|
||||
data "azurerm_image" "image" {
|
||||
name = "${ var.azure_image_name }"
|
||||
resource_group_name = "${data.azurerm_resource_group.image.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_network_interface" "node" {
|
||||
name = "node${ count.index + 1 }"
|
||||
location = "${ var.location }"
|
||||
|
@ -37,7 +32,7 @@ resource "azurerm_virtual_machine" "node" {
|
|||
delete_data_disks_on_termination = true
|
||||
|
||||
storage_image_reference {
|
||||
id = "${data.azurerm_image.image.id}"
|
||||
id = "${ var.image_id }"
|
||||
}
|
||||
|
||||
storage_os_disk {
|
||||
|
|
|
@ -6,7 +6,7 @@ set -x
|
|||
|
||||
echo $AZURE_LOCATION
|
||||
echo $AZURE_VM_KEY_NAME
|
||||
echo $AZURE_IMAGE_NAME
|
||||
echo $AZURE_VHD_URI
|
||||
echo $INTERNAL_TLD
|
||||
echo $CLUSTER_NAME
|
||||
CIDR_ALLOW_SSH=`$CDIR/myip`
|
||||
|
@ -48,7 +48,7 @@ dns-service-ip = "${K8S_DNS_IP}"
|
|||
internal-tld = "${INTERNAL_TLD}"
|
||||
k8s-service-ip = "${K8S_SERVICE_IP}"
|
||||
name = "${CLUSTER_NAME}"
|
||||
azure_image_name = "${AZURE_IMAGE_NAME}"
|
||||
azure_vhd_uri = "${AZURE_VHD_URI}"
|
||||
pki-ip = "${PKI_IP}"
|
||||
etcd-ips = "$ETCD_IPS"
|
||||
EOF
|
||||
|
|
Загрузка…
Ссылка в новой задаче