Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
IoT Edge Computing with MicroK8s

You're reading from   IoT Edge Computing with MicroK8s A hands-on approach to building, deploying, and distributing production-ready Kubernetes on IoT and Edge platforms

Arrow left icon
Product type Paperback
Published in Sep 2022
Publisher Packt
ISBN-13 9781803230634
Length 416 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Karthikeyan Shanmugam Karthikeyan Shanmugam
Author Profile Icon Karthikeyan Shanmugam
Karthikeyan Shanmugam
Arrow right icon
View More author details
Toc

Table of Contents (24) Chapters Close

Preface 1. Part 1: Foundations of Kubernetes and MicroK8s
2. Chapter 1: Getting Started with Kubernetes FREE CHAPTER 3. Chapter 2: Introducing MicroK8s 4. Part 2: Kubernetes as the Preferred Platform for IoT and Edge Computing
5. Chapter 3: Essentials of IoT and Edge Computing 6. Chapter 4: Handling the Kubernetes Platform for IoT and Edge Computing 7. Part 3: Running Applications on MicroK8s
8. Chapter 5: Creating and Implementing Updates on a Multi-Node Raspberry Pi Kubernetes Clusters 9. Chapter 6: Configuring Connectivity for Containers 10. Chapter 7: Setting Up MetalLB and Ingress for Load Balancing 11. Chapter 8: Monitoring the Health of Infrastructure and Applications 12. Chapter 9: Using Kubeflow to Run AI/MLOps Workloads 13. Chapter 10: Going Serverless with Knative and OpenFaaS Frameworks 14. Part 4: Deploying and Managing Applications on MicroK8s
15. Chapter 11: Managing Storage Replication with OpenEBS 16. Chapter 12: Implementing Service Mesh for Cross-Cutting Concerns 17. Chapter 13: Resisting Component Failure Using HA Clusters 18. Chapter 14: Hardware Virtualization for Securing Containers 19. Chapter 15: Implementing Strict Confinement for Isolated Containers 20. Chapter 16: Diving into the Future 21. Frequently Asked Questions About MicroK8s
22. Index 23. Other Books You May Enjoy

Kubernetes overview – understanding Kubernetes components

In this section, we'll go through the various components of the Kubernetes system, as well as their abstractions.

The following diagram depicts the various components that are required for a fully functional Kubernetes cluster:

Figure 1.4 – A Kubernetes system and its abstractions

Figure 1.4 – A Kubernetes system and its abstractions

Let's describe the components of a Kubernetes cluster:

  • Nodes, which are worker machines that run containerized work units, make up a Kubernetes cluster. Every cluster has at least one worker node.
  • There is an API layer (Kubernetes API) that can communicate with Kubernetes clusters, which may be accessed via a command-line interface called kubectl.

There are two types of resources in a Kubernetes cluster (as shown in the preceding diagram):

  • The control plane, which controls and manages the cluster
  • The nodes, which are the workers' nodes that run applications

All the operations in your cluster are coordinated by the control plane, including application scheduling, maintaining the intended state of applications, scaling applications, and deploying new updates.

A cluster's nodes might be virtual machines (VMs) or physical computers that serve as worker machines. A kubelet is a node-managing agent that connects each of the nodes to Kubernetes control plane. Container management tools, such as Docker, should be present on the node as well.

The control plane executes a command to start the application containers whenever an application needs to be started on Kubernetes. Containers are scheduled to run on the cluster's nodes by the control plane.

The nodes connect to the control plane using the Kubernetes API that the control plane provides. The Kubernetes API allows end users to interface directly with the cluster. The master components offer the cluster's control plane capabilities.

API Server, Controller-Manager, and Scheduler are the three processes that make up the Kubernetes control plane. The Kubernetes API is exposed through the API Server. It is the Kubernetes control plane's frontend. Controller-Manager is in charge of the cluster's controllers, which are responsible for handling everyday activities. The Scheduler keeps an eye out for new pods that don't have a node assigned to them and assigns them one. Each worker node in the cluster is responsible for the following processes:

  • Kubelet: This handles all the communication with the Kubernetes MasterControl plane.
  • kube-proxy: This handles all the networking proxy services on each node.
  • The container runtime, such as Docker.

Control plane components are in charge of making global cluster decisions (such as application scheduling), as well as monitoring and responding to cluster events. For clusters, there is a web-based Kubernetes dashboard. This allows users to administer and debug cluster-based applications, as well as the cluster itself. Kubernetes clusters may run on a wide range of platforms, including your laptop, cloud-hosted virtual machines, and bare-metal servers.

