IoT Edge Computing with MicroK8s

Book description

A step-by-step, comprehensive guide that includes real-world use cases to help you successfully develop and run applications and mission-critical workloads using MicroK8s

Key Features

  • An easy-to-follow guide that helps you get started with MicroK8s and other Kubernetes components
  • Understand the key concepts and constraints for building IoT and edge architectures
  • Get guidance on how to develop and deploy use cases and examples on IoT and edge computing platforms

Book Description

Are you facing challenges with developing, deploying, monitoring, clustering, storing, securing, and managing Kubernetes in production environments as you're not familiar with infrastructure technologies? MicroK8s - a zero-ops, lightweight, and CNCF-compliant Kubernetes with a small footprint is the apt solution for you.

This book gets you up and running with production-grade, highly available (HA) Kubernetes clusters on MicroK8s using best practices and examples based on IoT and edge computing.

Beginning with an introduction to Kubernetes, MicroK8s, and IoT and edge computing architectures, this book shows you how to install, deploy sample apps, and enable add-ons (like DNS and dashboard) on the MicroK8s platform. You'll work with multi-node Kubernetes clusters on Raspberry Pi and networking plugins (such as Calico and Cilium) and implement service mesh, load balancing with MetalLB and Ingress, and AI/ML workloads on MicroK8s. You'll also understand how to secure containers, monitor infrastructure and apps with Prometheus, Grafana, and the ELK stack, manage storage replication with OpenEBS, resist component failure using a HA cluster, and more, as well as take a sneak peek into future trends.

By the end of this book, you'll be able to use MicroK8 to build and implement scenarios for IoT and edge computing workloads in a production environment.

What you will learn

  • Get a holistic view of MicroK8s features using a sample application
  • Understand IoT and edge computing and their architecture constraints
  • Create, scale, and update HA Raspberry Pi multi-node clusters
  • Implement AI/ML use cases with the Kubeflow platform
  • Work with various networking plugins, and monitoring and logging tools
  • Perform service mesh integrations using Istio and Linkerd
  • Run serverless applications using Knative and OpenFaaS frameworks
  • Secure your containers using Kata and strict confinement options

Who this book is for

This book is for DevOps and cloud engineers, SREs, and application developers who want to implement efficient techniques for deploying their software solutions. It will also be useful for technical architects and technology leaders who are looking to adopt cloud-native technologies. A basic understanding of container-based application design and development, virtual machines, networking, databases, and programming will be helpful for using this book.

Publisher resources

Download Example Code

Table of contents

  1. IoT Edge Computing with MicroK8s
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Part 1: Foundations of Kubernetes and MicroK8s
  7. Chapter 1: Getting Started with Kubernetes
    1. The evolution of containers
    2. Kubernetes overview – understanding Kubernetes components
      1. Interacting with a Kubernetes cluster
    3. Understanding pods
    4. Understanding deployments
    5. Understanding StatefulSets and DaemonSets
      1. StatefulSets
      2. DaemonSets
    6. Understanding jobs and CronJobs
      1. Jobs
      2. CronJob
    7. Understanding services
    8. Summary
  8. Chapter 2: Introducing MicroK8s
    1. Introducing MicroK8s Kubernetes
    2. Quick installation
      1. Technical requirements
      2. Step 1 – Installation
      3. Step 2 – Verify the installation
    3. Deploying a sample application
    4. Enabling add-ons
      1. Full list of add-ons
    5. Starting/stopping MicroK8s
    6. Configuring MicroK8s to use local images
    7. Configuring MicroK8s to use its built-in registry
    8. Configuring MicroK8s to use private/public registries
    9. Configuring MicroK8s services
    10. Troubleshooting application and cluster issues
      1. The application level
      2. The cluster level
    11. Summary
  9. Part 2: Kubernetes as the Preferred Platform for IoT and Edge Computing
  10. Chapter 3: Essentials of IoT and Edge Computing
    1. What is IoT?
      1. Key elements of an IoT solution
    2. What is edge computing?
    3. How are IoT and the edge related?
    4. Benefits of edge computing
    5. What does it take to enable edge computing, edge analytics, and edge intelligence?
    6. Summary
  11. Chapter 4: Handling the Kubernetes Platform for IoT and Edge Computing
    1. Deployment approaches for edge computing
      1. Deployment of the entire Kubernetes cluster at the edge
      2. Deployment of Kubernetes nodes at the edge
      3. Deployment of virtual Kubernetes nodes at the edge
      4. Deployment of Kubernetes devices at the edge
    2. Propositions that Kubernetes offers
    3. Summary
  12. Part 3: Running Applications on MicroK8s
  13. Chapter 5: Creating and Implementing Updates on a Multi-Node Raspberry Pi Kubernetes Clusters
    1. Creating a MicroK8s multi-node cluster using 
