From Bare-Metal Windows to Kubernetes in Two Months Paul Steele - - PowerPoint PPT Presentation

from bare metal windows to kubernetes in two months
SMART_READER_LITE
LIVE PREVIEW

From Bare-Metal Windows to Kubernetes in Two Months Paul Steele - - PowerPoint PPT Presentation

From Bare-Metal Windows to Kubernetes in Two Months Paul Steele #IndyCloudConf About Me Software Engineer at SEP Purdue University https://blog.paul-steele.com/ #IndyCloudConf Greenfield #IndyCloudConf Legacy #IndyCloudConf


slide-1
SLIDE 1

From Bare-Metal Windows to Kubernetes in Two Months

Paul Steele

#IndyCloudConf

slide-2
SLIDE 2

About Me

  • Software Engineer at SEP
  • Purdue University
  • https://blog.paul-steele.com/

#IndyCloudConf

slide-3
SLIDE 3

Greenfield

#IndyCloudConf

slide-4
SLIDE 4

Legacy

#IndyCloudConf

slide-5
SLIDE 5

Agenda

  • Journey of migrating legacy application to the cloud
  • Showcase some of the “gotchas” we found

#IndyCloudConf

slide-6
SLIDE 6

The Application

  • Incident tracking software
  • C# application

○ IIS ○ Self Hosted - Bare Metal

  • 10-15 years old

○ Architectural tradeoffs

  • Supplemental windows services

○ Background tasks ○ Email ○ Indexing

#IndyCloudConf

slide-7
SLIDE 7

Feature Development

  • Two main teams

○ One in Indianapolis (SEP) ○ One several states away

  • Focused solely on Development
  • Never had the “budget” for DevOps

#IndyCloudConf

slide-8
SLIDE 8

Problems

  • Jenkins

○ Old ○ Only accessible to one team

  • App hard to deploy

○ Manual file drops ○ Long list of instructions

  • No automated database setup

○ No way to create a blank database

#IndyCloudConf

slide-9
SLIDE 9

What did this cause?

  • Uncertainty of state of code

○ Was the master branch passing?

  • Slow QA cycles

○ Ask for a server to be setup ■ Days to weeks ○ Check bug ○ Repeat if necessary

  • Deployed wrong version to production

#IndyCloudConf

slide-10
SLIDE 10

Where We Came In

  • Budget approved to move to the cloud

○ Azure ○ CI / CD pipeline ○ Deployments

  • Wanted to experiment with new technologies

○ Docker ○ Kubernetes

  • Team of three
  • Two months to pull it off

#IndyCloudConf

slide-11
SLIDE 11

Goals for the engagement

  • Get into the cloud

○ Containerize Application ○ Automated Database Creation ○ Setup Jenkins ○ Push button deployments into test environment ■ Not enough time to get into production

  • Everything should be scripted

#IndyCloudConf

slide-12
SLIDE 12

Containerizing the Application

#IndyCloudConf

slide-13
SLIDE 13

Containerizing The Application

  • C# legacy application

○ No .net core

  • Can’t use linux containers

#IndyCloudConf

slide-14
SLIDE 14
slide-15
SLIDE 15

Containers

  • Share Kernel Space
  • Linux

○ Few Compatibility Problems ○ Try to use newer kernel feature ■ Runtime error

  • Windows

○ Compatibility Problems ○ Try to use newer kernel feature ■ Startup error

#IndyCloudConf

slide-16
SLIDE 16

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-17
SLIDE 17

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-18
SLIDE 18

Windows Isolation Levels

  • Process isolation

○ Actual containers

  • Hyper-V isolation

○ Pretender containers

  • None of this was obvious to us setting out

#IndyCloudConf

slide-19
SLIDE 19

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-20
SLIDE 20

Helper Services

  • The container would start up IIS

#IndyCloudConf

slide-21
SLIDE 21

Helper Services

  • Chose option 2

#IndyCloudConf

slide-22
SLIDE 22

Fundamental Application Problems

  • App configurations in various flat files.

○ Not in source control

  • IIS configuration

○ Not in source control

  • Helper services configuration

○ Not in source control

  • Deployment required manually editing these files

