Hands-On Kubernetes on Windows: Effectively orchestrate Windows container workloads using Kubernetes

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Build and deploy scalable cloud applications using Windows containers and Kubernetes

Key Features

  • Run, deploy, and orchestrate containers on the Windows platform with this Kubernetes book
  • Use Microsoft SQL Server 2019 as a data store to deploy Kubernetes applications written in .NET Framework
  • Set up a Kubernetes development environment and deploy clusters with Windows Server 2019 nodes

Book Description

With the adoption of Windows containers in Kubernetes, you can now fully leverage the flexibility and robustness of the Kubernetes container orchestration system in the Windows ecosystem. This support will enable you to create new Windows applications and migrate existing ones to the cloud-native stack with the same ease as for Linux-oriented cloud applications.

This practical guide takes you through the key concepts involved in packaging Windows-distributed applications into containers and orchestrating these using Kubernetes. You'll also understand the current limitations of Windows support in Kubernetes. As you advance, you'll gain hands-on experience deploying a fully functional hybrid Linux/Windows Kubernetes cluster for development, and explore production scenarios in on-premises and cloud environments, such as Microsoft Azure Kubernetes Service.

By the end of this book, you'll be well-versed with containerization, microservices architecture, and the critical considerations for running Kubernetes in production environments successfully.

What you will learn

  • Understand containerization as a packaging format for applications
  • Create a development environment for Kubernetes on Windows
  • Grasp the key architectural concepts in Kubernetes
  • Discover the current limitations of Kubernetes on the Windows platform
  • Provision and interact with a Kubernetes cluster from a Windows machine
  • Create hybrid Windows Kubernetes clusters in on-premises and cloud environments

Who this book is for

This book is for software developers, system administrators, DevOps engineers, and architects working with Kubernetes on Windows, Windows Server 2019, and Windows containers. Knowledge of Kubernetes as well as the Linux environment will help you get the most out of this book.

Table of Contents

  1. Creating Containers
  2. Managing State in Containers
  3. Working with Container Images
  4. Kubernetes Concepts and Windows Support
  5. Kubernetes Networking
  6. Interacting with Kubernetes Clusters
  7. Deploying a Hybrid On-Premises Kubernetes Cluster
  8. Deploying a Hybrid Azure Kubernetes Service Engine Cluster
  9. Deploying Your First Application
  10. Deploying Microsoft SQL Server 2019 and ASP.NET MVC Application
  11. Configuring Applications to Use Kubernetes Features
  12. Development Workflow with Kubernetes
  13. Securing Kubernetes Clusters and Applications
  14. Monitoring Kubernetes Applications Using Prometheus
  15. Disaster Recovery
  16. Production Considerations for Running Kubernetes

Author(s): Piotr Tylenda
Publisher: Packt Publishing
Year: 2020

Language: English
Pages: 592

Cover
Title Page
Copyright and Credits
About Packt
Contributors
Table of Contents
Preface
Section 1: Creating and Working with Containers
Chapter 01: Creating Containers
Technical requirements
Linux versus Windows containers
Docker containerization on Linux
Docker containerization on Windows
Key differences between containers on Linux and Windows
Understanding Windows container variants
Process isolation
Hyper-V isolation
Linux containers on Windows
LinuxKit and MobyLinuxVM
LinuxKit LCOW and Hyper-V isolation
Installing Docker Desktop for Windows tooling
Stable and Edge channels
Installation
Verifying the installation
Running process-isolated containers
Running LCOW containers
Building your first container
Preparing a Visual Studio Code workspace
Creating a sample HTML web page
Creating a Dockerfile
Building a Docker image
Running Windows containers
Inspecting container logs
Exec into a running container
Summary
Questions
Further reading
Chapter 02: Managing State in Containers
 Technical requirements
