成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

資源編排工具-UCloud Terraform-搭建一臺 web 服務器

ernest.wang / 1123人閱讀

摘要:此案例使用創(chuàng)建一臺服務器基礎設施,通過創(chuàng)建一臺云主機并在云主機上綁定云硬盤和外網(wǎng)彈性,同時使用外網(wǎng)防火墻來保護云主機的網(wǎng)絡安全性。

搭建一臺 web 服務器

本篇目錄

關鍵詞UHostEIPUDisk

摘要

云主機是構建在云環(huán)境的彈性計算資源,是 UCloud 最為核心的服務。有些服務,如彈性 IP、鏡像、云硬盤等必須與云主機結合后使用,另一些服務,如數(shù)據(jù)庫、緩存、對象存儲等可以和云主機結合共同構建 IT 環(huán)境。

此案例使用 Terraform 創(chuàng)建一臺 web 服務器基礎設施,通過創(chuàng)建一臺云主機并在云主機上綁定云硬盤和外網(wǎng)彈性IP,同時使用外網(wǎng)防火墻來保護云主機的網(wǎng)絡安全性。

使用 Terraform 來創(chuàng)建云主機可以享有由基礎設施即代碼 (IaC) 帶來的便利。通過編寫 HCL 文件,可以快速構建包含基礎設施定義和它們之間關聯(lián)的拓撲,并借助于代碼版本管理工具,將基礎設施的變更納入版本控制中。

此案例需要一個可用的 UCloud 帳號,以及確保目標可用區(qū)有足夠的權限和配額可以創(chuàng)建云主機,EIP 和 UDisk??梢栽谙路?nbsp;操作步驟拷貝使用,或克隆 官方倉庫 以獲取完整的 案例演示代碼.

拓撲圖

avatar

操作步驟

定義資源

首先創(chuàng)建基礎設施代碼文件。

該樣例中包含:

一個 variables.tf 文件,用于定義輸入?yún)?shù),代碼詳情如下:

variable "region" {   default = "cn-bj2" } variable "zone" {   default = "cn-bj2-05" } variable "instance_password" {   default = "ucloud_2020" }CopyErrorSuccess

一個 main.tf 文件,用于建立一個從云資源到代碼的映射,代碼詳情如下:

# 指定 UCloud Provider 和配置信息 provider "ucloud" {   region = var.region } # 查詢默認可用區(qū)中的主機鏡像 data "ucloud_images" "default" {   availability_zone = var.zone   name_regex        = "^CentOS 7.[1-2] 64"   image_type        = "base" } # 查詢默認推薦 web 外網(wǎng)防火墻 data "ucloud_security_groups" "default" {     type = "recommend_web" } # 創(chuàng)建一臺 web 服務器 resource "ucloud_instance" "web" {     availability_zone = var.zone     image_id          = data.ucloud_images.default.images[0].id     instance_type     = "n-basic-2"     root_password     = var.instance_password     name              = "tf-example-web-server"     tag               = "tf-example"     boot_disk_type    = "cloud_ssd"     # the default Web Security Group that UCloud recommend to users     security_group = data.ucloud_security_groups.default.security_groups[0].id     # create cloud data disk attached to instance     data_disks {       size = 20       type = "cloud_ssd"     }     delete_disks_with_instance = true } # 創(chuàng)建外網(wǎng)彈性 EIP resource "ucloud_eip" "default" {   bandwidth     = 2   charge_mode   = "bandwidth"   name          = "tf-example-web-server"   tag           = "tf-example"   internet_type = "bgp" } # EIP 綁定到主機 resource "ucloud_eip_association" "default" {   resource_id = ucloud_instance.web.id   eip_id      = ucloud_eip.default.id }CopyErrorSuccess

生成執(zhí)行計劃

在當前目錄下執(zhí)行 terraform plan 命令,查看編排計劃:

Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. data.ucloud_images.default: Refreshing state... data.ucloud_security_groups.default: Refreshing state... ------------------------------------------------------------------------ An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols:   + create Terraform will perform the following actions:   # ucloud_eip.default will be created   + resource "ucloud_eip" "default" {       + bandwidth     = 2       + charge_mode   = "bandwidth"       + charge_type   = (known after apply)       + create_time   = (known after apply)       + expire_time   = (known after apply)       + id            = (known after apply)       + internet_type = "bgp"       + ip_set        = (known after apply)       + name          = "tf-example-web-server"       + public_ip     = (known after apply)       + remark        = (known after apply)       + resource      = (known after apply)       + status        = (known after apply)       + tag           = "tf-example"     }   # ucloud_eip_association.default will be created   + resource "ucloud_eip_association" "default" {       + eip_id        = (known after apply)       + id            = (known after apply)       + resource_id   = (known after apply)       + resource_type = (known after apply)     }   # ucloud_instance.web will be created   + resource "ucloud_instance" "web" {       + auto_renew                 = (known after apply)       + availability_zone          = "cn-bj2-05"       + boot_disk_size             = (known after apply)       + boot_disk_type             = "cloud_ssd"       + charge_type                = (known after apply)       + cpu                        = (known after apply)       + cpu_platform               = (known after apply)       + create_time                = (known after apply)       + data_disk_size             = (known after apply)       + data_disk_type             = (known after apply)       + delete_disks_with_instance = true       + disk_set                   = (known after apply)       + expire_time                = (known after apply)       + id                         = (known after apply)       + image_id                   = "uimage-ohveag"       + instance_type              = "n-basic-2"       + ip_set                     = (known after apply)       + isolation_group            = (known after apply)       + memory                     = (known after apply)       + name                       = "tf-example-web-server"       + private_ip                 = (known after apply)       + remark                     = (known after apply)       + root_password              = (sensitive value)       + security_group             = "firewall-h55aem"       + status                     = (known after apply)       + subnet_id                  = (known after apply)       + tag                        = "tf-example"       + vpc_id                     = (known after apply)       + data_disks {           + size = 20           + type = "cloud_ssd"         }     } Plan: 3 to add, 0 to change, 0 to destroy. ------------------------------------------------------------------------ Note: You didn't specify an "-out" parameter to save this plan, so Terraform can't guarantee that exactly these actions will be performed if "terraform apply" is subsequently run.CopyErrorSuccess