○ Highly error prone

#IndyCloudConf

slide-23
SLIDE 23

Addressing Configuration

  • Consolidated configurations

○ Standard location ○ Source control ○ Templated the configurations ○ 95% of configurations standard ○ On container start, fill in templates

  • Controlled by environment

variables

#IndyCloudConf

slide-24
SLIDE 24

Goals for the engagement

  • Get into the cloud

○ Containerize Application ○ Automated Database Creation ○ Setup Jenkins ○ Push button deployments into test environment

  • Everything should be scripted

#IndyCloudConf

slide-25
SLIDE 25

Automated Database Creation

#IndyCloudConf

slide-26
SLIDE 26

State of the Database

  • Microsoft SQL
  • No clean setup
  • Version x.7 introduced App migrations

○ Years of manual schema updates up to x.7

  • Support creation for both

○ Azure SQL ○ Docker Database

#IndyCloudConf

slide-27
SLIDE 27

A way forward

  • Found a series of test scripts
  • One script to get to version x

○ 7 scripts for each minor version

#IndyCloudConf

slide-28
SLIDE 28

The script

  • Added test data as it went

#IndyCloudConf

slide-29
SLIDE 29

Untangling

  • Hopeful we could add

some conditionals

#IndyCloudConf

slide-30
SLIDE 30

Not so Lucky

  • Schema scripts relied on

some data existing...

#IndyCloudConf

slide-31
SLIDE 31

Result

  • Fixing took longer than we wanted
  • Had the ability to create a database from scratch

○ With / Without test data

#IndyCloudConf

slide-32
SLIDE 32

Goals for the engagement

  • Get into the cloud

○ Containerize Application ○ Automated Database Creation ○ Setup Jenkins ○ Push button deployments into test environment

  • Everything should be scripted

#IndyCloudConf

slide-33
SLIDE 33

Setup Jenkins

#IndyCloudConf

slide-34
SLIDE 34
  • Solution template

○ Azure Marketplace ○ All the basics to jump start a jenkins instance

  • Utilized packer to create master image, and build

agent images

  • Ondemand Build Agents
  • Artifact Storage

○ Could use to deploy past testing

Next Step : Jenkins

https://azuremarketplace.microsoft.com/en-us/marketplace/apps/azure-oss.jenkins

#IndyCloudConf

slide-35
SLIDE 35

Structure of Jenkins

#IndyCloudConf

slide-36
SLIDE 36

Build Agents

  • Virtual Machines

○ Finer control of agents themselves

■ Cpu / memory ■ More to manage

○ Slower to spin up

■ Tend to reuse

○ Expensive

  • Containers

○ Less control of agents

■ Less to manager

○ Faster to spin up ○ Take advantage of existing infrastructure

■ Kubernetes

#IndyCloudConf

slide-37
SLIDE 37

Container build agents sound like the clear choice right?

#IndyCloudConf

slide-38
SLIDE 38

We Chose Virtual Machines

#IndyCloudConf

slide-39
SLIDE 39

Why

  • Build agents need to build our

containers

  • Need Docker in Docker

○ Not supported in Windows

slide-40
SLIDE 40

Jenkins Overview

  • Multibranch pipeline for builds

○ Didn’t have CI builds for branches before ○ Didn’t build application in dockerfile

■ Archive to azure blob storage

#IndyCloudConf

slide-41
SLIDE 41

Database Creation

  • Database Creation Job

○ System Testing ○ QA environments

#IndyCloudConf

slide-42
SLIDE 42

System Tests

  • System Test Job

○ Ran Integration tests for master branch ○ Challenge to modify the tests to work in Jenkins

■ Ran the app container in on the vm agents

#IndyCloudConf

slide-43
SLIDE 43

Deployment Job

  • Application Deployment Job

○ Deploy container ○ Deploy Where?

#IndyCloudConf

slide-44
SLIDE 44

Goals for the engagement

  • Get into the cloud

○ Containerize Application ○ Automated Database Creation ○ Setup Jenkins ○ Push button deployments into test environment

  • Everything should be scripted

#IndyCloudConf

slide-45
SLIDE 45

Push Button Deployment

#IndyCloudConf

