> [!info] > This series is a complete guide to Kubernetes, > written by Anvesh G. Jhuboo > > Anvesh is a Certified Kubernetes Administrator (CKA), > from the Cloud Native and Linux Foundation. ## Table of Contents - [[01-Intro to K8s]] - [[02-Installation]] - [[03-K8s Architecture]] - [[04-APIs and Access]] - [[05-API Objects]] - [[06-Managing State with Deployments]] - [[07-Volumes and Data]] - [[08-Services]] - [[09-Helm]] - [[10-Ingress]] - [[11-Scheduling]] - [[12-Logging]] - [[13-Custom Resource Definition - CRD]] - [[14-Security]] - [[15-High Availability - HA]] ### Introduction to Kubernetes Running a container on a single laptop is relatively simple. However, connecting containers across multiple hosts, scaling them, deploying applications without downtime, and ensuring service discovery can be challenging. Kubernetes addresses these challenges with a set of primitives and a powerful, extensible API, making it the go-to solution for managing containerized applications. ![K8s | center | 256](https://upload.wikimedia.org/wikipedia/commons/3/39/Kubernetes_logo_without_workmark.svg) #### What is Kubernetes? According to Kubernetes.io, Kubernetes is "an open-source software for automating deployment, scaling, and management of containerized applications." It leverages over 15 years of Google’s experience with Borg, Google’s internal cluster management system, to provide a robust solution for managing applications at scale. The name Kubernetes, derived from the Greek word for "helmsman" or "pilot," signifies its role in steering a ship of containers. Often abbreviated as K8s (with '8' representing the eight letters between 'K' and 's'), Kubernetes has become synonymous with container orchestration. #### Key Components of Kubernetes Deploying applications using Kubernetes involves a shift from traditional development and system administration practices. Here’s a breakdown of its core components: 1. **Control Plane Nodes**: These nodes manage the Kubernetes cluster. They include: - **API Server**: Exposes the Kubernetes API. - **Scheduler**: Assigns workloads to specific nodes. - **Controller Manager**: Runs various controllers to ensure the desired state of the cluster. - **etcd**: A key-value store for cluster data. 2. **Worker Nodes**: These nodes run the containerized applications. Key components include: - **Kubelet**: Communicates with the API server and manages containers on the node. - **Kube-proxy**: Manages network rules and ensures containers are accessible. 3. **Pods**: The smallest deployable units in Kubernetes, consisting of one or more containers that share storage, network, and namespace. 4. **Services**: Define how to access a set of pods, ensuring reliable networking within and outside the cluster. #### Challenges in Container Management Containers revolutionize application packaging, shipping, and running. However, managing them at scale and designing distributed applications based on microservices principles can be challenging. Key challenges include: - **CI/CD Pipelines**: Implementing robust CI/CD pipelines using tools like Jenkins, Spinnaker, or Helm. - **Cluster Management**: Setting up and maintaining a cluster of machines to run containers. - **Network and Storage**: Ensuring flexible, scalable, and secure networking and storage solutions. Kubernetes addresses these challenges through its flexible and powerful architecture, but it also requires applications to be designed with transient infrastructure in mind. Tools like Chaos Monkey, which terminates random containers, test the resilience of these applications. #### Kubernetes vs. Other Solutions While Kubernetes is a leading solution, other container orchestration tools include: - **Docker Swarm**: Integrated with Docker Engine for simple container orchestration. - **Apache Mesos**: Uses frameworks like Marathon to orchestrate containers. - **Nomad**: HashiCorp's scheduler for containerized and non-containerized applications. - **Rancher**: Provides a unified interface to manage multiple orchestration platforms, including Kubernetes. #### Kubernetes Architecture Kubernetes architecture comprises control plane nodes and worker nodes. Here’s a high-level overview: - **Control Plane**: Manages the cluster state, schedules workloads, and maintains cluster data. - **Worker Nodes**: Run the containers, with each node containing kubelet and kube-proxy for container management and networking. Kubernetes uses API-based communication, enabling non-Linux worker nodes and supporting Windows Server 2019 since release 1.14. To learn more about the ideas behind Kubernetes, you can read the [_Large-scale cluster management at Google with Borg_](https://ai.google/research/pubs/pub43438) paper. ![The Kubernetes Lineage](https://d36ai2hkxl16us.cloudfront.net/course-uploads/e0df7fbf-a057-42af-8a1f-590912be5460/cfhkkbh42zcw-Kuberneteslineage.jpg) #### Core Concepts and Terminology - **Pods**: Group of containers with shared resources. - **Namespaces**: Logical partitions within a cluster for resource isolation. - **Controllers**: Ensure the desired state of resources, e.g., Deployments manage ReplicaSets, which in turn manage Pods. - **Services**: Abstract way to expose an application running on a set of Pods. - **Labels and Selectors**: Facilitate the organization and management of resources. - **Annotations**: Store non-identifying metadata about resources. #### Scaling Machine Learning Workloads with Kubernetes Kubernetes is particularly powerful for machine learning (ML) workloads, especially when scaling GPU resources. Here’s how Kubernetes supports ML: 1. **GPU Support**: Kubernetes natively supports scheduling and managing GPU workloads using NVIDIA’s device plugin. 2. **Custom Resource Definitions (CRDs)**: Define custom resources to manage ML-specific requirements. 3. **Kubeflow**: An ML toolkit for Kubernetes, providing components for training, hyperparameter tuning, and serving models. 4. **Scalability**: Leverages Kubernetes' scaling capabilities to handle dynamic ML workloads efficiently. #### Conclusion Kubernetes has revolutionized container orchestration with its robust, flexible, and extensible architecture. Understanding its components, challenges, and advantages over other solutions is crucial for modern application development. Moreover, leveraging Kubernetes for machine learning workloads showcases its versatility and power in handling diverse and demanding use cases. ### Recommended Resources - Read the [Borg paper](https://ai.google/research/pubs/pub43438). - Listen to [John Wilkes talking about Borg and Kubernetes](https://www.gcppodcast.com/post/episode-46-borg-and-k8s-with-john-wilkes/). - Add the Kubernetes [community hangout](https://github.com/kubernetes/community) to your calendar, and attend at least once. - Join the community on [Slack](http://slack.kubernetes.io/) and go in the `#kubernetes-users` channel. Continue: [[02-Installation]]