A Primer to Containerization & Microservices

Preview:

Citation preview

APrimertoContainerization&Microservices

ShijuVarghese

AboutMe

• ConsultingSolutionsArchitect• FocusedonGoandGoogleCloud

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

Agenda

• IntroductiontoMicroservices• IntroductiontoContainerization• AnOverviewofContainerEcosystem• MicroservicesonContainers

Microservices

Monolith Microservices

• Composedofasuiteofsmallservices.

• Eachservicerunsinitsownprocess.

• Greaterflexibilityforscalability.

• PutallbusinesscapabiliKesintoasingleapplicaKon.

• ApplicaKonrunsinasingleprocess.

• Scaleshorizontallybyrunning

mulKpleinstancesofmonolith.

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

» Softwarebrokenupintofunctionalcomponents.» ComponentizationviaServicesinwhicheachserviceispackagedasoneunitofexecution.

» Independent,autonomousprocesswithnodependencyonotherMicroservices.

» Servicesareorganizedaroundbusinesscapability.» DecentralizationofDataManagement.» Independentlyreplaceableandupgradeable.

AutonomousServicesaroundBoundedContext

CommunicationbetweenServices

» Synchronous» REST

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

KeyBenefits

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

DeployingMicroservices

UnitofDeployment

» PhysicalServer» VirtualMachine(VM)» Container

DeploymentPatterns

» MultipleServiceInstancesperHost» ServiceInstanceperHost» ServerlessDeployment» AWSLambda» GoogleCloudFunctions

RunningMicroservicesonContainers

Acollectionofindependent,autonomouscontainersparticipatinginanapplicationdefinestheMicroservicesarchitecture.

Microservices-UnitofDeploymentofasContainer

Container

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

» PopularizedandrevolutionizedbyDocker.

WhyDoDevelopersLikeIt?

» Reliabledeployment» Staticapplicationenvironment;Immutableinfrastructure

» Portability» Separateapplicationsfromwhereitruns» Repeatablerunnableartifact» Runanywhere

» SpeedandLightweight» Bootsinseconds» 100-1000containersononemachine.

» LooselyCoupled» ComposeappsfromautonomousMicroservices

Docker

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

» Openplatformforcontainers.» Anecosystemforbuild,ship,andrundistributedapplications.

» Alightweightcontainervirtualizationplatform.» BuiltonLinuXContainers(LXC)» WritteninGolanguage.

ComponentsofDocker

» Docker-Aportable,lightweightruntimeandpackagingtoolforbuildingcontainerizedapps.

» DockerHub-SoftwareasaServiceplatformforsharingandmanagingDockerimages.

DockerFundamentals

» DockerImages-Imagesholdyourapps.» DockerRegistries-RegistryforsharingDockerimagesviaDockerHuborprivateregistrysystem.

» DockerContainers-CreatecontainersfromDockerimagestorunapps.

» Dockerfile-Atextdocumentthatcontainsinstructionstobuildadockerimage.

DockerCompose

Composeisatoolfordefiningandrunningmulti-containerDockerapplications.

#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

//BuildimagefromDockerfile$dockerbuild-ttaskmanager.

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

ContainerClusters

» DockerSwarm» GoogleKubernetes» CoreOSTectonic» ApacheMesos

Container-CentricMicroOS

» CoreOS» UbuntuSnappy» RancherOS» RedHatAtomicHost» VMwarePhoton

ContainerizationonCloud

ContainerasaService(CaaS)

» GoogleContainerEngine» AmazonEC2ContainerService

ShijuVarghesegophermonk@gmail.com

Recommended