我想在.yaml
文件中使用 Deployment Manager 模板配置防火墙和启动脚本
以下是我需要执行的步骤
- 已创建新的 Deployment Manager 部署
- 部署包括具有嵌入式启动脚本的虚拟机
- 具有启动脚本的虚拟机也有一个名为 http 的标记项
- 存在允许端口 80 (http) 流量并使用值为 http 的标记应用的防火墙规则
- 虚拟机使用 Apache Web 服务器响应 Web 请求
- 检查部署管理器是否包含启动脚本和防火墙资源
下面是我创建的示例文件,但在部署文件时,它显示了第 3 步(具有启动脚本的虚拟机也有一个名为 http 的标记项)未配置。
如果我错过任何事情,请帮助我。
- name: my-vm
type: compute.v1.instance
properties:
zone: us-central1-a
machineType: zones/us-central1-a/machineTypes/n1-standard-1
sourceRanges: ["0.0.0.0/0"]
targetTags: ["webserver"]
allowed:
- IPProtocol: TCP
ports: ["80"]
metadata:
items:
- key: startup-script
value: |
#! /bin/bash
apt-get update
apt-get install -y apache2
cat <<EOF > /var/www/html/index.html
<html><body><h1>Welcome to Apache</h1>
<p>This page was created from a simple startup script!</p>
</body></html>
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-9-stretch-v20180814
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-dee231a39b26c176/global/networks/default
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT