Slide 1

Slide 1 text

Spinnaker Application management by Terraform Plugins HashiTalk Japan 2020/7/3 16:00~16:15 Keisuke Yamashita (Twitter: @_k_e_k_e) Copyright © 2019 HashiCorp

Slide 2

Slide 2 text

Keisuke Yamashita Twitter: @_k_e_k_e Merpay SRE ・ Microservices Platform CI/CD Team

Slide 3

Slide 3 text

Agenda ・About Terraform Plugins ・Manage Spinnaker Applications w/ Terraform Providers ・Operation by Terraform Provisioners ・Wrap up

Slide 4

Slide 4 text

About Terraform Plugins

Slide 5

Slide 5 text

Terraform When terraform is executed...

Slide 6

Slide 6 text

Terraform = Terraform Core + Terraform Plugins Terraform Cores ● Entrypoint for Terraform ● Resource state management ● Communicate with Terraform Plugins Terraform Plugins ● Executable binary called by Terraform Core ● Exposes an implementation for a specific services(GCP, AWS, local host, etc)

Slide 7

Slide 7 text

Terraform Plugins = Terraform Providers + Terraform Provisioners

Slide 8

Slide 8 text

Terraform Plugins = Terraform Providers + Terraform Provisioners Terraform Providers ● Access external service APIs and CRUD resources ● Managed Terraform State Terraform Provisioners ● Run model specific actions for preparing the resources

Slide 9

Slide 9 text

Manage Spinnaker Applications by Terraform Provider

Slide 10

Slide 10 text

Spinnaker Spinnaker is an open source, multi-cloud continuous delivery platform

Slide 11

Slide 11 text

Spinnaker Spinnaker is an open source, multi-cloud continuous delivery platform Service Team Spinnaker Application Trigger Deploy

Slide 12

Slide 12 text

Spinnaker Spinnaker is an open source, multi-cloud continuous delivery platform Service Team Spinnaker Application Trigger Deploy How to manage Spinnaker Applications?

Slide 13

Slide 13 text

Terraform Providers The three kinds 1. Built-in Providers ● Null provider ● Secret provider ● … 2. Hashicorp distributed Providers ● terraform-provider-gcp ● terraform-provider-aws ● terraform-provider-vault

Slide 14

Slide 14 text

Terraform Providers The three kinds 3. Custom Providers ● Third-party developed providers ● Develop by yourself

Slide 15

Slide 15 text

mercari/terraform-provider-spinnaker Originally forked from armory-io/terraform-provider-spinnaker

Slide 16

Slide 16 text

Manage Spinnaker Applications CODE EDITOR resource “spinnaker_application” “my_app” { application = “my-app” email = “[email protected]” } resource “spinnaker_application” “my_test_app” { application = “my-test-app” email = “[email protected]” }

Slide 17

Slide 17 text

Manage Spinnaker Applications CODE EDITOR resource “spinnaker_application” “my_app” { application = “my-app” email = “[email protected]” } resource “spinnaker_application” “my_test_app” { application = “my-test-app” email = “[email protected]” }

Slide 18

Slide 18 text

Terraform Providers Take away To Terraform manage resources… 1. Check if there are built-in providers 2. Check if Hashicorp distributes the provider 3. Check custom provider in the community, GitHub, etc 4. Develop by yourself! Ideally, there are no limits what you can manage!

Slide 19

Slide 19 text

Terraform Providers Take away But… ● Built-in provider: It’s built-in ● Hashicorp distributed provider: Terraform will download on terraform init ● Custom Provider: You need to manually download to your environment

Slide 20

Slide 20 text

Operation by Terraform Provisioner

Slide 21

Slide 21 text

Spinnaker Spinnaker is an open source, multi-cloud continuous delivery platform New Spinnaker Application Create Old Spinnaker Application

Slide 22

Slide 22 text

Spinnaker Spinnaker is an open source, multi-cloud continuous delivery platform New Spinnaker Application Create Old Spinnaker Application How to delete old application? Delete

Slide 23

Slide 23 text

Terraform Provisioners List of provisioners ● Chef ● File ● habitat ● puppet ● remote-exec ● salt-masterless ● local-exec: Run any script on resource create or delete. See details Provisioners(https://www.terraform.io/docs/provisioners/index.html)

Slide 24

Slide 24 text

local-exec Terraform Provisioner Runs script on resource create CODE EDITOR resource “spinnaker_application” “my_app” { application = “my-app” email = “[email protected] provisioner “local-exec” { command = “./script/delete-app.sh my-old-app” } }

Slide 25

Slide 25 text

Terraform Provisioners Take away There are many actions provided by Terraform Provisioners. Ideally, you can run any operation by local-exec provisioner. Very useful for many use cases.

Slide 26

Slide 26 text

Terraform Provisioners Take away There are many actions provided by Terraform Provisioners. Ideally, you can run any operation by local-exec provisioner. Very useful for many use cases. No custom provisioners!

Slide 27

Slide 27 text

Wrap up

Slide 28

Slide 28 text

Manage Spinnaker Application by Terraform Plugins Managed Spinnaker application by custom Providers By developing custom Terraform Providers, you can ideally manage any resource. Start building one!

Slide 29

Slide 29 text

Manage Spinnaker Application by Terraform Plugins Managed Spinnaker application by custom Providers By developing custom Terraform Providers, you can ideally manage any resource. Start building one! Provisions are done by local-exec Provisioners Terraform is mainly used as provisioning tool but can be also used as configuration management tool.

Slide 30

Slide 30 text

Terraform has high extensibility which fits is many use cases

Slide 31

Slide 31 text

Thank You! HashiTalk Japan 2020 Keisuke Yamashita (Twitter: @_k_e_k_e) 31