slide-46
SLIDE 46

Enter Kubernetes

  • Azure? Use AKS!

○ Windows containers not natively supported ○ Better than AWS, or Google Cloud

  • Options?

○ Virtual Kubelet ○ acs-engine

https://github.com/virtual-kubelet/virtual-kubelet#how-it-works #IndyCloudConf

slide-47
SLIDE 47

ACS Engine

  • Generated Solution Templates
  • “Mimic’d” ACS with virtual machines
  • Allowed creating Kubernetes Instances

○ Supported swarm

  • Supported Hybrid Clusters
  • Has since been deprecated for aks-engine
  • Config files for ACS stored in source control

#IndyCloudConf

slide-48
SLIDE 48

Kubernetes

  • Master Node

○ Linux ○ Ran Nginx Ingress Controller + Certmanager

  • Other Nodes

○ Windows ○ With our VM choice could fit 4 Applications per node ■ ACS engine provided node auto scaling

#IndyCloudConf

slide-49
SLIDE 49

Goals for the engagement

  • Get into the cloud

○ Containerize Application ○ Automated Database Creation ○ Setup Jenkins ○ Push button deployments into test environment

  • Everything should be scripted

#IndyCloudConf

slide-50
SLIDE 50

So We’re Done!!!

#IndyCloudConf

slide-51
SLIDE 51

Right?

#IndyCloudConf

slide-52
SLIDE 52

Aren't we Done?

  • Jenkins performance was pitiful

○ Large base images

■ 10 minutes to pull base layer ■ Slow to build the container

○ System Tests

■ Inconsistent Failures ■ Slow

#IndyCloudConf

slide-53
SLIDE 53

Quick Fixes

  • Pull base layer during image creation

○ Adds extra time to image creation

■ Better than every build

  • Parallelize System Tests

○ From 1 node to 5

■ Budget constraints

#IndyCloudConf

slide-54
SLIDE 54

Larger Problem

  • Slow Container Builds

○ Were using hyper-v isolation not process isolation

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-55
SLIDE 55

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-56
SLIDE 56

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-57
SLIDE 57

What could go wrong?

  • VM agents started taking twice as long to spin up

○ 20 minutes at worst case

  • Container start time did improve however

#IndyCloudConf

slide-58
SLIDE 58

System Tests

  • System Tests were still flakey
  • Narrowed it down to Time skew

○ 30 minute offset inside the container

#IndyCloudConf

slide-59
SLIDE 59

The solution

  • Use a different base image,

○ Upgrade to the latest and greatest ○ Continue to use process isolation

#IndyCloudConf

slide-60
SLIDE 60

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-61
SLIDE 61

https://blogs.msdn.microsoft.com/azureservicefabric/2016/04/25/orchestrating-containers-with-service-fabric/ #IndyCloudConf

slide-62
SLIDE 62

Keep VM Agents around

  • Half of the time for CI builds was waiting for Vms
  • Keep them around for 1 hour

#IndyCloudConf

slide-63
SLIDE 63

#IndyCloudConf

slide-64
SLIDE 64

Results after Two months

  • Successful System Tests
  • VM agents

○ Spun in 7 minutes ○ Persist between builds

  • CI builds

○ Best Case < 10 minutes

  • Push Button Deployment to Kubernetes

#IndyCloudConf

slide-65
SLIDE 65

Before

Months to deploy

#IndyCloudConf

slide-66
SLIDE 66

After

Hours to Deploy

#IndyCloudConf

slide-67
SLIDE 67

Key Takeaways

  • Tooling for windows containers is lacking

○ Until 1803, not worth trying ■ Slow ■ Buggy

  • If we didn’t script all of this, never would have gotten done

○ Took a little longer upfront ○ All those vm changes, required full rebuild

  • Cloud costs need to be monitored

#IndyCloudConf

slide-68
SLIDE 68

Questions?

#IndyCloudConf

slide-69
SLIDE 69

Thanks!

  • Slides can be found:

https://info.sep.com/2019indycloudconf

  • SEP blog:

https://www.sep.com/sep-blog/2019/04/11/migrating-a- legacy-asp-net-application-to-azure/

#IndyCloudConf