MicroK8s is a simplistic streamlined Kubernetes implementation that builds a Kubernetes cluster on your local workstation and deploys all the Kubernetes services on a tiny cluster that only includes one node. It can be used to experiment with your local Kubernetes setup. MicroK8s is compatible with Linux, macOS X, Raspberry Pi, and Windows and can be used to experiment with local Kubernetes setups or for edge production use cases. Start, stop, status, and delete are all basic bootstrapping procedures that are provided by the MicroK8s CLI for working with your cluster. We'll learn how to install MicroK8s, check the status of the installation, monitor and control the Kubernetes cluster, and deploy sample applications and add-ons in the next chapter.

Other objects that indicate the state of the system exist in addition to the components listed in Figure 1.4. The following are some of the most fundamental Kubernetes objects:

  • Pods
  • Deployments
  • StatefulSets and DaemonSets
  • Jobs and CronJobs
  • Services

In the Kubernetes system, Kubernetes objects are persistent entities. These entities are used by Kubernetes to represent the state of your cluster. It will operate indefinitely to verify that the object exists once it has been created. You're simply telling the Kubernetes framework how your cluster's workloads should look by building an object; this is your cluster's ideal state. You must use the Kubernetes API to interact with Kubernetes objects, whether you want to create, update, or delete them. The CLI handles all Kubernetes API queries when you use the kubectl command-line interface, for example. You can also directly access the Kubernetes API in your apps by using any of the client libraries. The following diagram illustrates the various Kubernetes objects:

Figure 1.5 – Overview of Kubernetes objects

Figure 1.5 – Overview of Kubernetes objects

Kubernetes provides the preceding set of objects (such as pods, services, and controllers) to satisfy our application's requirements and drive its architecture. The guiding design principles and design patterns we employ to build any new services are determined by these new primitives and platform abilities. A deployment object, for example, is a Kubernetes object that can represent an application running on your cluster. When you build the deployment, you can indicate that three replicas of the application should be running in the deployment specification. The Kubernetes system parses the deployment specification and deploys three instances of your desired application, altering its status as needed. If any of those instances fail for whatever reason, the Kubernetes framework responds to the discrepancy between the specification and the status by correcting it – in this case, by establishing a new instance.

Understanding how Kubernetes works is essential, but understanding how to communicate with Kubernetes is just as important. We'll go over some of the ways to interact with a Kubernetes cluster in the next section.

Interacting with a Kubernetes cluster

In this section, we'll look at different ways to interface with a Kubernetes cluster.

Kubernetes Dashboard is a user interface that can be accessed via the web. It can be used to deploy containerized applications to a Kubernetes cluster, troubleshoot them, and control the cluster's resources. This dashboard can be used for a variety of purposes, including the following:

  • All the nodes and persistent storage volumes are listed in the Admin overview, along with aggregated metrics for each node.
  • The Workloads view displays a list of all running applications by namespace, as well as current pod memory utilization and the number of pods in a deployment that are currently ready.
  • The Discover view displays a list of services that have been made public and have enabled cluster discovery.
  • You can drill down through logs from containers that belong to a single pod using the Logs view.
  • For each clustered application and all the Kubernetes resources running in the cluster, the Storage view identifies any persistent volume claims.
Figure 1.6 – Kubernetes Dashboard

Figure 1.6 – Kubernetes Dashboard

  • With the help of the Kubernetes command-line tool, kubectl, you can perform commands against Kubernetes clusters. kubectl is a command-line tool for deploying applications, inspecting and managing cluster resources, and viewing logs. kubectl can be installed on a variety of Linux, macOS, and Windows platforms.

The basic syntax for kubectl looks as follows:

kubectl [command] [type] [name] [flags]

Let's look at command, type, name, and flags in more detail:

  • command: This defines the action you wanted to obtain on one or more resources, such as create, get, delete, and describe.
  • type: This defines the types of your resources, such as pods and jobs.
  • name: This defines the name of the resource. Names are case-sensitive. If the name is omitted, details for all the resources are displayed; for example, kubectl get pods.
  • flags: This defines optional flags.

We'll take a closer look at each of these Kubernetes objects in the upcoming sections.

You have been reading a chapter from
IoT Edge Computing with MicroK8s
Published in: Sep 2022
Publisher: Packt
ISBN-13: 9781803230634
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime