from code to kubernetes

84
From Code to Kubernetes

Upload: daniel-oliveira-filho

Post on 08-Apr-2017

458 views

Category:

Software


0 download

TRANSCRIPT

Page 1: From Code to Kubernetes

From Code to Kubernetes

Page 2: From Code to Kubernetes

About UsArt Richards

CTO - truckin.io

Page 3: From Code to Kubernetes

About MeDaniel Oliveira

Devops Engineer

danieloliv79

danieloliveira079

[email protected]

Page 4: From Code to Kubernetes

Agenda

Page 5: From Code to Kubernetes

● Scenario and Architecture● Technologies● Challenges● Results● Foundations● Infrastructure as Code● Configuration Management● Building and Deployments● Application Debugging using Weavescope● Demo - From code to Kubernetes● Future● QA

Page 6: From Code to Kubernetes

git push

Page 7: From Code to Kubernetes

Scenario and Architecture

Page 8: From Code to Kubernetes

Distributed Teams

Page 9: From Code to Kubernetes

Early stages products

Page 10: From Code to Kubernetes

Greenfield projects

Page 11: From Code to Kubernetes

One man's operations team

Priorities vs Resources

Page 12: From Code to Kubernetes

Deployments Lifecycle

Page 13: From Code to Kubernetes

10+Non-production deployments per day

Page 14: From Code to Kubernetes

8 ProjectsFrontend, Backend API, Android

Development, Test, Staging, Demo and Production

Page 15: From Code to Kubernetes

WeeklyProduction deployments

(mobile, frontend and backend)

Page 16: From Code to Kubernetes

Technologies

Page 17: From Code to Kubernetes

Applications

Page 18: From Code to Kubernetes

Infrastructure

Page 19: From Code to Kubernetes

Challenges

Page 20: From Code to Kubernetes

● CI/CD Pipeline

● Infrastructure as Code

● Isolated Environments (Dev, Test, Demo, Staging, Production)

● Unified orchestrator for builds and deployments processes

● Integrations

● Easy application debugging

● Automation

Page 21: From Code to Kubernetes

Results

Page 22: From Code to Kubernetes
Page 23: From Code to Kubernetes

Foundations

Page 24: From Code to Kubernetes

IaaSCloud Provider

ResourcesNetwork, Instances, IAM, Disk, Registry, Kubernetes Cluster

Software, Packages and ConfigsSalt Master, Salt Minion, Docker, Postgresql and Elasticsearch

Pro

visi

onin

g O

rder

Desired StateMinions, API, Reactor, Integrations

Page 25: From Code to Kubernetes

Let's talk about provisioning

Page 26: From Code to Kubernetes

Google Cloud Platform

https://cloud.google.com

Page 27: From Code to Kubernetes

Infrastructure as Code

Page 28: From Code to Kubernetes

IaaSCloud Provider

ResourcesNetwork, Instances, IAM, Disk, Registry, Kubernetes Cluster

Software, Packages and ConfigsSalt Master, Salt Minion, Docker, Postgresql and Elasticsearch

Pro

visi

onin

g O

rder

Desired StateMinions, API, Reactor, Integrations

Page 29: From Code to Kubernetes

Terraform by Hashicorp

https://www.terraform.io

Page 30: From Code to Kubernetes

Basic network resources configuration file

variable

● Command line tool (apply, plan, destroy)

● Multiples Providers

● Config based resources

● Usage of Variables

● Dependencies Graph

● Execution Plan

● Resource Creation in Parallel

● Multiples Provisioners

● Detailed Output

dependency

Terraform output

Page 31: From Code to Kubernetes

Configure 'Em AllNetwork, Firewall, Subnetworks, Instances,

Buckets, Disks, Kubernetes Cluster, Services Accounts and IAM

Page 32: From Code to Kubernetes

Configuration Management

Page 33: From Code to Kubernetes

IaaSCloud Provider

ResourcesNetwork, Instances, IAM, Disk, Registry, Kubernetes Cluster

Software, Packages and ConfigsSalt Master, Salt Minion, Docker, Postgresql and Elasticsearch

Pro

visi

onin

g O

rder

Desired StateMinions, API, Reactor, Integrations

Page 34: From Code to Kubernetes

https://saltstack.com

Page 35: From Code to Kubernetes

SaltStack Open Sourcehttps://docs.saltstack.com/en/latest/

Master

MinionOperator

MinionPostgresql

MinionBuilder

MinionElastic

G@roles:builder and G@environment:test

Page 36: From Code to Kubernetes

Selectors

Master

MinionBuilder

Executed imperatively via command line or reactively via Salt Reactor.

salt cli selector command

Page 37: From Code to Kubernetes

Salt Pillars"Offer global values that can be distributed to minions"

Page 38: From Code to Kubernetes
Page 39: From Code to Kubernetes
Page 40: From Code to Kubernetes

Salt States"The SLS is a representation of the state in which a system should be in, and is

set up to contain this data in a simple format."

Page 41: From Code to Kubernetes

state ID

modulename.command

arguments

Page 42: From Code to Kubernetes
Page 43: From Code to Kubernetes

Using defined pillars within states

