Top Banner
Building a continuous deployment pipeline Patrick Hamann Web Performance Engineer | Fastly Clint Shryock Software Engineer | Hashicorp
37

Altitude SF 2017: Building a continuous deployment pipeline

Jan 22, 2018

Download

Technology

Fastly
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Altitude SF 2017: Building a continuous deployment pipeline

Building a continuous deployment pipeline

Patrick HamannWeb Performance Engineer | Fastly

Clint ShryockSoftware Engineer | Hashicorp

Page 2: Altitude SF 2017: Building a continuous deployment pipeline

Web Performance Engineer | Fastly

Patrick HamannSoftware Engineer | HashiCorp

Clint Shryock

Page 3: Altitude SF 2017: Building a continuous deployment pipeline

Poll?

Page 4: Altitude SF 2017: Building a continuous deployment pipeline

Why?

Page 5: Altitude SF 2017: Building a continuous deployment pipeline

• Configuration drift

• Manual deployment

• Not reproducible

• Can’t see outcomes ahead of time

• Changes can’t be traced

• Can’t easily rollback state

The problem?

Page 6: Altitude SF 2017: Building a continuous deployment pipeline

• Services can be easily reproduced

• Services are consistent

• Processes are repeatable & predictable

• Configuration is continuously tested

• Visibility and actionability

The goal

Page 7: Altitude SF 2017: Building a continuous deployment pipeline

• Declare our service configuration in code

• Configuration is maintained in VCS

• Small changes get tested and continuously integrated

• Deployment is automated on every change

How?

Page 8: Altitude SF 2017: Building a continuous deployment pipeline

Travis CI Terraform FastlyGitHub

Page 9: Altitude SF 2017: Building a continuous deployment pipeline

1. Developer writes change

1

Page 10: Altitude SF 2017: Building a continuous deployment pipeline

2. Tests changes locally

2

Page 11: Altitude SF 2017: Building a continuous deployment pipeline

3. Pushes change to VCS

3

Page 12: Altitude SF 2017: Building a continuous deployment pipeline

4. Triggers build in CI to integrate & test change

4

Page 13: Altitude SF 2017: Building a continuous deployment pipeline

5. If successful, deploys change to Fastly

5

Page 14: Altitude SF 2017: Building a continuous deployment pipeline

• How to apply changes to your services via the CLI

• What is Terraform?

• How we can define our Fastly configuration as code

• How to use CI to automate the application of your changes

• How to manage multiple environments*

What we'll learn today

Page 15: Altitude SF 2017: Building a continuous deployment pipeline
Page 16: Altitude SF 2017: Building a continuous deployment pipeline

Deploying a new version

Page 17: Altitude SF 2017: Building a continuous deployment pipeline

• Find the active version of service

• Clone the active version

• Delete all the existing VCL files

• Upload the new VCL files

• Define the main VCL

• Validate the newly cloned version

• Activate version

Manually deploying a new version

Page 18: Altitude SF 2017: Building a continuous deployment pipeline
Page 19: Altitude SF 2017: Building a continuous deployment pipeline
Page 20: Altitude SF 2017: Building a continuous deployment pipeline
Page 21: Altitude SF 2017: Building a continuous deployment pipeline

Find active version

curl https://api.fastly.com/service/<SERVICE_ID>/version -H 'Fastly-Key: <API_TOKEN>'

< HTTP/1.1 200 OK< Status: 200 OK< Content-Type: application/json

{ "testing": false, "locked": true, "number": 88, "active": true, "service_id": "5DYjgYJ8SeELWdjbdJtZdD", "staging": false, "created_at": "2017-06-06T16:28:31+00:00", "deleted_at": null, "comment": "", "updated_at": "2017-06-06T16:28:41+00:00", "deployed": false}

Page 22: Altitude SF 2017: Building a continuous deployment pipeline

Clone active version

curl https://api.fastly.com/service/<SERVICE_ID>/version -H 'Fastly-Key: <API_TOKEN>'

< HTTP/1.1 200 OK< Status: 200 OK< Content-Type: application/json

{ "testing": false, "locked": true, "number": 88, "active": true, "service_id": "5DYjgYJ8SeELWdjbdJtZdD", "staging": false, "created_at": "2017-06-06T16:28:31+00:00", "deleted_at": null, "comment": "", "updated_at": "2017-06-06T16:28:41+00:00", "deployed": false}

Page 23: Altitude SF 2017: Building a continuous deployment pipeline

Introduction to Terraform

Page 24: Altitude SF 2017: Building a continuous deployment pipeline

• Unify the view of resources using infrastructure as code

• Support the modern data center (IaaS, PaaS, SaaS)

• Expose a way to safely and predictably change infrastructure

• Provide a workflow that is technology agnostic

• Manage anything with an API

Terraform's Goals

Page 25: Altitude SF 2017: Building a continuous deployment pipeline

• Provides a high-level abstraction of infrastructure (IaC)

• Allows for composition and combination

• Supports parallel management of resources (graph, fast)

• Separates planning from execution (dry-run)

Terraform vs. Other Tools

Page 26: Altitude SF 2017: Building a continuous deployment pipeline

• Human-readable configuration (HCL) is designed for human

consumption so users can quickly interpret and understand their

infrastructure configuration.

• HCL includes a full JSON parser for machine-generated

configurations.

Infrastructure as Code (Terraform)

Page 27: Altitude SF 2017: Building a continuous deployment pipeline

Infrastructure dependency graph

gcs_bucket

fastly_service

dnsimple_record

gcs

dnsimplefastly

Page 28: Altitude SF 2017: Building a continuous deployment pipeline

Walking the graph

2

4

3

2

3 gcs_bucket

fastly_service

dnsimple_record

gcs

dnsimple2

1

fastly

root

Page 29: Altitude SF 2017: Building a continuous deployment pipeline

variable "fastly_api_token" {}

provider "fastly" { api_key = "${var.fastly_api_token}"}

resource "fastly_service_v1" "www-fastly-com" { name = "www.fastly.com"

domain { name = "www.fastly.com" comment = "Production service" }}

main.tf

Page 30: Altitude SF 2017: Building a continuous deployment pipeline

variable "fastly_api_token" {}

provider "fastly" { api_key = "${var.fastly_api_token}"}

resource "fastly_service_v1" "www-fastly-com" { name = "www.fastly.com"

domain { name = "www.fastly.com" comment = "Production service" }}

main.tf

Page 31: Altitude SF 2017: Building a continuous deployment pipeline

variable "fastly_api_token" {}

provider "fastly" { api_key = "${var.fastly_api_token}"}

resource "fastly_service_v1" "www-fastly-com" { name = "www.fastly.com"

domain { name = "www.fastly.com" comment = "Production service" }}

main.tf

Page 32: Altitude SF 2017: Building a continuous deployment pipeline

variable "fastly_api_token" {}

provider "fastly" { api_key = "${var.fastly_api_token}"}

resource "fastly_service_v1" "www-fastly-com" { name = "www.fastly.com"

domain { name = "www.fastly.com" comment = "Production service" }}

main.tf

Page 33: Altitude SF 2017: Building a continuous deployment pipeline

Questions?

Page 34: Altitude SF 2017: Building a continuous deployment pipeline

Workshop!

Page 35: Altitude SF 2017: Building a continuous deployment pipeline

Terminal

bit.ly/altitude-abcd

$ ssh -A [email protected]

$ password: altitude2017

$ cd workshop

Terminal

Page 36: Altitude SF 2017: Building a continuous deployment pipeline

Questions?

Page 37: Altitude SF 2017: Building a continuous deployment pipeline

Thank you.