A.J*_*JRJ 3 google-cloud-platform google-deployment-manager
我的yaml模板如下,我想添加防火墙属性以允许http流量:
resources:
- name: deployed-vm2222
type: compute.v1.instance
properties:
zone: us-central1-f
machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/machineTypes/f1-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
Run Code Online (Sandbox Code Playgroud)
Fad*_*him 13
在防火墙中,我们使用:
targetTags: ["http"]
Run Code Online (Sandbox Code Playgroud)
然后,在实例中,我们使用:
tags:
items: ["http"]
Run Code Online (Sandbox Code Playgroud)
完整的文件可以如下所示:
resources:
- name: default-allow-http
type: compute.v1.firewall
properties:
targetTags: ["http"]
sourceRanges: ["0.0.0.0/0"]
allowed:
- IPProtocol: TCP
ports: ["80"]
- name: vm-test
type: compute.v1.instance
properties:
zone: xxxx
machineType: xxxx
tags:
items: ["http"]
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
diskName: xxxx
sourceImage: xxxx
networkInterfaces:
- network: xxxx
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
Run Code Online (Sandbox Code Playgroud)
执行此操作时需要注意几件事,请确保正确标记了实例以启用标记。例如,标记实例,http服务器或https服务器,以确保防火墙知道它正在处理公共流量。
可以通过以下方式添加防火墙条目。
resources:
- name: instance
type: xxxxxxxx
properties:
zone: us-east1-b
tags:
- http-server
- name: default-allow-http
type: compute.v1.firewall
properties:
network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default
targetTags: ["http-server"]
sourceRanges: ["0.0.0.0/0"]
allowed:
- IPProtocol: TCP
ports: ["80"]
Run Code Online (Sandbox Code Playgroud)
您可以在模板中添加防火墙规则,如下所示:
- name: allow-http-fw
type: compute.v1.firewall
properties:
allowed:
- IPProtocol: TCP
ports: 80
sourceRanges: [ 0.0.0.0/0 ]
Run Code Online (Sandbox Code Playgroud)
您可以定义为防火墙资源列出的属性。
| 归档时间: |
|
| 查看次数: |
5007 次 |
| 最近记录: |