Terraform을 사용하여 VMware Cloud Foundation as a Service에서 가상 데이터 센터 구성하기
이 튜토리얼에서는 비용이 발생할 수 있습니다. Cost Estimator를 사용하여 예상 사용량을 기반으로 비용 추정값을 생성하십시오.
이 튜토리얼에서는 초기 인스턴스 프로비저닝 후 IBM Cloud® for VMware Cloud Foundation as a Service 단일 테넌트 또는 멀티 테넌트 가상 데이터 센터(VDC)를 운영하는 기본 단계를 설명합니다. 이 자습서를 완료하는 데 약 20~30분이 소요되며, VMware Cloud Foundation as a Service 인스턴스 와 VDC 가 이미 프로비저닝되어 있는 것으로 가정합니다. 이 튜토리얼에서는 필요한 경우 사용 사례에 맞게 사용자 지정하고 수정할 수 있는 예제 테라폼 템플릿을 사용합니다.
목표
이 튜토리얼에서는 학습합니다:
- Terraform으로 VDC 네트워크를 만드는 방법.
- Terraform으로 VDC 네트워크에서 가상 머신(VM)을 생성하는 방법.
- Terraform을 사용하여 VDC 엣지 게이트웨이에서 네트워크 주소 변환(NAT) 및 방화벽(FW) 규칙을 구성하는 방법.
다음 다이어그램은 배포할 솔루션의 개요를 보여줍니다.
- IBM Cloud 콘솔을 사용하여 단일 테넌트 인스턴스에서 VDC를 생성합니다. 인스턴스에는 하나 이상의 VDC가 있을 수 있으므로 테스트 목적으로 전용 VDC를 사용할 수 있습니다. 이 예제 VDC는
2 IOPS/GB
스토리지 풀만 사용합니다. - VDC가 생성되면 엣지 게이트웨이와 외부 네트워크가 자동으로 생성됩니다. 외부 네트워크를 통해 인터넷에 액세스할 수 있으며 사용 가능한 공용 IP 주소 6개가 포함된
/29
의 IP 주소 블록이 제공됩니다. - Terraform 템플릿은 방화벽 및 네트워크 주소 변환 규칙뿐만 아니라 VDC 네트워크, 가상 머신을 생성하는 데 사용됩니다. 생성은 변수를 통해 완전히 제어됩니다. Terraform은 사용자 이름과 비밀번호를 사용하여 VMware Cloud Director API에 인증합니다. 액세스 토큰은 가까운 시일 내에 지원될 예정입니다.
- 라우팅된 네트워크 2개(
application-network-1
및db-network-1
)와 격리된 네트워크 1개(isolated-network-1
) 등 3개의 VDC 네트워크가 생성됩니다. 라우팅된 VDC 네트워크는 엣지 게이트웨이에 연결되고 격리된 VDC 네트워크는 독립형 네트워크입니다. 필요에 따라 더 많은 네트워크를 만들 수 있습니다. - Windows 2022 운영 체제를 사용하여 점프 서버(
jump-server-1
)가 생성됩니다. 서버는application-network-1
에 연결됩니다. VM 콘솔을 통해 가상 머신에 접속하거나 엣지 게이트웨이에 생성된 DNAT 규칙을 통해 RDP를 사용하여 가상 머신에 접속할 수 있습니다. - 하나의 예제 가상 머신(
application-server-1
)이application-network-1
에 생성됩니다.application-server-1
에는 로깅을 위한 추가 디스크가 있습니다. 필요에 따라 더 많은 가상 머신 또는 디스크를 생성할 수 있습니다. - 하나의 예제 가상 머신(
db-server-1
)이 두 개의 별도 vnics를 사용하여db-network-1
및isolated-network-1
에 생성됩니다.db-server-1
에는 데이터 및 로깅용 디스크 두 개가 추가로 있습니다. 필요에 따라 더 많은 가상 머신 또는 디스크를 생성할 수 있습니다. - 공용 네트워크 액세스를 위해 소스 NAT(SNAT) 및 대상 NAT(DNAT) 규칙이 만들어집니다. 모든 라우팅된 네트워크에 대해 공용 인터넷에 대한 SNAT가 구성되고 애플리케이션 서버에 액세스하도록 DNAT가 구성됩니다.
- 방화벽 규칙은 환경에 대한 네트워크 액세스를 보호하기 위해 프로비저닝됩니다. 방화벽 규칙을 만들기 위해 네트워크 및 개별 IP 주소에 대한 정적 그룹 및 IP 집합이 생성됩니다.
이 튜토리얼은 다음 단계로 나뉩니다:
- 예제 저장소 복제
- VDC에 대한 필수 정보 얻기
- 테라폼 템플릿 변수 구성
- 초기화, 계획 및 적용
- VMware Cloud Director 콘솔에 연결합니다
- 인터넷을 통해 VM에 연결하고 연결 유효성 검사
VMware Cloud Director 콘솔을 사용하는 대체 튜토리얼 도 사용할 수 있습니다.
시작하기 전에
이 튜토리얼에는 다음 항목이 필요합니다.
- IBM Cloud 청구 가능 계정
- 사용자 권한을 확인하십시오. 사용자 계정에 VMware Cloud Foundation as a Service 리소스를 생성하고 관리할 수 있는 충분한 권한이 있는지 확인합니다.
- 사전 프로비저닝된 VMware Cloud Foundation as a Service 단일 테넌트 인스턴스 입니다,
- VMware Cloud Foundation as a Service 단일 테넌트 인스턴스의 사전 프로비저닝된 VDC 입니다,
- IBM Cloud CLI,
- IBM Cloud API 키,
jq
를 사용하여 JSON 파일을 쿼리하고, 그리고- Terraform과 VMware Cloud Director Provider를 사용하여 인프라를 코드화하여 리소스를 프로비저닝할 수 있습니다.
튜토리얼 시작하기 안내서에는 사용자 운영 체제에 맞게 이 도구를 다운로드하고 설치하기 위한 지시사항이 있습니다.
예제 리포지토리 복제
VMware Cloud Foundation as a Service에 대한 예제 Terraform 템플릿은 GitHub에서 찾을 수 있습니다.
예제 리포지토리를 로컬 컴퓨터(예: 노트북 또는 인터넷에 액세스할 수 있는 가상 서버)에 복제합니다.
예를 들어 GitHub CLI를 사용합니다:
gh repo clone IBM/vmwaas-terraform-examples
또는 다음 URL 와 함께 HTTPS 를 사용하십시오
https://github.com/IBM/vmwaas-terraform-examples.git
VDC에 대한 필수 정보 얻기
전제 조건으로 IBM Cloud 콘솔 에서 VMware Cloud Foundation as a Service 단일 테넌트 인스턴스 만들기 및 하나 이상의 VDC 를 사용해야 합니다.
인스턴스와 VDC가 배포되면 콘솔에서 필요한 세부 정보 및 VDC ID를 수집할 수 있습니다.
단일 테넌트 인스턴스의 VMware Cloud Foundation as a Service 클라우드 디렉터 콘솔에 로그인합니다(VMware):
- VMware Cloud Foundation as a Service 테이블에서 VMware Cloud Foundation as a Service 인스턴스 이름을 클릭합니다.
- 요약 탭에서 정보를 검토합니다.
- VDC 리전의 VMware Cloud Director 콘솔에 처음 액세스하는 경우 관리자 자격 증명을 설정하여 복잡한 임의의 초기 비밀번호를 생성해야 합니다.
- VDC 세부 정보 페이지에서 VMware Cloud Director Console 를 클릭하여 콘솔에 액세스합니다.
- 관리자 사용자 이름과 암호를 사용하여 VMware Cloud Director 콘솔에 처음 로그인합니다.
- 관리자가 VMware Cloud Director 콘솔에 로그인한 후 VMware Cloud Director 콘솔에 액세스할 수 있는 역할을 가진 사용자를 추가로 만들 수 있습니다.
VMware Cloud Director 콘솔에 로그인하여 Terraform 배포에 필요한 정보를 수집할 수 있습니다. 또는 예제 리포지토리에 제공된 vmwaas.sh
셸 스크립트를 사용할 수도 있습니다. 스크립트는 VMware Cloud Foundation as a Service API를 사용하여 이러한 값을 수집합니다.
스크립트를 사용하려면 지역 및 API 키를 다음과 같이 구성하세요:
export IBMCLOUD_API_KEY=your-api-key-here
export IBMCLOUD_REGION=region-here
기본 지역은 us-south
입니다.
스크립트 사용:
% ./vmwaas.sh
USAGE : vmwaas [ ins | in | vdcs | vdc | vdcgw | tf | tfvars ]
인스턴스를 나열하려면
% ./vmwaas.sh ins
Get instances.
Instances:
NAME DIRECTOR_SITE_ID LOCATION STATUS
demo b75efs1c-35df-40b3-b569-1124be37687d us-south-1 ReadyToUse
VDC를 나열하려면:
% ./vmwaas.sh vdcs
Get virtual datacenters.
VDCs:
NAME ID DIRECTOR_SITE_ID CRN
vdc-demo 5e37ed2d-54cc-4798-96cf-c363de922ab4 b75efs1c-35df-40b3-b569-1124be37687d crn:v1:bluemix:public:vmware:us-south:...
인증을 위해 Terraform TF_VAR을 받으려면:
% ./vmwaas.sh tfvars vdc-demo
Get variables for Terraform in export format.
TF_VARs:
export TF_VAR_vmwaas_url="https://<your_url>.us-south.vmware.cloud.ibm.com/api"
export TF_VAR_vmwaas_org="f37f3422-e6c4-427e-b277-9fec334b99fb"
export TF_VAR_vmwaas_vdc_name="vdc-demo"
이를 셸로 내보내거나 terraform.tfvars 줄을 terraform.tfvars
파일에 스크립트의 출력으로 추가하는 tfvars
옵션을 사용하여 가져올 수 있습니다.
Terraform 템플릿 변수 구성
이 예제 인프라 테라폼 템플릿은 vcd-demo-infra
폴더에 있습니다.
이 데모 Terraform 템플릿은 라우팅된 두 개의 네트워크와 격리된 하나의 VDC 네트워크, 세 개의 VM 및 예제 SNAT, DNAT 및 방화벽 규칙으로 구성된 다음 예제 인프라를 배포합니다.
테라폼은 VMware Cloud Director Provider를 사용하며, 사용된 예제에서 주요 공급자 리소스는 다음과 같습니다:
- vcd_network_routed_v2
- vcd_network_isolated_v2
- vcd_vm
- vCD_NSXT_IP_SET
- vCD_NSXT_SECURITY_GROUP
- vCD_NSXT_NAT_RULE
- vCD_NSXT_파이어월
이 예제 템플릿에서는 생성은 Terraform 변수를 통해 완전히 제어되며, 예를 들어 더 많은 네트워크 또는 VM이 필요한 경우 실제 Terraform 템플릿을 변경할 필요가 없습니다. 예제 terraform.tfvars-example
파일이 제공되며 예제 값은 설명과 함께 제공됩니다.
시작하기 전에 예를 들어 terraform.tfvars-example
을 terraform.tfvars
으로 복사합니다:
cp terraform.tfvars-example terraform.tfvars
필요에 따라 네트워크, 가상 머신을 더 추가하고 NAT 또는 방화벽 규칙 등을 사용자 지정하는 등 그대로 사용할 수 있습니다.
-
인스턴스 및 VDC에 액세스하려면 다음 공통 변수를 설정하세요.
# Note. Variable values to access your Director instance. Use the Director portal # to figure our your values here. vmwaas_url = "put-your-director-url-here" # for example "https://abcxyz.us-south.vmware.cloud.ibm.com/api" vmwaas_org = "put-your-org-id-here" vmwaas_vdc_name = "put-your-vdc-name-here" vmwaas_api_token = "" # Note. See VMware Docs to create API token. #vmwaas_user = "put-your-username-here" # Note. When using a username and password, create a new local user in Director for terraform. #vmwaas_password = "put-your-password-here" # Note. When using a username and password, create a new local user in Director for terraform.
API 토큰을 생성하려면 VMware Cloud Director Docs를 참조하십시오.
이러한 변수의 경우
vmwaas_api_token
,vmwaas_user
및vmwaas_password
에 대해terraform.tfvars
스크립트에서 정의하는 대신 TF_VAR_라는 환경 변수를 생성할 수도 있습니다(예:vmwaas.sh
스크립트). 이 경우terraform.tfvars
에 이 줄을 주석으로 처리합니다.인증 방법을 변경하는 경우 코드의 공급자 블록을 다른 인증 방법을 사용하도록 변경해야 합니다.
-
공통 이름 접두사를 설정하여 VDC 네트워크, 가상 머신 등을 식별하고 구분하세요.
# Note. Use a common name prefix for each item. item_name_prefix = "demo"
-
가상 머신의 DNS 서버를 정의합니다.
가상 머신에서 IBM Cloud 공용 DNS 서버를 사용하거나 직접 사용할 수 있습니다.
# Note. IBM Cloud DNS servers listed here. # You may also use your own here. dns_servers = ["161.26.1.10","161.26.1.11"]
여기에서 자체 DNS 서버를 사용할 때는 네트워크 연결이 가능한지 확인하세요.
-
VDC 네트워크를 정의합니다.
VDC 네트워크를 만들 때 맵 변수
vdc_networks
을 사용하여 이러한 네트워크와 해당 IP 풀을 정의합니다.# Note. Create VDC networks of type `routed` or # `isolated`. You can define one `static_ip_pool`and one # `dhcp_ip_pool` for each. vdc_networks = { application-network-1 = { description = "Application network 1" type = "routed" subnet = { cidr = "172.26.1.0/24" prefix_length = 24 gateway = "172.26.1.1" static_ip_pool = { start_address = "172.26.1.10" end_address = "172.26.1.100" } dhcp_ip_pool = { start_address = "172.26.1.101" end_address = "172.26.1.199" } } }, db-network-1 = { description = "DB network 1" type = "routed" subnet = { cidr = "172.26.2.0/24" prefix_length = 24 gateway = "172.26.2.1" static_ip_pool = { start_address = "172.26.2.10" end_address = "172.26.2.100" } dhcp_ip_pool = { start_address = "172.26.2.101" end_address = "172.26.2.199" } } }, isolated-network-1 = { description = "Isolated network 1" type = "isolated" subnet = { cidr = "172.26.3.0/24" prefix_length = 24 gateway = "172.26.3.1" static_ip_pool = { start_address = "172.26.3.10" end_address = "172.26.3.100" } dhcp_ip_pool = {} # leave empty for isolated network } }, }
-
가상 머신 구성을 정의합니다.
VM을 생성할 때 맵 변수
virtual_machines
을 사용하여 이를 정의합니다.# Note. Create VMs inside your VDC. # You can define each one individually and attach multiple networks # and disks. Individual disks are created for each additional disk. # Note. Check the storage profile names and apply to your VMs / disks. # If left empty, default profile is used. virtual_machines = { app-server-1 = { image = { catalog_name = "Public Catalog" template_name = "RedHat-8-Template-Official" } memory = 8192 cpus = 2 cpu_hot_add_enabled = true memory_hot_add_enabled = true storage_profile = "2 IOPS/GB" networks = { 0 = { name = "application-network-1" ip_allocation_mode = "POOL" is_primary = true ip = "" }, } disks = { 0 = { name = "logDisk" size_in_mb = "100" bus_type = "SCSI" bus_sub_type = "VirtualSCSI" bus_number = 1 storage_profile = "" }, } }, db-server-1 = { image = { catalog_name = "Public Catalog" template_name = "RedHat-8-Template-Official" } memory = 8192 cpus = 2 cpu_hot_add_enabled = true memory_hot_add_enabled = true storage_profile = "" networks = { 0 = { name = "db-network-1" ip_allocation_mode = "POOL" is_primary = true ip = "" }, 1 = { name = "isolated-network-1" ip_allocation_mode = "POOL" is_primary = false ip = "" }, } disks = { 0 = { name = "dbDisk" size_in_mb = "100" bus_type = "SCSI" bus_sub_type = "VirtualSCSI" bus_number = 1 storage_profile = "" }, 1 = { name = "dbLogDisk" size_in_mb = "100" bus_type = "SCSI" bus_sub_type = "VirtualSCSI" bus_number = 1 storage_profile = "" }, } }, jump-server-1 = { image = { catalog_name = "Public Catalog" template_name = "Windows-2022-Template-Official" } memory = 8192 cpus = 2 cpu_hot_add_enabled = true memory_hot_add_enabled = true storage_profile = "" networks = { 0 = { name = "application-network-1" ip_allocation_mode = "POOL" is_primary = true ip = "" }, }, disks = {} }, }
-
공인 IP 주소 맵을 정의합니다.
각 VDC와 엣지 게이트웨이에는 6개의 공용 IP 주소가 할당됩니다. 이 테라폼 템플릿은 제공된 연속된 IP 주소 목록을 지도로 취급합니다. 다음 변수
public_ips
는 VDC에 제공된 공인 IP 주소를 설명합니다. 다른 변수에 실제 IP 주소(예:public-ip-1
)를 실제로 지정하지 않고도 템플릿에서 키(예:xx.yy.zz.56
)를 사용하여 IP 주소를 정의하고 참조로 사용할 수 있습니다.# Note. Map of available 6 public IPs. You can use these names # in NAT rules. Do not change the map's keys here. public_ips = { public-ip-0 = { name = "public-ip-0" description = "" }, public-ip-1 = { name = "public-ip-1" description = "" }, public-ip-2 = { name = "public-ip-2" description = "" }, public-ip-3 = { name = "public-ip-3" description = "" }, public-ip-4 = { name = "public-ip-4" description = "" }, public-ip-5 = { name = "public-ip-5" description = "" }, }
-
NAT 규칙을 정의합니다.
nat_rules
변수는 생성할 NAT 규칙을 정의합니다. 제공된 예시를 확인하고 필요에 따라 수정하세요.# Note. You can use `vdc_networks` or `virtual_machines` keys as # address_targets here. Terraform will pick the IP address of # the specific resource and use that in the actual NAT rule. # Note. You can specify the desired actual public IP address # (`external_address`) in the rule, or you can use the # `external_address_list_index`, which will pick the IP # addresses from the allocated IP pool (`edge_gateway_allocated_ips`). # Note. Use Director UI to get the name for the Application # profiles." nat_rules = { dnat-to-app-1 = { rule_type = "DNAT" description = "DNAT rule to app-server-1" external_address_target = "public-ip-1" external_address = "" internal_address_target = "app-server-1" internal_address = "" dnat_external_port = "" app_port_profile = "" logging = false priority = 90 enabled = true }, dnat-to-jump-1 = { rule_type = "DNAT" description = "DNAT rule to jump-server-1" external_address_target = "public-ip-2" external_address = "" internal_address_target = "jump-server-1" internal_address = "" dnat_external_port = "" app_port_profile = "" logging = false priority = 90 enabled = true }, snat-to-internet-1 = { rule_type = "SNAT" description = "SNAT rule to application-network-1" external_address_target = "public-ip-0" external_address = "" internal_address_target = "application-network-1" internal_address = "" snat_destination_address = "" logging = false priority = 100 enabled = true }, snat-to-internet-2 = { rule_type = "SNAT" description = "SNAT rule to db-network-1" external_address_target = "public-ip-0" external_address = "" internal_address_target = "db-network-1" internal_address = "" snat_destination_address = "" logging = false priority = 100 enabled = true }, }
-
방화벽 규칙을 정의하는 데 필요한 IP 세트 및 정적 그룹을 만듭니다.
테라폼 템플릿은 NAT 규칙에 사용되는 공인 IP 주소에 대한 IP 집합을 생성합니다. 온프레미스 네트워크 또는 기타 사설 또는 공용 IP 주소와 같은 추가 IP 집합을 정의할 수도 있습니다.
# Note. You need to create IP sets to be used in firewall rules. # You can use the `public_ips` keys here as address_targets, # but you can define IP sets using real IP addresses using a # list `ip_addresses`. ip_sets = { ip-set-on-public-ip-0 = { description = "Public IP 0 - used for SNAT" ip_addresses = [] address_target = "public-ip-0" }, ip-set-on-public-ip-1 = { description = "Public IP 1 - used for DNAT to app-server-1" ip_addresses = [] address_target = "public-ip-1" }, ip-set-on-public-ip-2 = { description = "Public IP 2 - used for DNAT to jump-server-1" ip_addresses = [] address_target = "public-ip-2" }, ip-set-on-public-ip-3 = { description = "Public IP 3" ip_addresses = [] address_target = "public-ip-3" }, ip-set-on-public-ip-4 = { description = "Public IP 4" ip_addresses = [] address_target = "public-ip-4" }, ip-set-on-public-ip-5 = { description = "Public IP 5" ip_addresses = [] address_target = "public-ip-5" }, ip-set-on-premises-networks = { description = "On-premises networks" ip_addresses = ["172.16.0.0/16",] address_target = "" }, }
방화벽 규칙에서 정적 그룹을 소스 및 대상으로 사용할 수도 있습니다. 이 예에서는 라우팅된 각 VDC 네트워크에 대해 하나씩, 그리고 라우팅된 모든 VDC 네트워크를 포함하는 세 개의 정적 그룹을 만듭니다.
# Note. You need to create Static Groups to be used in firewall rules. # You can use `vdc_networks` as keys here. security_groups = { sg-application-network-1 = { description = "Static Group for application-network-1" address_targets = ["application-network-1"] }, sg-db-network-1 = { description = "Static Group for db-network-1" address_targets = ["db-network-1"] }, sg-all-routed-networks = { description = "Static Group for all VDC networks" address_targets = ["application-network-1", "db-network-1"] }, }
-
방화벽 규칙을 정의합니다.
firewall_rules
변수는 생성할 방화벽 규칙을 정의합니다. 제공된 예시를 참조하여 필요에 따라 수정하세요.# Note. Use "ALLOW or "DROP". # Note. Use Director UI to get the name for the Application # profiles." firewall_rules = { app-1-egress = { action = "ALLOW" direction = "OUT" ip_protocol = "IPV4" destinations = [] # These refer to IP sets (ip_sets or nat_rules) or Static Groups (vdc_networks) sources = ["sg-application-network-1", "sg-db-network-1"] # These refer to IP sets (ip_sets or nat_rules) or Static Groups (vdc_networks) system_app_ports = [] logging = false enabled = true }, dnat-to-app-1-ingress = { action = "ALLOW" direction = "IN" ip_protocol = "IPV4" destinations = ["ip-set-on-public-ip-1"] # These refer to IP sets (ip_sets or nat_rules) or Static Groups (vdc_networks) sources = [] # These refer to IP sets (ip_sets or nat_rules) or Static Groups (vdc_networks) system_app_ports = ["SSH","HTTPS","ICMP ALL"] logging = false enabled = true }, dnat-to-jump-1-ingress = { action = "ALLOW" direction = "IN" ip_protocol = "IPV4" destinations = ["ip-set-on-public-ip-2"] # These refer to IP sets (ip_sets or nat_rules) or Static Groups (vdc_networks) sources = [] # These refer to IP sets (ip_sets or nat_rules) or Static Groups (vdc_networks) system_app_ports = ["RDP"] logging = false enabled = true }, }
일반적으로 공용 인터넷을 통해 RDP를 사용하는 것은 권장하지 않습니다. 위에 나열된 규칙은 설명 목적으로만 사용되었습니다.
초기화, 계획 및 적용
-
테라폼 프로젝트를 초기화하려면 예제 디렉터리에서
terraform init
명령을 실행하고 출력을 관찰하세요.예를 들어, 다음과 같습니다.
% terraform init Initializing the backend... Initializing provider plugins... - Finding latest version of hashicorp/random... - Finding latest version of vmware/vcd... - Installing hashicorp/random v3.4.3... - Installed hashicorp/random v3.4.3 (signed by HashiCorp) - Installing vmware/vcd v3.8.2... - Installed vmware/vcd v3.8.2 (signed by a HashiCorp partner, key ID 8BF53DB49CDB70B0) Partner and community providers are signed by their developers. If you'd like to know more about provider signing, you can read about it here: https://www.terraform.io/docs/cli/plugins/signing.html Terraform has created a lock file .terraform.lock.hcl to record the provider selections it made above. Include this file in your version control repository so that Terraform can guarantee to make the same selections by default when you run "terraform init" in the future. Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary.
-
다음으로
terraform plan
을 실행하여 배포할 내용을 확인할 수 있습니다.% terraform plan data.vcd_resource_list.list_of_vdcs: Reading... data.vcd_resource_list.list_of_vdc_edges: Reading... data.vcd_resource_list.list_of_catalog_items: Reading... data.vcd_nsxt_app_port_profile.system["SSH"]: Reading... data.vcd_nsxt_app_port_profile.system["HTTPS"]: Reading... data.vcd_nsxt_app_port_profile.system["ICMP ALL"]: Reading... data.vcd_org_vdc.org_vdc: Reading... [output omitted] Plan: 29 to add, 0 to change, 0 to destroy.
-
계획의 결과물을 확인하고 모든 것이 계획대로 표시되면
terraform apply
을 실행하여 실제로 에셋을 배포할 수 있습니다.예를 들어, 다음과 같습니다.
% terraform apply --auto-approve data.vcd_resource_list.list_of_vdcs: Reading... data.vcd_resource_list.list_of_vdc_edges: Reading... data.vcd_resource_list.list_of_catalog_items: Reading... data.vcd_nsxt_app_port_profile.system["SSH"]: Reading... data.vcd_nsxt_app_port_profile.system["HTTPS"]: Reading... data.vcd_nsxt_app_port_profile.system["ICMP ALL"]: Reading... data.vcd_org_vdc.org_vdc: Reading... [output omitted] Apply complete! Resources: 29 added, 0 changed, 0 destroyed.
-
위의 예시 외에도, 테라폼은 몇 가지 변수를
outputs
로 제공합니다. 예를 들어 VM에 액세스하기 위한 IP 주소 및 기타 액세스 정보를 얻으려면 이output
값을 확인합니다.예를 들어
terraform output created_virtual_machines
을 실행하여 VM에 대한 액세스 액세스 정보를 얻을 수 있습니다:% terraform output created_virtual_machines { "app-server-1" = { "admin_password" = "<omitted>" "name" = "demo-app-server-1" "network" = [ { "ip_address" = "172.26.1.10" "is_primary" = true "name" = "demo-application-network-1" }, ] } "db-server-1" = { "admin_password" = "<omitted>" "name" = "demo-db-server-1" "network" = [ { "ip_address" = "172.26.2.10" "is_primary" = true "name" = "demo-db-network-1" }, { "ip_address" = "172.26.3.10" "is_primary" = false "name" = "demo-isolated-network-1" }, ] } "jump-server-1" = { "admin_password" = "<omitted>" "name" = "demo-jump-server-1" "network" = [ { "ip_address" = "172.26.1.11" "is_primary" = true "name" = "demo-application-network-1" }, ] } }
NAT 규칙과 사용 중인 공인 IP 주소를 가져오려면
terraform output created_nat_rules
을 실행하면 됩니다:% terraform output created_nat_rules { "dnat-to-app-1" = { "dnat_external_port" = "" "external_address" = "xxx.yyy.zzz.19" "internal_address" = "172.26.1.10" "name" = "demo-dnat-to-app-1" "rule_type" = "DNAT" "snat_destination_address" = "" } "dnat-to-jump-1" = { "dnat_external_port" = "" "external_address" = "xxx.yyy.zzz.20" "internal_address" = "172.26.1.11" "name" = "demo-dnat-to-jump-1" "rule_type" = "DNAT" "snat_destination_address" = "" } "snat-to-internet-1" = { "dnat_external_port" = "" "external_address" = "xxx.yyy.zzz.18" "internal_address" = "172.26.1.0/24" "name" = "demo-snat-to-internet-1" "rule_type" = "SNAT" "snat_destination_address" = "" } "snat-to-internet-2" = { "dnat_external_port" = "" "external_address" = "xxx.yyy.zzz.18" "internal_address" = "172.26.2.0/24" "name" = "demo-snat-to-internet-2" "rule_type" = "SNAT" "snat_destination_address" = "" } }
created_fw_rules
출력을 통해 구성된 방화벽 규칙,created_ip_sets
가 있는 IP 세트 및created_static_groups
이 있는 정적 그룹 등을 확인할 수 있습니다. 예를 들어, 다음과 같습니다.terraform output created_fw_rules
프로비저닝 후에는 표준과 필요에 따라 예제 방화벽 규칙을 조정하세요. 여기서는 데모 목적으로만 구성된 ssh
및 RDP
와 같이 VM에 대한 공개 액세스를 노출합니다.
VMware Cloud Director 콘솔에 연결합니다
대체 튜토리얼 사용 및 액세스 방법 VMware Cloud Director 콘솔을 참조하시기 바랍니다. 배포된 자산과 엣지 게이트웨이가 어떻게 구성되었는지 확인합니다(FW 및 NAT 규칙).
예를 들어, 테라폼 output
에서 VM의 사용자 이름과 비밀번호를 가져옵니다:
terraform output created_virtual_machines
VMware Cloud Director 콘솔에서 콘솔을 사용하여 가상 머신에 연결합니다:
- 웹 콘솔 시작를 클릭하여 가상 머신에 로컬 콘솔을 엽니다.
- 웹 콘솔을 사용하여 이전 단계에서 캡처한 비밀번호와 사용자 ID로 루트를 사용하여 가상 머신에 로그인합니다.
- 그러면
www.ibm.com
과 같은 인터넷 리소스를 핑하여 네트워킹이 완료되고 작동 중임을 확인할 수 있어야 합니다.
인터넷을 통해 VM에 연결하고 연결 유효성 확인
마지막 단계는 인터넷을 통해 가상 머신에 연결하여 배포 및 네트워크 연결을 검증하는 것입니다.
인터넷을 통해 가상 머신에 연결합니다:
- 노트북이나 워크스테이션에서 공용 IP 주소
public-ip-1
과 ssh를app-server-1
로 핑할 수 있어야 네트워킹이 완료되어 작동 중임을 알 수 있습니다. - 이전 단계에서 수집한 공개 IP 주소
public-ip-2
와 사용자 이름 및 비밀번호를 사용하여 RDP를 사용하여 점프 서버jump-server-1
에 연결할 수 있어야 합니다. - 그런 다음 콘솔을 사용하여 상태를 비활성화(회색)로 슬라이드하여 규칙과 해당 상태를 편집하여 이전 단계에서 생성한 FW 규칙
dnat-to-app-1-ingress
을 비활성화하거나, 특정 규칙의 Terraform 변수를Drop
로 변경하고terraform apply --auto-approve
을 실행할 수 있습니다. - 그런 다음 콘솔을 사용하여 상태를 비활성화(회색)로 슬라이드하여 규칙과 해당 상태를 편집하여 이전 단계에서 생성한 FW 규칙
dnat-to-jump-1-ingress
을 비활성화하거나, 특정 규칙의 Terraform 변수를Drop
로 변경하고terraform apply --auto-approve
을 실행할 수 있습니다.
참고 자료
VDC 관리에 대한 자세한 내용은 다음 VMware Cloud Director™ 테넌트 포털 가이드를 확인하시기 바랍니다:
- VMware 의 조직 관리 가상 데이터 센터 네트워크 클라우드 디렉터 테넌트 포털
- VMware 의 NSX Edge 게이트웨이 관리 Cloud Director 테넌트 포털
- 가상 머신 관련 작업
공급자, 리소스 및 데이터 소스에 대한 자세한 정보는 Terraform 레지스트리에서 확인하세요: