Upgrade to Pro — share decks privately, control downloads, hide ads and more …

IaCでクラウドのインフラ運用を効率化しよう

 IaCでクラウドのインフラ運用を効率化しよう

2021年12月に開催した、Oracle Developer Day 2021の公演資料です。

Oracle Cloud InfrastructureでのIaCの推進を支える様々なサービスやツールをご紹介しながら、クラウド上でのインフラ運用を効率化する方法についてお伝えします。

Masataka Marukawa

December 17, 2021
Tweet

More Decks by Masataka Marukawa

Other Decks in Technology

Transcript

  1. 3 Copyright © 2021, Oracle and/or its affiliates Agenda 1.

    Infrastructure as Code と OCIでの活用 2. OCIでのTerraformの利用 3. OCI Resource Manager
  2. IT Copyright © 2021, Oracle and/or its affiliates 5 •

    • • • IT • • • • • DevOps • Infrastructure-as-Code
  3. Infrastructure as Code IT ( ) Kief Morris - Infrastrucrue

    as Code 2nd Edition – O'reilly 2020 Infrastructure as Code (IaC) Copyright © 2021, Oracle and/or its affiliates 6 DEPLOY DELIVER TEST BUILD CODE Infrastructure
  4. • IT • IT (装 ) • IT 装 •

    • • • DevOps Infrastructure as Code (IaC) Copyright © 2021, Oracle and/or its affiliates 7 GUI
  5. 8 IaC - Virtual Machine Virtual Cloud Network Internet Gateway

    Route Table Security Lists Block Storage Subnet • ) • “ ” ” ” Copyright © 2021, Oracle and/or its affiliates
  6. 9 Copyright © 2021, Oracle and/or its affiliates 1. (Bash,

    Perl, PowerShell, Ruby, Python… +SDK) • (Procedural) 2. (DSL) (CFEngine, Puppet, Chef, Ansible) • ( ) (=Declarative) 3. (Terraform, CloudFormation) • (=Idenpotency) (= ) 4. (Pulumi, AWS CDK ) • TypeScript, Python, Java • ( ) 2000 2010 2020
  7. • (Declarativity) • ( ) ( ) (Idempotency) • (

    ) • ( ) • – 10 yum install nginx yum: name: nginx state: installed (= ) Copyright © 2021, Oracle and/or its affiliates
  8. Copyright © 2021, Oracle and/or its affiliates 11 SDKs Java,

    Python, TypeScript/JavaScript, .NET, Ruby, Go, PL/SQL, CLI Terraform OCI Provider Ansible Collections OCI API REST Endpoints Resource Manager OCI
  9. Terraform HashiCorp • • (300+) • HCL (HashiCorp Configuration Language)

    (DSL) • (State) ( OK) • Terraform – 13 Copyright © 2021, Oracle and/or its affiliates
  10. 14 Terraform – Terraform (GRUD ) • • Provider $

    terraform apply • ( ) • $ terraform apply • • $ terraform destroy • $ terraform show • $ terraform graph Copyright © 2021, Oracle and/or its affiliates
  11. 15 Terraform – Terraform Core Provider Terraform Plugins Provisioners Client

    Library GO HTTP(S) Cloud *.tf JSON OR State .tfstate State (terraform.tfstate) Terraform state REST API Provider State Copyright © 2021, Oracle and/or its affiliates
  12. https://github.com/terraform-providers/terraform-provider-oci/blob/master/examples/networking/vcn/vcn.tf resource "oci_core_virtual_network" "vcn1" { cidr_block = "10.0.0.0/16" dns_label =

    "vcn1" compartment_id = "var.compartment_ocid" display_name = "vcn1" } resource "oci_core_instance" "instance1" { availability_domain = data.oci_identity_availability_domain.ad1.name compartment_id = var.compartment_ocid display_name = "be-instance1" shape = var.instance_shape metadata = { user_data = base64encode(var.user-data) } } Terraform Copyright © 2021, Oracle and/or its affiliates 16
  13. デモ Copyright © 2021, Oracle and/or its affiliates 17 Terraformサンプルを利用したOCIリソースの作成、変更

    • https://github.com/terraform-providers/terraform-provider-oci/tree/master/examples
  14. Infrastructure-as-Code OCI ( ) OCI Resource Manager 19 = Terraform-as-a-Service

    • Terraform OCI • HCL(HashiCorp Configuration Language) Terraform • (State) OCI OCI • OCI CRUD • OCI API IAM Audit OCI • OCI (Discovery / ) Copyright © 2021, Oracle and/or its affiliates Resource Manager
  15. Terraform • Terraform • OCI Resource Manager • • Resource

    Manager • WebUI/CLI/API Terraform OCI Resource Manager Copyright © 2021, Oracle and/or its affiliates 20
  16. 21 Terraform vs. OCI Resource Manager Terraform OCI Resource Manager

    State terraform OCI RM • RM • state • OCI IAM • Stack. Terraform Copyright © 2021, Oracle and/or its affiliates
  17. • OCI • Terraform (.tf) • : Plan, Apply, Destroy

    State • (.tfstate) • Resource Manager • • OCI Resource Manager Copyright © 2021, Oracle and/or its affiliates 22 1 2 3 State Destroy Apply Plan 1 2 … .tf Resource Manager
  18. デモ Copyright © 2021, Oracle and/or its affiliates 24 OCI

    Resource Managerを利用したOCIリソースの作成 • テンプレートを利用したネットワークリソースの作成 • zipしたTerraform構成ファイルをアップロードしてロードバランサとWebサーバーを構成 • ソースコードリポジトリ (GitHub) と連携した構成の実行
  19. Terraform • Resource Manager • HCL Oracle Cloud Infrastructure •

    Copyright © 2021, Oracle and/or its affiliates 26