Harness Kubernetes' extensibility to deploy modern patterns and learn to effectively handle production issues Key Features Build and run efficient cloud-native applications on Kubernetes using industry best practices Operate Kubernetes in a production environment, troubleshoot clusters, and address security concerns Deploy cutting-edge Kubernetes patterns such as service mesh and serverless to your cluster Book Description Kubernetes is a modern cloud native container orchestration tool and one of the most popular open source projects worldwide. In addition to the technology being powerful and highly flexible, Kubernetes engineers are in high demand across the industry. This book is a comprehensive guide to deploying, securing, and operating modern cloud native applications on Kubernetes. From the fundamentals to Kubernetes best practices, the book covers essential aspects of configuring applications. You'll even explore real-world techniques for running clusters in production, tips for setting up observability for cluster resources, and valuable troubleshooting techniques. Finally, you'll learn how to extend and customize Kubernetes, as well as gaining tips for deploying service meshes, serverless tooling, and more on your cluster. By the end of this Kubernetes book, you'll be equipped with the tools you need to confidently run and extend modern applications on Kubernetes. What you will learn Set up Kubernetes and configure its authentication Deploy your applications to Kubernetes Configure and provide storage to Kubernetes applications Expose Kubernetes applications outside the cluster Control where and how applications are run on Kubernetes Set up observability for Kubernetes Build a continuous integration and continuous deployment (CI/CD) pipeline for Kubernetes Extend Kubernetes with service meshes, serverless, and more Who this book is for This book is for developers, architects, DevOps engineers, or anyone interested in developing and managing cloud-native applications. Those already running cloud applications and looking for a better way to manage their platform or others interested in a career change given the recent popularity of Kubernetes will also find this book helpful. Some familiarity with cloud computing, containers and DevOps is required, but no prior knowledge of building production applications using Kubernetes is needed to get started with this book Cover Title Page Copyrights and Credits About Packt Contributors Table of Contents Preface Section 1: Setting Up Kubernetes Chapter 1: Communicating with Kubernetes Technical requirements Introducing container orchestration What is container orchestration? Benefits of container orchestration Popular orchestration tools Kubernetes' architecture Kubernetes node types The Kubernetes control plane The Kubernetes API server The Kubernetes scheduler The Kubernetes controller manager etcd The Kubernetes worker nodes kubelet kube-proxy The container runtime Addons Authentication and authorization on Kubernetes Namespaces Users Authentication methods Kubernetes' certificate infrastructure for TLS and security Authorization options RBAC ABAC Using kubectl and YAML Setting up kubectl and kubeconfig Imperative versus declarative commands Writing Kubernetes resource YAML files Summary Questions Further reading Chapter 2: Setting Up Your Kubernetes Cluster Technical requirements Options for creating a cluster minikube – an easy way to start Installing minikube Creating a cluster on minikube Managed Kubernetes services Benefits of managed Kubernetes services Drawbacks of managed Kubernetes services AWS – Elastic Kubernetes Service Getting started Google Cloud – Google Kubernetes Engine Getting started Microsoft Azure – Azure Kubernetes Service Getting started Programmatic cluster creation tools Kubeadm Kops Kubespray Creating a cluster with Kubeadm Installing Kubeadm Starting the master nodes Starting the worker nodes Setting up kubectl Creating a cluster with Kops Installing on macOS Installing on Linux Installing on Windows Setting up credentials for Kops Setting up state storage Creating clusters Creating a cluster completely from scratch Provisioning your nodes Creating the Kubernetes certificate authority for TLS Creating config files Creating an etcd cluster and configuring encryption Bootstrapping the control plane component Bootstrapping the worker node Summary Questions Further reading Chapter 3: Running Application Containers on Kubernetes Using Pods Technical requirements What is a Pod? Implementing Pods Pod paradigms Pod networking Pod storage Namespaces The Pod life cycle Understanding the Pod resource spec Summary Questions Further reading Section 2: Configuring and Deploying Applications on Kubernetes Chapter 4: Scaling and Deploying Your Application Technical requirements Understanding Pod drawbacks and their solutions Pod controllers Using ReplicaSets Replicas Selector Template Testing a ReplicaSet Controlling Deployments Controlling Deployments with imperative commands Harnessing the Horizontal Pod Autoscaler Implementing DaemonSets Understanding StatefulSets Using Jobs CronJobs Putting it all together Summary Questions Further reading Chapter 5: Services and Ingress – Communicating with the Outside World Technical requirement Understanding Services and cluster DNS Cluster DNS Service proxy types Implementing ClusterIP Protocol Using NodePort Setting up a LoadBalancer Service Creating an ExternalName Service Configuring Ingress Ingress controllers Summary Questions Further reading Chapter 6: Kubernetes Application Configuration Technical requirements Configuring containerized applications using best practices Understanding ConfigMaps Understanding Secrets Implementing ConfigMaps From text values From files From environment files Mounting a ConfigMap as a volume Mounting a ConfigMap as an environment variable Using Secrets From files Manual declarative approach Mounting a Secret as a volume Mounting a Secret as an environment variable Implementing encrypted Secrets Checking whether your Secrets are encrypted Disabling cluster encryption Summary Questions Further reading Chapter7: Storage on Kubernetes Technical requirements Understanding the difference between volumes and persistent volumes Volumes Persistent volumes Persistent volume claims Attaching Persistent Volume Claims (PVCs) to Pods Persistent volumes without cloud storage Installing Rook The rook-ceph-block storage class The Rook Ceph filesystem Summary Questions Further reading Chapter 8: Pod Placement Controls Technical requirements Identifying use cases for Pod placement Kubernetes node health placement controls Applications requiring different node types Applications requiring specific data compliance Multi-tenant clusters Multiple failure domains Using node selectors and node name Implementing taints and tolerations Multiple taints and tolerations Controlling Pods with node affinity Using requiredDuringSchedulingIgnoredDuringExecution node affinities Using preferredDuringSchedulingIgnoredDuringExecution node affinities Multiple node affinities Using inter-Pod affinity and anti-affinity Pod affinities Pod anti-affinities Combined affinity and anti-affinity Pod affinity and anti-affinity limitations Pod affinity and anti-affinity namespaces Summary Questions Further reading Section 3: Running Kubernetes in Production Chapter 9: Observability on Kubernetes Technical requirements Understanding observability on Kubernetes Understanding what matters for Kubernetes cluster and application health Using default observability tooling Metrics on Kubernetes Logging on Kubernetes Installing Kubernetes Dashboard Alerts and traces on Kubernetes Enhancing Kubernetes observability using the best of the ecosystem Introducing Prometheus and Grafana Implementing the EFK stack on Kubernetes Implementing distributed tracing with Jaeger Third-party tooling Summary Questions Further reading Chapter 10: Troubleshooting Kubernetes Technical requirements Understanding failure modes for distributed applications The network is reliable Latency is zero Bandwidth is infinite The network is secure The topology doesn't change There is only one administrator Transport cost is zero The network is homogeneous Troubleshooting Kubernetes clusters Case study – Kubernetes Pod placement failure Troubleshooting applications on Kubernetes Case study 1 – Service not responding Case study 2 – Incorrect Pod startup command Case study 3 – Pod application malfunction with logs Summary Questions Further reading Chapter 11: Template Code Generation and CI/CD on Kubernetes Technical requirements Understanding options for template code generation on Kubernetes Helm Kustomize Implementing templates on Kubernetes with Helm and Kustomize Using Helm with Kubernetes Using Kustomize with Kubernetes Understanding CI/CD paradigms on Kubernetes – in-cluster and out-of-cluster Out-of-cluster CI/CD In-cluster CI/CD Implementing in-cluster and out-of-cluster CI/CD with Kubernetes Implementing Kubernetes CI with AWS Codebuild Implementing Kubernetes CI with FluxCD Summary Questions Further reading Chapter 12: Kubernetes Security and Compliance Technical requirements Understanding security on Kubernetes Reviewing CVEs and security audits for Kubernetes Understanding CVE-2016-1905 – Improper admission control Understanding CVE-2018-1002105 – Connection upgrading to the backend Understanding the 2019 security audit results Implementing tools for cluster configuration and container security Using admission controllers Enabling Pod security policies Using network policies Handling intrusion detection, runtime security, and compliance on Kubernetes Installing Falco Understanding Falco's capabilities Mapping Falco to compliance and runtime security use cases Summary Questions Further reading Section 4: Extending Kubernetes Chapter 13: Extending Kubernetes with CRDs Technical requirements How to extend Kubernetes with custom resource definitions Writing a custom resource definition Self-managing functionality with Kubernetes operators Mapping the operator control loop Designing an operator for a custom resource definition Using cloud-specific Kubernetes extensions Understanding the cloud-controller-manager component Installing cloud-controller-manager Understanding the cloud-controller-manager capabilities Using external-dns with Kubernetes Using the cluster-autoscaler add-on Integrating with the ecosystem Introducing the Cloud Native Computing Foundation Summary Questions Further reading Chapter 14: Service Meshes and Serverless Technical requirements Using sidecar proxies Using NGINX as a sidecar reverse proxy Using Envoy as a sidecar proxy Adding a service mesh to Kubernetes Setting up Istio on Kubernetes Implementing serverless on Kubernetes Using Knative for FaaS on Kubernetes Using OpenFaaS for FaaS on Kubernetes Summary Questions Further reading Chapter 15: Stateful Workloads on Kubernetes Technical requirements Understanding stateful applications on Kubernetes Popular Kubernetes-native stateful applications Understanding strategies for running stateful applications on Kubernetes Deploying object storage on Kubernetes Installing the Minio Operator Installing Krew and the Minio kubectl plugin Starting the Minio Operator Creating a Minio tenant Accessing the Minio console Running DBs on Kubernetes Running CockroachDB on Kubernetes Testing CockroachDB with SQL Implementing messaging and queues on Kubernetes Deploying RabbitMQ on Kubernetes Summary Questions Further reading Assessments Chapter 1 – Communicating with Kubernetes Chapter 2 – Setting Up Your Kubernetes Cluster Chapter 3 – Running Application Containers on Kubernetes Chapter 4 – Scaling and Deploying Your Application Chapter 5 – Services and Ingress – Communicating with the Outside World Chapter 6 – Kubernetes Application Configuration Chapter 7 – Storage on Kubernetes Chapter 8 – Pod Placement Controls Chapter 9 – Observability on Kubernetes Chapter 10 – Troubleshooting Kubernetes Chapter 11 – Template Code Generation and CI/CD on Kubernetes Chapter 12 – Kubernetes Security and Compliance Chapter 13 – Extending Kubernetes with CRDs Chapter 14 – Service Meshes and Serverless Chapter 15 – Stateful Workloads on Kubernetes Other Books You May Enjoy Index Apply Kubernetes Beyond The Basics Of Kubernetes Clusters By Implementing Iam Using Oidc And Active Directory, Layer 4 Load Balancing Using Metallb, Advanced Service Integration, Security, Auditing, And Ci/cdkey Features* Find Out How To Add Enterprise Features To A Kubernetes Cluster With Theory And Exercises To Guide You* Understand Advanced Topics Including Load Balancing, Externaldns, Idp Integration, Security, Auditing, Backup, And Ci/cd* Create Development Clusters For Unique Testing Requirements, Including Running Multiple Clusters On A Single Server To Simulate An Enterprise Environmentbook Descriptioncontainerization Has Changed The Devops Game Completely, With Docker And Kubernetes Playing Important Roles In Altering The Flow Of App Creation And Deployment. This Book Will Help You Acquire The Knowledge And Tools Required To Integrate Kubernetes Clusters In An Enterprise Environment.the Book Begins By Introducing You To Docker And Kubernetes Fundamentals, Including A Review Of Basic Kubernetes Objects. You'll Then Get To Grips With Containerization And Understand Its Core Functionalities, Including How To Create Ephemeral Multinode Clusters Using Kind. As You Make Progress, You'll Learn About Cluster Architecture, Kubernetes Cluster Deployment, And Cluster Management, And Get Started With Application Deployment. Moving On, You'll Find Out How To Integrate Your Container To A Cloud Platform And Integrate Tools Including Metallb, Externaldns, Openid Connect (oidc), Pod Security Policies (psps), Open Policy Agent (opa), Falco, And Velero. Finally, You Will Discover How To Deploy An Entire Platform To The Cloud Using Continuous Integration And Continuous Delivery (ci/cd).by The End Of This Kubernetes Book, You Will Have Learned How To Create Development Clusters For Testing Applications And Kubernetes Components, And Be Able To Secure And Audit A Cluster By Implementing Various Open-source Solutions Including Openunison, Opa, Falco, Kibana, And Velero.what You Will Learn* Create A Multinode Kubernetes Cluster Using Kind* Implement Ingress, Metallb, And Externaldns* Configure A Cluster Oidc Using Impersonation* Map Enterprise Authorization To Kubernetes* Secure Clusters Using Psps And Opa* Enhance Auditing Using Falco And Efk* Back Up Your Workload For Disaster Recovery And Cluster Migration* Deploy To A Platform Using Tekton, Gitlab, And Argocdwho This Book Is Forthis Book Is For Anyone Interested In Devops, Containerization, And Going Beyond Basic Kubernetes Cluster Deployments. Devops Engineers, Developers, And System Administrators Looking To Enhance Their It Career Paths Will Also Find This Book Helpful. Although Some Prior Experience With Docker And Kubernetes Is Recommended, This Book Includes A Kubernetes Bootcamp That Provides A Description Of Kubernetes Objects To Help You If You Are New To The Topic Or Need A Refresher. Apply Kubernetes beyond the basics of Kubernetes clusters by implementing IAM using OIDC and Active Directory, Layer 4 load balancing using MetalLB, advanced service integration, security, auditing, and CI/CD Key Features Find out how to add enterprise features to a Kubernetes cluster with theory and exercises to guide you Understand advanced topics including load balancing, externalDNS, IDP integration, security, auditing, backup, and CI/CD Create development clusters for unique testing requirements, including running multiple clusters on a single server to simulate an enterprise environment Book Description Containerization has changed the DevOps game completely, with Docker and Kubernetes playing important roles in altering the flow of app creation and deployment. This book will help you acquire the knowledge and tools required to integrate Kubernetes clusters in an enterprise environment. The book begins by introducing you to Docker and Kubernetes fundamentals, including a review of basic Kubernetes objects. You'll then get to grips with containerization and understand its core functionalities, including how to create ephemeral multinode clusters using kind. As you make progress, you'll learn about cluster architecture, Kubernetes cluster deployment, and cluster management, and get started with application deployment. Moving on, you'll find out how to integrate your container to a cloud platform and integrate tools including MetalLB, externalDNS, OpenID connect (OIDC), pod security policies (PSPs), Open Policy Agent (OPA), Falco, and Velero. Finally, you will discover how to deploy an entire platform to the cloud using continuous integration and continuous delivery (CI/CD). By the end of this Kubernetes book, you will have learned how to create development clusters for testing applications and Kubernetes components, and be able to secure and audit a cluster by implementing various open-source solutions including OpenUnison, OPA, Falco, Kibana, and Velero. What you will learn Create a multinode Kubernetes cluster using kind Implement Ingress, MetalLB, and ExternalDNS Configure a cluster OIDC using impersonation Map enterprise authorization to Kubernetes Secure clusters using PSPs and OPA Enhance auditing using Falco and EFK Back up your workload for disaster recovery and cluster migration Deploy to a platform using Tekton, GitLab, and ArgoCD Who this book is for This book is for anyone interested in DevOps, containerization, and going beyon.. Go beyond simply learning Kubernetes fundamentals and its deployment, and explore more advanced concepts, including serverless computing and service meshes with the latest updates Key Features Master Kubernetes architecture and design to build and deploy secure distributed applications Learn advanced concepts like autoscaling, cluster federation, serverless computing, and service mesh integration for observability Explore Kubernetes 1.18 features and its rich ecosystem of tools like Kubectl, Knative, and Helm Book Description The third edition of Mastering Kubernetes is updated with the latest tools and code enabling you to learn Kubernetes 1.18's latest features. This book primarily concentrates on diving deeply into complex concepts and Kubernetes best practices to help you master the skills of designing and deploying large clusters on various cloud platforms. The book trains you to run complex stateful microservices on Kubernetes including advanced features such as horizontal pod autoscaling, rolling updates, resource quotas, and persistent storage backend. With the two new chapters, you will gain expertise in serverless computing and utilizing service meshes. As you proceed through the chapters, you will explore different options for network configuration and learn to set up, operate, and troubleshoot Kubernetes networking plugins through real-world use cases. Furthermore, you will understand the mechanisms of custom resource development and its utilization in automation and maintenance workflows. By the end of this Kubernetes book, you will graduate from an intermediate to advanced Kubernetes professional. What you will learn Master the fundamentals of Kubernetes architecture and design Build and run stateful applications and complex microservices on Kubernetes Use tools like Kubectl, secrets, and Helm to manage resources and storage Master Kubernetes Networking with load balancing options like Ingress Achieve high-availability Kubernetes clusters Improve Kubernetes observability with tools like Prometheus, Grafana, and Jaeger Extend Kubernetes working with Kubernetes API, plugins, and webhooks Who this book is for If you are a system administrator or a cloud developer with working knowledge of Kubernetes and are keen to master its advanced features, along with learning everything from building microservices to utilizing service meshes, Mastering Kubernetes is for you. Basic familiarity with networking concepts will be helpful Containerization has changed the DevOps game competely, with Docker and Kubernetes playing important roles in altering the flow of app creation and deployment. This book will help you acquire the knowledge and tools required to integrate Kubernetes clusters in an enterprise environment. The book begins by introducing you to Docker and Kubernetes fundamentals, including a review of basic Kubernetes objects. You'll then get to grips with containerization and understand its core functionalities, including how to create ephemeral multinode clusters using Kind. As you make progress, you'll learn about cluster architecture, Kubernetes cluster deployment, and cluster management, and get started with application deployment. Moving on, you'll find out how to integrate your container with a cloud platform and integrate tools including MetalLB, externalDNS, OpenID Connet (OIDC), pod security policies (PSPs), Open Policy Agent (OPA), Falco, and Velero. Finally, you will discover how to deploy an entire platform to the cloud using continuous integration and continuous delivery (CI/CD) Kubernetes is a modern cloud native container archestration tool and one of the most popular open source projects worldwide. In addition to the technology being powerful and highly flexible, Kubernetes engineers are in high demand across the industry. This book is a comprehensive guide to deploying, securing, and operating modern cloud native applications on Kubernetes. From the fundamentals to Kubernetes best practices, the book covers essential aspects of configuring applications. You'll even explore real-world techniques for running clusters in production, tips for setting up observability for cluster resources, and valuable troubleshooting techniques. Finally, you'll learn how to extend and customize Kubernetes, as well as gaining tips for deploying service meshes, serverless tooling, and more on your cluster. By the end of this Kubernetes book, you'll be equipped with the tools you need to confidently run and extend modern applications on Kubernetes This new third edition of Mastering Kubernetes, updated with the latest tools and code, explores the newest features in Kubernetes 1.18 throughout the book to fully leverage the modularity and flexibility that Kubernetes offers to build and run large scale distributed applications