【发布时间】:2015-07-02 04:50:59
【问题描述】:
我正在尝试在同一个云服务中创建多个虚拟机(但在云服务中的独特部署中)。下面只生成一台名为 mycluster-master-3 的机器(给定 self.numMasters == 3)。换句话说,实际上只创建了最后一台机器,并且可以在 Azure 管理门户中看到。请注意,当我使用 self.numMasters == 3 执行此代码时没有错误:
for node in range(self.numMasters):
logger.info('Deploying virtual machine "%s"...' % (self.clusterName + '-master-' + str(node + 1)))
logger.info('Creating linuxConfig...')
linuxConfig = azure.servicemanagement.LinuxConfigurationSet(
host_name=self.clusterName + '-master-' + str(node + 1),
user_name='auser',
user_password='Auser123!',
disable_ssh_password_authentication=True
)
# Destination storage account container/blob where the VM disk
# will be created
media_link = 'https://xxxxxxx.blob.core.windows.net/xxxxxx/%s.vhd' % (self.clusterName + '-master-' + str(node + 1))
os_hd = azure.servicemanagement.OSVirtualHardDisk(image_name, media_link)
logger.info('Creating virtual machine deployment...')
self.sms.create_virtual_machine_deployment(
service_name=serviceName,
deployment_name=self.clusterName + '-master-' + str(node + 1),
label=self.clusterName + '-master-' + str(node + 1),
role_name=self.clusterName + '-master-' + str(node + 1),
system_config=linuxConfig,
os_virtual_hard_disk=os_hd,
role_size=self.instanceType,
deployment_slot='production'
)
我认为将我的所有虚拟机都放在一个云服务中可以让它们在内部相互通信,而不会暴露在我的其他云服务中的机器上。但显然,云服务为其中的虚拟机提供了一个公共 IP。也许这就是为什么只创建一个虚拟机的原因,尽管从概念上讲,我认为一个云服务可以有多个虚拟机实例。这让我很困惑。 所以现在我想我需要为集群中的每个 VM 实例提供一个云服务。这样,所有机器都将拥有一个公共 IP,并且可以通过 Internet 访问。我还需要将所有云服务放在一个虚拟网络中。这样,它们之间的流量将不会通过互联网路由。我的假设正确吗?有没有更好/其他方式来完成我想要的(一组机器安全快速地相互通信,但可以通过互联网进行 SSH。)
【问题讨论】: