altitude sf 2017: building a continuous deployment pipeline

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

Upload: fastly

Post on 22-Jan-2018

777 views

Category:

Technology


2 download

TRANSCRIPT

Building a continuous deployment pipeline

Patrick HamannWeb Performance Engineer | Fastly

Clint ShryockSoftware Engineer | Hashicorp

Web Performance Engineer | Fastly

Patrick HamannSoftware Engineer | HashiCorp

Clint Shryock

Poll?

Why?

• 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?

• Services can be easily reproduced

• Services are consistent

• Processes are repeatable & predictable

• Configuration is continuously tested

• Visibility and actionability

The goal

• 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?

Travis CI Terraform FastlyGitHub

1. Developer writes change

1

2. Tests changes locally

2

3. Pushes change to VCS

3

4. Triggers build in CI to integrate & test change

4

5. If successful, deploys change to Fastly

5

• 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

Deploying a new version

• 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

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}

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}

Introduction to Terraform

• 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

• 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

• 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)

Infrastructure dependency graph

gcs_bucket

fastly_service

dnsimple_record

gcs

dnsimplefastly

Walking the graph

2

4

3

2

3 gcs_bucket

fastly_service

dnsimple_record

gcs

dnsimple2

1

fastly

root

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

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

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

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

Questions?

Workshop!

Terminal

bit.ly/altitude-abcd

$ ssh -A [email protected]

$ password: altitude2017

$ cd workshop

Terminal

Questions?

Thank you.