ebook img

Kubernetes 101 PDF

128 Pages·2021·12.004 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Kubernetes 101

Kubernetes 101 Learn the basics of Kubernetes and container-based infrastructure. Jeff Geerling and Katherine Geerling Thisbookisforsaleathttp://leanpub.com/kubernetes-101 Thisversionwaspublishedon2021-07-29 ThisisaLeanpubbook.Leanpubempowersauthorsand publisherswiththeLeanPublishingprocess.Lean Publishingistheactofpublishinganin-progressebook usinglightweighttoolsandmanyiterationstogetreader feedback,pivotuntilyouhavetherightbookandbuild tractiononceyoudo. ©2021JeffGeerlingandKatherineGeerling Tweet This Book! PleasehelpJeffGeerlingandKatherineGeerlingby spreadingthewordaboutthisbookonTwitter! Thesuggestedtweetforthisbookis: IjustboughtKubernetes101byJeffGeerlingonLeanPub! Checkitoutathttps://leanpub.com/kubernetes-101 #Kube101 Thesuggestedhashtagforthisbookis#kube101. Findoutwhatotherpeoplearesayingaboutthebookby clickingonthislinktosearchforthishashtagonTwitter: #kube101 Also By Jeff Geerling AnsibleforDevOps AnsibleforKubernetes Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i Whoisthisbookfor? . . . . . . . . . . . . . . . . . . ii Typographicconventions . . . . . . . . . . . . . . . . ii Pleasehelpimprovethisbook! . . . . . . . . . . . . . iv CurrentPublishedBookVersionInformation . iv AbouttheAuthor. . . . . . . . . . . . . . . . . . . . . iv Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . v ExamplesRepository . . . . . . . . . . . . . . . . . . . viii Otherresources . . . . . . . . . . . . . . . . . . . . . . ix Chapter1-Hello,Kubernetes! . . . . . . . . . . . . . . 1 KubernetesOrigins . . . . . . . . . . . . . . . . . . . . 1 IsKubernetesRightforYou? . . . . . . . . . . . . . . 3 KubernetesEnvironments . . . . . . . . . . . . . . . 5 InstructionsforMinikube . . . . . . . . . . . . . . . . 6 BuildingtheexampleDockerimage . . . . . . . . . 8 Chapter2-Containers . . . . . . . . . . . . . . . . . . . 10 WhydoesKubernetesusecontainers? . . . . . . . . 10 ContainerHistory:VendorWars . . . . . . . . . . . 11 Docker,containerd,andrunC . . . . . . . . . . 12 rktandCoreOS . . . . . . . . . . . . . . . . . . . 14 KubernetesContainerRuntime . . . . . . . . . 14 CONTENTS CRI-O . . . . . . . . . . . . . . . . . . . . . . . . . 14 ModernContainerRuntimeoptions. . . . . . . 15 Howdoyoubuildacontainer?DockervsBuildah 15 Instructionsfor‘HelloGo’app . . . . . . . . . . . . . 16 Buildthe‘HelloGo’Dockercontainerimage . . . . 17 PushthecontainerimagetoaprivateDockerregistry 17 Chapter3-Deployingapps . . . . . . . . . . . . . . . . 19 CreatingaLinodeClusterforcloud-basedtesting . 19 DeployingHelloGointoKubernetes . . . . . . . . . 21 ExposingtheHelloGoApp. . . . . . . . . . . . . . . 24 ScalingtheHelloGoApp . . . . . . . . . . . . . . . . 26 UpdatingtheGoApp . . . . . . . . . . . . . . . . . . 28 RollingbacktheDeployment . . . . . . . . . . . . . 29 Chapter4-Real-worldapps . . . . . . . . . . . . . . . . 30 InstallingDrupalonaTraditionalLAMPserver . . 30 LAMPServerSetupfordrupal . . . . . . . . . . 31 AutomatingtheInstallation . . . . . . . . . . . . . . 34 Installing Drupal on Kubernetes using Bitnami’s HelmChart . . . . . . . . . . . . . . . . . . . . 35 InstallHelm . . . . . . . . . . . . . . . . . . . . . 36 InstalltheDrupalChart . . . . . . . . . . . . . . 36 ExposingaLoadBalancerinMinikube . . . . . 37 ChangingChartOptions . . . . . . . . . . . . . 37 CleaningUp . . . . . . . . . . . . . . . . . . . . . 38 DrupalDirectlyinKubernetes-Let’sDoit[Mostly 38 DeployingtheDrupalKubernetesManifests . 39 Chapter5-ScalingDrupalink8s. . . . . . . . . . . . . 43 FixingthescalabilityissuewithDrupalPods . . . . 43 SharedStorageOptions . . . . . . . . . . . . . . 44 RookandCeph . . . . . . . . . . . . . . . . . . . 44 NFS . . . . . . . . . . . . . . . . . . . . . . . . . . 45 CONTENTS SetupanNFSserver . . . . . . . . . . . . . . . . . . . 46 Reconfigure the Drupal PersistentVolumeClaim forNFS . . . . . . . . . . . . . . . . . . . . . . 46 SetupNFSclientprovisionerinK8s . . . . . . 47 DeployDrupalandMySQL(MariaDB) . . . . . 48 SaveaFileandobserveit . . . . . . . . . . . . . 49 ScaleDrupalup…anddown! . . . . . . . . . . . . . . 49 UseHorizontalPodAutoscaling(HPA) . . . . . . . 51 Setupmetrics-server . . . . . . . . . . . . . . . 51 ConfiguringHPAforDrupal . . . . . . . . . . . 52 TestingHPAforDrupal . . . . . . . . . . . . . . 53 ScalingDatabases . . . . . . . . . . . . . . . . . . . . 54 Chapter6-DNS,TLS,Cron,Logging . . . . . . . . . . 56 SettingthingsupfromEpisode5 . . . . . . . . . . . 56 DNSandIngresssetupforDrupal . . . . . . . . . . . 57 SetupanNGINXIngressController . . . . . . 60 SetupIngressforDrupal . . . . . . . . . . . . . 61 ExternalDNSIntegration . . . . . . . . . . . . . 61 SetupTLSwithcert-managerandLet’sEncrypt. . 62 KeepingDrupalHappywithaCronJob . . . . . . . 65 MonitoringDrupal’sLogs. . . . . . . . . . . . . . . . 68 UsinganExternalSaaSLogAggregator . . . . 68 RunningyourownELKStack . . . . . . . . . . 69 RelyingonaServiceMesh . . . . . . . . . . . . 69 Usingyourcloudprovider’ssolution . . . . . . 70 Chapter7-Hello,Operator! . . . . . . . . . . . . . . . . 71 WhatareOperators? . . . . . . . . . . . . . . . . . . . 71 TheConcept . . . . . . . . . . . . . . . . . . . . . 72 TheExecution . . . . . . . . . . . . . . . . . . . . 73 WhynotuseanOperator? . . . . . . . . . . . . 75 PopularKubernetesOperators . . . . . . . . . . . . . 76 CONTENTS BuildyourownOperator . . . . . . . . . . . . . . . . 76 BuildinganOperatorwithOperatorSDK . . . 78 Anylanguage,includingPythonorRust! . . . 83 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . 83 Chapter8-Kube,MeetPi . . . . . . . . . . . . . . . . . 84 HeavyMetalKubernetes . . . . . . . . . . . . . . . . 84 StartwithTrainingWheels . . . . . . . . . . . . . . . 85 TheRaspberryPimakesforCompactClusters 86 TheRaspberryPisipsenergy,andkeepsitscool 88 The Raspberry Pi teaches lessons about scala- bility . . . . . . . . . . . . . . . . . . . 89 ARMisnotallsunshineandroses . . . . . . . . 91 InstallingaKubernetesDistribution . . . . . . . . . 92 kubeadm . . . . . . . . . . . . . . . . . . . . . . . 93 SettinguptheRaspberryPiDramble . . . . . . . . . 94 GoingFurther . . . . . . . . . . . . . . . . . . . . . . . 95 OtherGuides . . . . . . . . . . . . . . . . . . . . 96 Chapter9-SecretsandConfiguration . . . . . . . . . 97 Chapter10-MonitoringKubernetes . . . . . . . . . . 98 TwoClusterstoMonitor. . . . . . . . . . . . . . 99 ClusterVisibilitywithLens. . . . . . . . . . . . . . . 99 InstallLens . . . . . . . . . . . . . . . . . . . . . . 100 InspectyourclusterswithLens . . . . . . . . . 100 ExplorePodLogs . . . . . . . . . . . . . . . . . . 101 LogintoNodesandPods . . . . . . . . . . . . . 101 Visitwebservicesinabrowser. . . . . . . . . . 103 Manageresources . . . . . . . . . . . . . . . . . . 103 PrometheusandGrafana . . . . . . . . . . . . . . . . 104 InstallPrometheusandGrafanausingHelm . 104 AccessGrafana . . . . . . . . . . . . . . . . . . . 105 GrafanaDashboards . . . . . . . . . . . . . . . . 108 CONTENTS MaintainingGrafana . . . . . . . . . . . . . . . . 108 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . 108 Afterword . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Preface In 2020, the entire global community experienced a shock in theformoftheCOVID-19pandemic. Entire industries had to pivot overnight or risk ruin. Tech, fortunately for those of us in the industry, was suddenly in highdemand. Since I had a good deal of working knowledge about Ku- bernetes, and since I also finished a popular video series on Ansible earlier in the year, I decided to live-stream a series ‘Kubernetes 101’ to try to train people new to cloud-native infrastructureonthispopularclusteringsoftware. After many thousands of developers have viewed the video series, I decided to translate the content of the video series into this introductory-level book, so even more people could diveintoKubernetesandlearnanewskill. Whether you’re new to infrastructure, or you’re a veteran, Kubernetes can be complex and daunting. This book follows the progress of the video series, and starts with the basics, teaching each new concept with concrete, real-world exam- ples. IhopeyouenjoythebookasmuchasIenjoyedwritingit! —JeffGeerling,2021

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.