Mounting local volumes for stateful applications
Volumes and bind mount
Creating and mounting volumes
Removing volumes
Mounting a local container host directory using bind mounts
Using remote/cloud storage for container storage
Installing the Azure CLI and Azure PowerShell module
Creating Azure Files SMB share
Mounting Azure Files SMB share in a container
Running clustered solutions inside containers
Creating a MongoDB ReplicaSet
Writing and reading test data
Summary
Questions
Further reading
Chapter 03: Working with Container Images
Technical requirements
Storing and sharing container images
Pushing an image to the Docker registry
Using a custom local registry
Using cloud container builders
Creating a GitHub repository
Creating a Docker Hub repository with autobuild
Triggering the Docker Hub autobuild
Creating Azure Container Registry
Building a Docker image using Azure Container Registry
Automatic builds for Azure Container Registry
Image tagging and versioning
Using the latest tag
Semantic versioning 
Ensuring the integrity of the image supply chain
Signing an image
Enabling DCT for the client
Summary
Questions
Further reading
Section 2: Understanding Kubernetes Fundamentals
Chapter 04: Kubernetes Concepts and Windows Support
Technical requirements
Kubernetes high-level architecture
What is Kubernetes?
Kubernetes master – control plane
kube-apiserver
etcd cluster
kube-scheduler
kube-controller-manager
cloud-controller-manager
Kubernetes nodes – data plane
kubelet
Container runtime
kube-proxy
DNS
Kubernetes objects
Pods
ReplicaSets
Deployments
StatefulSets
DaemonSets
Services
Storage-related objects
The Windows and Kubernetes ecosystem
Kubernetes limitations on Windows
Creating your own development cluster from scratch
minikube
Docker Desktop for Windows
Production cluster deployment strategies
kubeadm
kops
kubespray
AKS Engine
Managed Kubernetes providers
Creating AKS cluster with Windows nodes
Summary
Questions
Further reading
Chapter 05: Kubernetes Networking
Technical requirements
Kubernetes networking principles
L2 network
Overlay network
Other solutions
Services
ClusterIP
NodePort
LoadBalancer
ExternalName
Ingress
Kubernetes CNI network plugins
Understanding the CNI project
CoreOS Flannel
Windows Server networking in Kubernetes
Limitations
Choosing Kubernetes network modes
L2Bridge
L2Tunnel
Overlay
Transparent
Summary
Questions
Further reading
Chapter 06: Interacting with Kubernetes Clusters
Technical requirements
Installing Kubernetes command-line tooling
Accessing Kubernetes clusters
Working with development clusters
Looking at common kubectl commands
Creating resources
Deleting resources
Describing and listing resources
Editing resources
Running an ad hoc Pod
Accessing Pod container logs
Execcing into a Pod container
Copying Pod container files
Port forwarding and proxying traffic
Summary
Questions
Further reading
Section 3: Creating Windows Kubernetes Clusters
Chapter 07: Deploying a Hybrid On-Premises Kubernetes Cluster
Technical requirements
Preparing the Hyper-V environment
Enabling Hyper-V
Creating an internal NAT Hyper-V vSwitch
Creating an external Hyper-V vSwitch
Creating a Kubernetes master node using kubeadm
Creating a VM and installing Ubuntu Server
Creating the VM
Installing Ubuntu Server
Configuring the network
Installing additional packages for integration with Hyper-V
Setting up a passwordless SSH login
Installing and configuring Kubernetes prerequisites
Planning the cluster
Initializing the cluster
Installing the Kubernetes network
Preparing VMs for Windows nodes
Creating the VM
Installing Windows Server 2019
Configuring the network
Installing the SSH server
Installing and configuring Kubernetes prerequisites
Joining Windows nodes using kubeadm
Deploying and inspecting your first application
Summary
Questions
Further reading
Chapter 08: Deploying a Hybrid Azure Kubernetes Service Engine Cluster
Technical requirements
Installing AKS Engine
Creating an Azure resource group and a service principal
Using apimodel and generating an Azure resource manager template
Deploying the cluster
Deploying and inspecting your first application
Basic operations
Connecting to virtual machines
Enabling Azure Log Analytics and Azure Monitor for containers
Summary
Questions
Further reading
Section 4: Orchestrating Windows Containers Using Kubernetes
Chapter 09: Deploying Your First Application
Technical requirements
Imperatively deploying an application
Using Kubernetes manifest files
Scheduling Pods on Windows nodes
Accessing your application
Scaling the application
Summary
Questions
Further reading
Chapter 10: Deploying Microsoft SQL Server 2019 and a ASP.NET MVC Application
Technical requirements
Creating and publishing an ASP.NET MVC application to Docker Hub
Injecting the configuration using environment variables
Configuring logging for Windows containers log monitor
Creating a Dockerfile
Building and pushing the Docker image
Preparing the AKS Engine
Deploying a failover Microsoft SQL Server 2019
Deploying the ASP.NET MVC application
Accessing the application
Scaling the application
Debugging the application
Creating a debug Dockerfile and publishing a debug image
Updating the Kubernetes Deployment
Attaching the Visual Studio remote debugger
Summary
Questions
Further reading
Chapter 11: Configuring Applications to Use Kubernetes Features
Technical requirements
Using namespaces to isolate applications
Creating namespaces
kubectl commands and namespaces
Deleting namespaces
Health monitoring using liveness and readiness probes
Readiness probes
Liveness probes
Startup probes
Specifying resource limits and configuring autoscaling
Resource requests and limits
HPA
Managing application configuration using ConfigMaps and Secrets
Managing persistent data storage on Windows nodes
Configuring rolling updates for Deployments
Role-Based Access Control
Summary
Questions
Further reading
Chapter 12: Development Workflow with Kubernetes
Technical requirements
Using developer tooling with Kubernetes
Visual Studio 2019
Visual Studio Code
Packaging applications using Helm
Installing Helm
Deploying Microsoft SQL Server using Helm
Creating a Helm chart for our Voting application
Debugging a containerized application using Azure Application Insights
Enabling Azure Application Insights
Snapshot debugger
Using Kubernetes Dashboard
Deploying Kubernetes Dashboard
Accessing pod container logs
Executing commands in a pod container
Working on microservices in a team using Azure Dev Spaces
Summary
Questions
Further reading
Chapter 13: Securing Kubernetes Clusters and Applications
Technical requirements
Securing Kubernetes clusters
Using built-in RBAC for authorization 
Using an external authentication provider
Bootstrapping the cluster using kubeadm
Disabling public API access
Disabling the public Dashboard
Running containers in nonprivileged mode
Encrypting data at rest
Using network policies
Securing the image supply chain and scan images
Rotating infrastructure credentials and certificates
Enabling audit logging
Integrating AAD with AKS Engine
Securing container runtime in Windows
Deploying secure applications using network policies
Network policy support
Configuring network policy
Kubernetes secrets on Windows machines
Summary
Questions
Further reading
Chapter 14: Monitoring Kubernetes Applications Using Prometheus
Technical requirements
Available monitoring solutions
Prometheus and monitoring Windows nodes
Provisioning observable Windows nodes
Installing WMI Exporter and enabling Metrics Server in Docker
Using extensions for AKS Engine
Deploying Prometheus using a Helm chart
Installing Helm charts
Verifying the Deployment
Windows Performance Counters
Extending a Docker image with the Telegraf service
Deploying an observable version of the voting application
Monitoring .NET applications using prometheus-net
Installing the NuGet package and adding metrics
Deploying the new version of the voting application
Configuring dashboards and alerts in Grafana
Adding visualizations
Configuring alerting
Summary
Questions
Further reading
Chapter 15: Disaster Recovery
Technical requirements
Kubernetes cluster backup strategy
Backing up an etcd cluster
Restoring the etcd cluster backup
Automating backup
Replacing a failed etcd cluster member
Summary
Questions
Further reading
Chapter 16: Production Considerations for Running Kubernetes
Technical requirements
Provisioning clusters reproducibly
Infrastructure as code for clusters
GitOps for application workloads
Kubeadm limitations
Upgrading clusters
OS patching
Configuring a network proxy for the Docker daemon and Kubernetes
Summary
Questions
Further reading
Assessments
Other Books You May Enjoy
Index