● Introducing the map.jinja file

● Passing pillars values when compiling states

Page 44: From Code to Kubernetes
Page 45: From Code to Kubernetes

Output to MinionParse + Merge

SaltStack Compilation Process

+ =Pillarsdictionaries

Statesjinja2

Low Data

Parse

Page 46: From Code to Kubernetes

Gitfs"The gitfs backend allows Salt to serve files from git repositories."

Page 47: From Code to Kubernetes

push 15s

Master

Gitfs

Page 48: From Code to Kubernetes

Putting all together

Page 49: From Code to Kubernetes

Desired State● 8 VMs

○ Salt Master○ Operator○ Builder○ Postgresql○ Elasticsearch○ 3 Kubernetes nodes

● 2 Persistent Data Disks: 500GB attached to PG and ELS● 1 Kubernetes Cluster● Network

○ Required Firewall Rules○ 2 Subnets

● 2 IAM/Service Accounts: Pull/Push Docker Registry

Page 50: From Code to Kubernetes

Complete Cloud Provision Flow

NetworkFirewall, Subnets, Static IPs,

...

InstancesSalt Master, Salt Minion,

Postgresql, Elasticsearch, Builder, Operator

KubernetesCluster

Nodes, Firewall Rules, K8S Master and Workers

● $ terraform apply

Salt states are applied just after an instance is created, based on its "role" specified in the grains config

Core resources are created during this phase

Creates the initial cluster state based on the number of nodes specified

Page 51: From Code to Kubernetes
Page 52: From Code to Kubernetes

Work is done!

Page 53: From Code to Kubernetes

Google Cloud Admin Panel

Page 54: From Code to Kubernetes
Page 55: From Code to Kubernetes
Page 56: From Code to Kubernetes

http://kubernetes.io/

Page 57: From Code to Kubernetes

Kubernetes Dashboard

Page 58: From Code to Kubernetes
Page 59: From Code to Kubernetes
Page 60: From Code to Kubernetes

Show me the flow!

Page 61: From Code to Kubernetes

Salt API

https

http

s

ssh

Builder

Operator

runnersreactor

Event Hubhttps

Page 62: From Code to Kubernetes

Building and Deploying

Page 63: From Code to Kubernetes

Kubernetes Objects"Kubernetes Objects are persistent entities in the Kubernetes system. Kubernetes uses these entities to represent the state of your cluster."

Page 64: From Code to Kubernetes

Kubernetes objects

● Abstracts: deployments, services, replica sets, ingress, ...

● Generated on the fly by Salt using templates

● Final .yaml file compiled including pillars and arguments

● $ kubectl apply -f mysite-development.yaml

● Garbage collector

Page 65: From Code to Kubernetes

deploymentV1.yaml

Page 66: From Code to Kubernetes

Builder

1 2

3

4 5

67

8

Code to Image FlowRegistry

Reactor

push

state.apply

notifynotify

notify

push notify

Page 67: From Code to Kubernetes

Operator

Kubernetes Deployment Flow

Registry

Reactor (Post Build)

Pullkubectlstate.apply12 4

notify3

5

notify6

Page 68: From Code to Kubernetes

https://operable.io/ChatOps

Page 69: From Code to Kubernetes

Build

Build

Page 70: From Code to Kubernetes

Rollback

Page 71: From Code to Kubernetes

Application Debugginghttps://www.weave.works/products/weave-scope/

Page 72: From Code to Kubernetes
Page 73: From Code to Kubernetes
Page 74: From Code to Kubernetes
Page 75: From Code to Kubernetes
Page 76: From Code to Kubernetes

DemoLive from code to Kubernetes!

Page 77: From Code to Kubernetes

FutureWhat must be improved?

● Error Handling● Credentials Management● Logging and Monitoring● On Demand Environments● Terraform File Refactoring● Implement Production● Rollout Deployments ● Postgresql Cluster● Elasticsearch Cluster● ...

Page 78: From Code to Kubernetes

Wrap upWhat I've seen so far?

● Automated provision

● Infrastructure as Code

● Event driven environment

● Fast delivery cycle

● Isolated environments

● Application Debugging

● ChatOps

Page 79: From Code to Kubernetes

Final Words

Page 80: From Code to Kubernetes

Doesn't have to be perfect from day 0!

Page 81: From Code to Kubernetes

Pick up the right people

"When you get into one of these groups, there's only a couple of ways you can get out: one is death, the other is mental institutions..." - Devops Engineer testimonial

Page 82: From Code to Kubernetes

LinksSaltstack - https://saltstack.com

Salt States - https://docs.saltstack.com/en/latest/topics/tutorials/starting_states.html

Salt Pillars - https://docs.saltstack.com/en/latest/topics/pillar/

Terraform - https://www.terraform.io/intro/index.html

Weavescope - https://www.weave.works/products/weave-scope

Kubernetesio - http://kubernetes.io

Jenkins CI - https://jenkins.io

Docker - https://docker.com

Google Cloud Platform - cloud.google.com

GCP Calculator - https://cloud.google.com/products/calculator/

Page 83: From Code to Kubernetes

Danke Schön!

Page 84: From Code to Kubernetes

Questions?