gpt4 book ai didi

azure - 如何将 Azure 多实例容器连接到 Azure 虚拟网络

转载 作者:行者123 更新时间:2023-12-03 07:02:45 25 4
gpt4 key购买 nike

情况:我创建了一个 azure 资源。它有一个容器注册表、带防火墙的虚拟网络。

问题:创建单个容器实例时,您可以指定虚拟网络,以便将防火墙规则、公共(public)静态 IP 和所有网络设置附加到容器。但是,在部署多容器实例时,只能在 azure 上下文上使用带有 docker compose 的命令来完成。

问题:我想知道如何将多容器实例链接到虚拟网络?

最佳答案

若要在 Azure CLI 中使用 az container create 命令部署多容器组,必须在 YAML 文件中指定容器组配置。然后将 YAML 文件作为参数传递给命令。

此 YAML 文件定义了一个名为“myContainerGroup”的容器组,其中包含两个容器、一个私有(private) IP 地址和两个公开端口。这些容器是从公共(public) Microsoft 镜像部署的。该组中的第一个容器运行一个面向互联网的 Web 应用程序。第二个容器(sidecar)定期通过容器组的本地网络向第一个容器中运行的 Web 应用程序发出 HTTP 请求。

您需要子网委托(delegate)权限,即 Microsoft.ContainerInstance/containerGroups。在您现有的 Vnet 子网中

enter image description here

yaml代码

apiVersion: '2021-07-01'
location: westus2
name: myContainerGroup
properties:
containers:
- name: aci-tutorial-app
properties:
image: mcr.microsoft.com/azuredocs/aci-helloworld:latest
resources:
requests:
cpu: 1
memoryInGb: 1.5
ports:
- port: 80
- port: 8080
- name: aci-tutorial-sidecar
properties:
image: mcr.microsoft.com/azuredocs/aci-tutorial-sidecar
resources:
requests:
cpu: 1
memoryInGb: 1.5
osType: Linux
ipAddress:
type: Private
ports:
- protocol: tcp
port: 80
- protocol: tcp
port: 8080
restartPolicy: Always
subnetIds:
- id: /subscriptions/b83c1XXXXXX-b5ba-2XXXX74c23f/resourceGroups/v-XX-XXX/providers/Microsoft.Network/virtualNetworks/Vnet1/subnets/default
name: default
tags: {exampleTag: tutorial}
type: Microsoft.ContainerInstance/containerGroups

enter image description here

enter image description here

引用:Tutorial: Deploy a multi-container group using a YAML file

关于azure - 如何将 Azure 多实例容器连接到 Azure 虚拟网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72061210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com