a Raspberry Pi
      1. What we are trying to achieve
      2. Configuring Wi-Fi access settings
      3. Installing and configuring MicroK8s
      4. Adding the worker node
    2. Deploying a sample containerized application
    3. Performing rolling updates to the application with a new software version
    4. Scaling the application deployment
    5. Guidelines on multi-node cluster configuration
      1. Cluster-level configuration/settings
    6. Container life cycle management
    7. Deploying and sharing HA applications
    8. Summary
  14. Chapter 6: Configuring Connectivity for Containers
    1. CNI overview
    2. Communication flow from Pod 3 to Pod 6
    3. Configuring Calico
      1. Requirements
      2. Step 1 – Creating a MicroK8s Raspberry Pi cluster
      3. Step 2 – Enabling the Calico CNI add-on
      4. Step 3 – Deploying a sample containerized application
      5. Step 4 – Applying isolation by using NetworkPolicy
      6. Step 5 – Enabling access
    4. Configuring Cilium
      1. Step 1 – Enabling the Cilium add-on
      2. Step 2 – Enabling the DNS add-on
      3. Step 3 – Deploying a sample containerized application
      4. Step 4 – Applying isolation by using NetworkPolicy
      5. Step 5 – Enabling access
    5. Configuring Flannel CNI
      1. Disabling the HA cluster to enable the Flannel add-on
    6. Guidelines on choosing a CNI provider
      1. Key considerations when choosing a CNI provider
    7. Summary
  15. Chapter 7: Setting Up MetalLB and Ingress for Load Balancing
    1. Overview of MetalLB and Ingress
    2. Configuring MetalLB to load balance across the cluster
      1. Requirements
      2. Step 1 – Creating a MicroK8s Raspberry Pi cluster
      3. Step 2 – Enabling the MetalLB add-on
      4. Step 3 – Deploying a sample containerized application
      5. Step 4 – Verifying the load balancer mechanism
    3. Configuring Ingress to expose Services outside the cluster
      1. Option 1 – Using the Ingress NodePort method
      2. Option 2 – Using Ingress and a load balancer
    4. Guidelines on how to choose the right load balancer for your applications
    5. Summary
  16. Chapter 8: Monitoring the Health of Infrastructure and Applications
    1. Overview of monitoring, logging, and alerting options
    2. Configuring a monitoring and alerting stack using the Prometheus, Grafana, and Alertmanager tools
      1. Requirements for setting up a MicroK8s Raspberry Pi cluster
      2. Step 1 – Creating a MicroK8s Raspberry Pi cluster
      3. Step 2 – Configuring Prometheus, Grafana, and Alertmanager
      4. Step 3 – Accessing Prometheus, Grafana, and Alertmanager
    3. Configuring a logging, monitoring, and alerting stack using the EFK toolset
      1. Step 1 – Enabling the Fluentd add-on
      2. Step 2 – Defining an index pattern
      3. Step 3 – Filtering and viewing the data
    4. Key metrics that need to be monitored
      1. Kubernetes events
    5. Summary
  17. Chapter 9: Using Kubeflow to Run AI/MLOps Workloads
    1. Overview of the ML workflow
      1. Introduction – Kubeflow and its components
      2. Introduction to the ML workflow
      3. Kubeflow components in each phase
      4. Kubeflow Pipelines
    2. Deploying Kubeflow
      1. What we are trying to achieve
      2. Step 1 – Installing and configuring MicroK8s
      3. Step 2 – Installing Juju Operator Lifecycle Manager
      4. Step 3 – Post-installation configurations
    3. Accessing the Kubeflow dashboard
    4. Creating a Kubeflow pipeline to build, train, and deploy a sample ML model
      1. Step 1 – launching a new notebook server from the Kubeflow dashboard
      2. Step 2 – creating a Kubeflow pipeline
      3. Step 3 – compiling and running
    5. Recommendations – running AL/ML workloads on Kubernetes
      1. Best practices for running AI/ML workloads
    6. Summary
  18. Chapter 10: Going Serverless with Knative and OpenFaaS Frameworks
    1. Overview of the Knative framework
      1. Build components
      2. Serving components
      3. Eventing components
    2. Enabling the Knative add-on
    3. Deploying and running a sample service on Knative
    4. Overview of the OpenFaaS framework
    5. Enabling the OpenFaaS add-on
    6. Deploying and running a sample function on OpenFaaS
    7. Best practices for developing and deploying serverless applications
      1. Serverless function = specific function
      2. Using microservices
      3. Using appropriate stacks for various resources
      4. Applying the principle of least privilege
      5. Performing load testing
      6. Using a CI/CD pipeline
      7. Constant monitoring is required
      8. Auditing in addition to monitoring
      9. Auditing software dependencies
    8. Summary
  19. Part 4: Deploying and Managing Applications on MicroK8s
  20. Chapter 11: Managing Storage Replication with OpenEBS
    1. Overview of OpenEBS
      1. Control plane
      2. Data plane
      3. Storage engines
    2. Configuring and implementing a PostgreSQL stateful workload
      1. Requirements
      2. Step 1 – Creating the MicroK8s Raspberry Pi cluster
      3. Step 2 – Enabling the OpenEBS add-on
      4. Step 3 – Deploying the PostgreSQL stateful workload
      5. Step 4 – Creating the test data
      6. Step 5 – Simulating node failure
    3. Kubernetes storage best practices
    4. Guidelines on choosing OpenEBS data engines
    5. Summary
  21. Chapter 12: Implementing Service Mesh for Cross-Cutting Concerns
    1. Overview of the Linkerd service mesh
    2. Enabling the Linkerd add-on and running a sample application
      1. Step 1 – Enabling the Linkerd add-on
      2. Step 2 – Deploying the sample application
      3. Step 3 – Exploring the Linkerd dashboard
    3. Overview of the Istio service mesh
    4. Enabling the Istio add-on and running a sample application
      1. Step 1 – Enabling the Istio add-on
      2. Step 2 – Deploying the sample application
      3. Step 3 – Exploring the Istio service dashboard
    5. Common use cases for a service mesh
    6. Guidelines on choosing a service mesh
    7. Best practices for configuring a service mesh
    8. Summary
  22. Chapter 13: Resisting Component Failure Using HA Clusters
    1. An overview of HA topologies
    2. Setting up an HA Kubernetes cluster
      1. Requirements
      2. Step 1 – Creating the MicroK8s Raspberry Pi cluster
      3. Step 2 – Examining the HA setup
      4. Step 3 – Deploying a sample containerized application
      5. Step 3 – Simulating control plane node failure
    3. Kubernetes HA best practices
    4. Summary
  23. Chapter 14: Hardware Virtualization for Securing Containers
    1. Overview of Kata Containers
      1. How Kata Containers works
    2. Enabling the Kata add-on and running a sample application
      1. Step 1 – Enabling the Kata add-on
      2. Step 2 – Deploying a sample application
    3. Container security best practices
      1. Utilizing DevSecOps
      2. Scanning external vulnerabilities via dependency scanning
      3. Analyzing container images using image scanning tools
      4. Enforcing image content trust
      5. Securing registries
      6. Securing your host
      7. Securing your runtime
      8. Reviewing container privileges
      9. Using real-time event and log auditing
      10. Monitoring resource usage
      11. Common security misconfigurations and remediation
    4. Summary
  24. Chapter 15: Implementing Strict Confinement for Isolated Containers
    1. Overview of Snap, Snapcraft, and Ubuntu Core
    2. Setting up Ubuntu Core on a Raspberry Pi board
      1. What we are trying to achieve
      2. Requirements
      3. Step 1 – Setting up an Ubuntu Core image to an SD card
      4. Step 2 – Creating an Ubuntu SSO account
      5. Step 3 – Generating an SSH key pair
      6. Step 4 – Booting Ubuntu Core on Raspberry Pi
    3. Setting up MicroK8s on Ubuntu Core
      1. Adding the worker node
    4. Deploying a sample containerized application
    5. Summary
  25. Chapter 16: Diving into the Future
    1. How MicroK8s is uniquely positioned for accelerating IoT and Edge deployments
      1. Some of the notable challenges in operating IoT edge
      2. How MicroK8s Kubernetes is benefiting edge devices
    2. Looking forward – Kubernetes trends and industry outlook
      1. Trend 1 – security is still everyone’s concern
      2. Trend 2 – GitOps for continuous deployment
      3. Trend 3 – App store for operators
      4. Trend 4 – Serverless computing and containers
      5. Trend 5 – AI/ML and data platforms
      6. Trend 6 – Stateful applications
    3. Summary
    4. Further reading
  26. Frequently Asked Questions About MicroK8s
  27. Index
    1. Why subscribe?
  28. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: IoT Edge Computing with MicroK8s
  • Author(s): Karthikeyan Shanmugam
  • Release date: September 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781803230634