可以看到即將創(chuàng)建一臺云主機、一塊云硬盤、一個彈性 EIP、一個主機和 EIP 之間的綁定關系,以及一個主機與云硬盤之間的掛載關系。

執(zhí)行編排

執(zhí)行 terraform apply 命令并確認,執(zhí)行編排計劃:

Do you want to perform these actions?   Terraform will perform the actions described above.   Only 'yes' will be accepted to approve.   Enter a value: yesCopyErrorSuccess

可通過控制臺確認資源已創(chuàng)建完成。


文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉載請注明本文地址:http://m.hztianpu.com/yun/126508.html

相關文章

  • IaC 自動化配置與編排神器 - Terraform 深度解析

    摘要:而對于依賴關系的抽象,業(yè)界最通行的做法即使用有向無環(huán)圖,來描述事務間的依賴關系。圖表并行遍歷,執(zhí)行資源動作從根節(jié)點開始,并行地去編排整個資源拓撲,遍歷整個有向無環(huán)圖,直到所有資源都被成功編排,并執(zhí)行清理操作。前言Terraform 是 Hashicorp 公司開源的一種多云資源編排工具。使用者通過一種特定的配置語言(HCL Hashicorp Configuration Language)來...

    Tecode 評論0 收藏0
  • 多云資源編排工具-UCloud Terraform

    摘要:是基于公司開源的實現(xiàn)的多云資源編排工具,用戶可以通過編寫規(guī)格文件,實現(xiàn)對基礎設施的自動化管理。資源編排工具將資源的狀態(tài)描述為一個狀態(tài)的集合,并支持若干種不同類型的狀態(tài)存儲。UCloud Terraform 是基于 Hashicorp 公司開源的Terraform實現(xiàn)的多云資源編排工具,用戶可以通過編寫 HCL(Hashicorp Configuration Language) 規(guī)格文件,實現(xiàn)...

    ernest.wang 評論0 收藏0
  • UCloud 資源編排工具與Chef,Puppet,Ansible對比

    摘要:使用資源編排工具的功能,可以與配置管理工具有機地結合在一起。資源編排工具基于公司開源的工具,使用簡單且統(tǒng)一的語法,幾乎可以管理任何資源而無需學習新的工具。與其它工具的對比本篇目錄配置管理工具(如 Chef,Puppet,Ansible 等)友商的資源編排系統(tǒng),如 AWS CloudFormation,阿里 ROS基于 API/SDK 自行研發(fā)配置管理工具(如 Chef,Puppet,Ansi...

    ernest.wang 評論0 收藏0
  • 多云資源編排工具-API GW 是否可以抗住 Terraform 高并發(fā)的調用場景?

    摘要:多云資源編排工具是否可以抗住高并發(fā)的調用場景目前默認的最大并發(fā)數(shù)是,不會由單個用戶同時發(fā)起過多的并發(fā)連接,所以降低了業(yè)務間鎖競爭的風險,可以支持更多資源同時編排。多云資源編排工具-APIGW是否可以抗住Terraform高并發(fā)的調用場景?目前Terraform默認的最大并發(fā)數(shù)是10,不會由單個用戶同時發(fā)起過多的并發(fā)連接,所以降低了業(yè)務間鎖競爭的風險,可以支持更多資源同時編排。是否所有的可用區(qū)...

    ernest.wang 評論0 收藏0
  • 云命令行(CloudShell)-什么是云命令行

    摘要:產品概述云命令行是版的命令行工具,目的是為了方便用戶管理云服務。不同賬戶的虛擬機相互隔離,保障安全。預裝命令工具鏈產品即開即用,無須配置賬戶信息。編程語言常用命令等使用限制每個賬戶同時能打開的會話不超過個。產品概述云命令行(CloudShell)是Web版的命令行工具,目的是為了方便用戶管理UCloud云服務。 打開CloudShell產品頁面,后臺會自動分配一臺虛擬機供您免費使用,虛擬機內...

    ernest.wang 評論0 收藏0

發(fā)表評論

0條評論

閱讀需要支付1元查看
<