Microservices In The Cloud Using Kubernetes, Docker, And Jenkins

Transcription

Microservices in the Cloudusing Kubernetes, Docker andJenkinsSATURN May 3rd, 2017@KurtStam, PhD,Principal Engineer on the #Fabric8/Fuse team

Content MicroAdventures & MicroServicesIntroduction to DockerIntroduction to Kubernetes/OpenShiftDemo of RPi Cluster running K8sJenkins: Fabric8 CI/CD Pipeline

Spitsbergen Exp 1985

Spitsbergen 1985

Spitsbergen 1985

Spitsbergen 1985

#microadventures

#microadventures

#microadventures

Monolith and Conventional DeploymentLots of planningDifferent teams and responsibilitiesRegression IssuesCheap to start, hard to maintain when you hit a certaincomplexity level

Micro Services Micro Services are about time to marketComponent reuse, not code reuse.‘One concern’: Simple and small, but not too smallEasy to test, limited risk of regressions, CI/CDOne team from development to deploymentAPI Contract (REST & Swagger), API ManagerPerfect for cloud deployment!

Java Micro Services AngularJS UI for display logic REST Service(s) Swagger 2 for business backend SQL/No-SQL store & Caching

Open Source Cloud: Virtualization of the entire stack Fabric8: iPaas OpenShift: Paas Kubernetes: DockerOrchestration Docker OS Level Virtualization

Open Source Cloud: Virtualization of the entire stack

Shipping software is hard

Matrix from Hell

Analogy with Cargo Transport Pre-1960

Same Matrix from Hell

Solution: Intermodal Shipping Container

Docker is the Shipping Container for Code

VMs versus Container

Docker Demo: Hello WorldBase Image Shared KernelProcess IsolationLayers: pull, commit, pushDockerHubCentos: yum install dockerdocker run centos echo hello worlddocker run -it centos bashhttps://hub.docker.com/r/kurtstam/saturn

Docker Demo: DockerfileFROM php:5.6-apache(https://hub.docker.com/ /php/)COPY src/ /var/www/html/docker build -t php-hello-world .docker run -it -p 80:8001 php-hello-world

Computational Resources: Cloud

KubernetesKubernetes: ‘Helmsman of a ship’based on Borg experiencesContainer (Docker, Rocket) OrchestrationCloud Operating SystemThree flavors:OpenShift OnLine (Public PaaS) running on Amazon, Google, etc cloudsOpenShift Enterprise (Private Paas), running in your data centerOrigin (Community Paas), running on a laptop (MiniKube, MiniShift)

Kubernetes

Kubernetes Pod

Kubernetes PodA Pod contains one or more containersContainers within a pod are tightly coupledConsumersgit RepoShared namespaces Containers in a pod share IP, port and IPCnamespaces Containers in a pod talk to each other throughlocalhostGitSynchronizerPodVolume

Kubernetes Pod NetworkingPods have IPs which are routable10.1.2.106Pods can reach each other without NATEven across nodesNo Brokering of Port Numbers10.1.2.0/2410.1.1.21110.1.1.2These are fundamental requirements10.1.1.0/24Many solutionsFlannel, Weave, OpenVSwitch, Cloud Provider10.1.3.4510.1.3.17Let’s deploy a pod!10.1.3.0/2410.1.3.0/24

Kubernetes ServiceA logical grouping of pods that perform thesame functionClient grouped by label selectorLoad balances incoming requests acrossconstituent podsVIPServiceChoice of pod is random but supportssession affinity (ClientIP)Label selector:type FEGets a stable virtual IP and port also a DNS nameLet’s deploy a service!PodContainertype FEPodContainertype FEPodContainerContainertype FE

Kubernetes lerController#pods 2version v1Podversion v1PodPodPodPodfrontendfrontendversion v1version v2ReplicationController#pods 1version v2show: version v2show: version v2 Keeps Pods runningGives direct control of Pod #sGrouped by Label SelectorLet’s scale a service!

Developer ViewImageConfigfilewebweb browsersbrowserskubectlK8s MasterDashBoardpersistentstore (Paxos)schedulerAPI y

Kubernetes on RaspberryPihttp://www.github.com/Project31

Shopping ListTo build this four-Pi setup I used: 4 Raspberry Pi 2s4 16GB MicroSD cards (Class 10)1 60W power supply with USB outlets4 short USB to Micro USB cables (for powering the Pis)4 short Cat 5 network cables1 longer Cat 5 network cable to hook into your network1 network hub (Mine is an old five-port, 10/100MBps I dusted off)LEGOs (Trust me, it feels good to build your own!)

Fabric8 Management:Fabric8Hawtio Console, Logging, Metrics, Maven plugin----------------------- containers -------------------------------Fabric8 iPaas:ActiveMQ Messaging, Camel, API managementiPaaS Quickstarts:micro service examplesFabric8 DevOps:CD pipeline, jenkins, gogs, chat, gerrit, hubot(q)

Developer Experience

Developer SystemsContinuous ImprovementSocialTransparencySystems AvailabilityAutomation

Continuous Delivery Pipeline using Fabric8 and Jenkins Demo

Questions?Fabric8.ioFabric8 Microservices PlatformGet StartedCreate a Kubernetes Cluster with Fabric8Docker.comCreate and Run Container ImagesKubernetes.ioContainer based CloudOpenshift.orgRed Hat product based on Kubernetes@KurtStam

References[1] http://www.fabric8.io[2] http://www.apiman.io[3] @tekggrl "Kubernetes: From Beginner to Expert"[4] http://www.github.com/Project31[5] s-cloud-with-raspberry-pi

Pico Cluster100 RPi boards:400 Cores400 GB RamStorage on clustered MicroSDor SAN8,000

Kubernetes on RaspberryPiDisruptive technology: Platform of tomorrowOpen Source EverythingLow costLow powerRedundantDistributedSuper scalable

Microservices in the Cloud Using Kubernetes, Docker, and Jenkins Author: Kurt Stam (Red Hat) Subject: This presentation introduces Docker and Kubernetes, dives into microservices development and deployment using CI/CD pipelines, and shows a demo of a cloud-in-a-box. Created Date: 5/3/2017 4:11:17 PM