29
A Primer to Containerization & Microservices Shiju Varghese

A Primer to Containerization & Microservices

Embed Size (px)

Citation preview

Page 1: A Primer to Containerization & Microservices

APrimertoContainerization&Microservices

ShijuVarghese

Page 2: A Primer to Containerization & Microservices

AboutMe

• ConsultingSolutionsArchitect• FocusedonGoandGoogleCloud

@shijucv|https://medium.com/@shijuvar

Page 3: A Primer to Containerization & Microservices
Page 4: A Primer to Containerization & Microservices

Agenda

• IntroductiontoMicroservices• IntroductiontoContainerization• AnOverviewofContainerEcosystem• MicroservicesonContainers

Page 5: A Primer to Containerization & Microservices

Microservices

Page 6: A Primer to Containerization & Microservices

Monolith Microservices

• Composedofasuiteofsmallservices.

• Eachservicerunsinitsownprocess.

• Greaterflexibilityforscalability.

• PutallbusinesscapabiliKesintoasingleapplicaKon.

• ApplicaKonrunsinasingleprocess.

• Scaleshorizontallybyrunning

mulKpleinstancesofmonolith.

Page 7: A Primer to Containerization & Microservices

Microservicesisanarchitecturalstyleinwhichsoftwareapplicationsarecomposedofasuiteofindependentlydeployable,small,modularservices.EachoftheseMicroservicesfocusesoncompletingonetaskthatrepresentsasmallbusinesscapability.Theycommunicatewitheachotherusinglanguage-agnosticprotocolssuchasRepresentationalStateTransfer(REST),ormessagingsystems.Inanutshell,Microservicesaresmall,autonomousservicesthatworktogether.

Page 8: A Primer to Containerization & Microservices

» Softwarebrokenupintofunctionalcomponents.» ComponentizationviaServicesinwhicheachserviceispackagedasoneunitofexecution.

» Independent,autonomousprocesswithnodependencyonotherMicroservices.

» Servicesareorganizedaroundbusinesscapability.» DecentralizationofDataManagement.» Independentlyreplaceableandupgradeable.

AutonomousServicesaroundBoundedContext

Page 9: A Primer to Containerization & Microservices

CommunicationbetweenServices

» Synchronous» REST

» Asynchronous» AMQP» RabbitMQ,ApacheKafka,CloudnativePub/Sub

Page 10: A Primer to Containerization & Microservices

KeyBenefits

» Tacklestheproblemofcomplexity.» FlexibilityforPolyglottechnologystack.» Resilience.» FlexibilityforScalability.» EaseofDeployment.» OrganisationalAlignment.» Composability.» OptimisingforReplaceability.

Page 11: A Primer to Containerization & Microservices

DeployingMicroservices

Page 12: A Primer to Containerization & Microservices

UnitofDeployment

» PhysicalServer» VirtualMachine(VM)» Container

Page 13: A Primer to Containerization & Microservices

DeploymentPatterns

» MultipleServiceInstancesperHost» ServiceInstanceperHost» ServerlessDeployment» AWSLambda» GoogleCloudFunctions

Page 14: A Primer to Containerization & Microservices

RunningMicroservicesonContainers

Page 15: A Primer to Containerization & Microservices

Acollectionofindependent,autonomouscontainersparticipatinginanapplicationdefinestheMicroservicesarchitecture.

Microservices-UnitofDeploymentofasContainer

Page 16: A Primer to Containerization & Microservices

Container

» LightweightLinuxenvironment.» Hermeticallysealed,deployableapp.» Separateappsfrominfrastructure.» DevelopappagainstanidealizedOS-AstaticLinuxenvironment.

» PopularizedandrevolutionizedbyDocker.

Page 17: A Primer to Containerization & Microservices

WhyDoDevelopersLikeIt?

» Reliabledeployment» Staticapplicationenvironment;Immutableinfrastructure

» Portability» Separateapplicationsfromwhereitruns» Repeatablerunnableartifact» Runanywhere

» SpeedandLightweight» Bootsinseconds» 100-1000containersononemachine.

» LooselyCoupled» ComposeappsfromautonomousMicroservices

Page 18: A Primer to Containerization & Microservices

Docker

Dockerisanopen-sourceenginetoeasilycreatelightweight,portable,self-sufficientcontainersfromanyapplication.Thesamecontainerthatadeveloperbuildsandtestonalaptopcanrunatscale,inproduction,onVMs,privatecloud,publiccloudsandmore.

Page 19: A Primer to Containerization & Microservices

» Openplatformforcontainers.» Anecosystemforbuild,ship,andrundistributedapplications.

» Alightweightcontainervirtualizationplatform.» BuiltonLinuXContainers(LXC)» WritteninGolanguage.

Page 20: A Primer to Containerization & Microservices

ComponentsofDocker

» Docker-Aportable,lightweightruntimeandpackagingtoolforbuildingcontainerizedapps.

» DockerHub-SoftwareasaServiceplatformforsharingandmanagingDockerimages.

Page 21: A Primer to Containerization & Microservices

DockerFundamentals

» DockerImages-Imagesholdyourapps.» DockerRegistries-RegistryforsharingDockerimagesviaDockerHuborprivateregistrysystem.

» DockerContainers-CreatecontainersfromDockerimagestorunapps.

» Dockerfile-Atextdocumentthatcontainsinstructionstobuildadockerimage.

Page 22: A Primer to Containerization & Microservices

DockerCompose

Composeisatoolfordefiningandrunningmulti-containerDockerapplications.

Page 23: A Primer to Containerization & Microservices

#golangimagewhereworkspace(GOPATH)configuredat/go.FROMgolang

#Copythelocalpackagefilestothecontainer’sworkspace.ADD./go/src/github.com/shijuvar/go-web/taskmanager

#SettingupworkingdirectoryWORKDIR/go/src/github.com/shijuvar/go-web/taskmanager

#GetgodepsformanagingandrestoringdependenciesRUNgogetgithub.com/tools/godep

#RestoregodepdependenciesRUNgodeprestore

#Buildthetaskmanagercommandinsidethecontainer.RUNgoinstallgithub.com/shijuvar/go-web/taskmanager

#Runthetaskmanagercommandwhenthecontainerstarts.ENTRYPOINT/go/bin/taskmanager

#Servicelistensonport8080.EXPOSE8080

Page 24: A Primer to Containerization & Microservices

//BuildimagefromDockerfile$dockerbuild-ttaskmanager.

//RunDockerimageandpublishingawebapp$dockerrun—publish3000:8080—namegoweb—rmtaskmanager

Page 25: A Primer to Containerization & Microservices

ContainerClusters

» DockerSwarm» GoogleKubernetes» CoreOSTectonic» ApacheMesos

Page 26: A Primer to Containerization & Microservices

Container-CentricMicroOS

» CoreOS» UbuntuSnappy» RancherOS» RedHatAtomicHost» VMwarePhoton

Page 27: A Primer to Containerization & Microservices

ContainerizationonCloud

Page 28: A Primer to Containerization & Microservices

ContainerasaService(CaaS)

» GoogleContainerEngine» AmazonEC2ContainerService