Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Software Architecture with C# 12 and .NET 8 - Fourth Edition

You're reading from  Software Architecture with C# 12 and .NET 8 - Fourth Edition

Product type Book
Published in Feb 2024
Publisher Packt
ISBN-13 9781805127659
Pages 756 pages
Edition 4th Edition
Languages
Authors (2):
Gabriel Baptista Gabriel Baptista
Profile icon Gabriel Baptista
Francesco Abbruzzese Francesco Abbruzzese
Profile icon Francesco Abbruzzese
View More author details

Table of Contents (26) Chapters

Preface 1. Understanding the Importance of Software Architecture 2. Non-Functional Requirements 3. Managing Requirements 4. Best Practices in Coding C# 12 5. Implementing Code Reusability in C# 12 6. Design Patterns and .NET 8 Implementation 7. Understanding the Different Domains in Software Solutions 8. Understanding DevOps Principles and CI/CD 9. Testing Your Enterprise Application 10. Deciding on the Best Cloud-Based Solution 11. Applying a Microservice Architecture to Your Enterprise Application 12. Choosing Your Data Storage in the Cloud 13. Interacting with Data in C# – Entity Framework Core 14. Implementing Microservices with .NET 15. Applying Service-Oriented Architectures with .NET 16. Working with Serverless – Azure Functions 17. Presenting ASP.NET Core 18. Implementing Frontend Microservices with ASP.NET Core 19. Client Frameworks: Blazor 20. Kubernetes 21. Case Study 22. Case Study Extension: Developing .NET Microservices for Kubernetes 23. Answers
24. Other Books You May Enjoy
25. Index

Kubernetes

This chapter is dedicated to describing the Kubernetes container orchestrator and its implementation in Azure, called Azure Kubernetes Service (AKS). We discussed the importance and the tasks handled by orchestrators in the Which tools are needed to manage microservices? section of Chapter 11, Applying a Microservice Architecture to Your Enterprise Application. Here, it is worth recalling just that Kubernetes is the de facto standard for orchestrators.

We will show also how to install and use minikube on your local machine, which is a one-node Kubernetes simulator you can use to try out all of the examples in this chapter, and also to test your own applications. Simulators are useful both to avoid wasting too much money on an actual cloud-based Kubernetes cluster, and to provide a different Kubernetes cluster to each developer.

This chapter explains the fundamental Kubernetes concepts and then focuses on how to interact with a Kubernetes cluster and how to deploy...

Technical requirements

In this chapter, you will require the following:

  • Visual Studio 2022 free Community Edition or better, with all the database tools installed, or any other .yaml file editor, such as Visual Studio Code.
  • A free Azure account. The Creating an Azure account section in Chapter 1, Understanding the Importance of Software Architecture, explains how to create one.
  • An optional minikube installation. Installation instructions will be given in the Using minikube section of this chapter.

The code for this chapter is available at https://github.com/PacktPublishing/Software-Architecture-with-C-Sharp-12-and-.NET-8-4E.

Kubernetes basics

Kubernetes is an advanced open source software for managing distributed applications running on a computer network. Kubernetes can be used on your private machine’s cluster, or you can use hardware-scalable Kubernetes offerings from all main cloud providers. This kind of software is called an orchestrator since it dynamically allocates microservices to the available hardware resources in order to maximize performance. Moreover, orchestrators like Kubernetes provide stable virtual addresses to microservices that they move around from one machine to another, thus changing their physical addresses. At the time of writing, Kubernetes is the most widespread orchestrator and the de facto standard for cluster orchestration that can be used with a wide ecosystem of tools and applications. While not being tied to specific languages or frameworks, Kubernetes is a fundamental tool for managing hardware resources and communications in .NET distributed applications based...

Interacting with Kubernetes clusters

In this section, we will explain both how to create an Azure Kubernetes cluster, and how to install minikube, a Kubernetes simulator, on your local machine. All examples can be run on both Azure Kubernetes and your local minikube instance.

Creating an Azure Kubernetes cluster

To create an AKS cluster, do the following:

  1. Type AKS into the Azure search box.
  2. Select Kubernetes services.
  3. Then click the Create button.

After that, the following form will appear:

Figure 20.4: Creating a Kubernetes cluster

It is worth mentioning that you can get help simply by hovering over any with the mouse.

As usual, you are required to specify a subscription, resource group, and region. Then, you can choose a unique name (Kubernetes cluster name) and the version of Kubernetes you would like to use. For computational power, you are asked to select a machine template for each node (Node size) and the number of nodes...

Advanced Kubernetes concepts

In this section, we will discuss other important Kubernetes features, including how to assign permanent storage to StatefulSets; how to store secrets such as passwords, connection strings, or certificates; how a container can inform Kubernetes about its health state; and how to handle complex Kubernetes packages with Helm. All of these subjects are organized into dedicated subsections. We will start with the problem of permanent storage.

Requiring permanent storage

Since Pods are moved between nodes, they can’t store data on the disk storage offered by the current node where they are running, or they would lose that storage as soon as they are moved to a different node. This leaves us with two options:

  • Using external databases: With the help of databases, ReplicaSets can also store information. However, if we need better performance in terms of write/update operations, we should use distributed sharded databases based on non-SQL...

Summary

In this chapter, we described Kubernetes’ basic concepts and objects, and then we explained how to create an AKS cluster. We also showed how to deploy applications and how to monitor and inspect the state of your cluster with a simple demo application.

The chapter also described more advanced Kubernetes features that have fundamental roles in practical applications, including how to provide persistent storage to the containers running on Kubernetes, how to inform Kubernetes of the health state of your containers, and how to offer advanced HTTP services, such as HTTPS and name-based virtual hosting.

Finally, we reviewed how to install complex applications with Helm, and gave a short description of Helm and Helm commands.

Up next, we have the book’s case study.

Questions

  1. Why are Services needed?
  2. Why is an Ingress needed?
  3. Why is Helm needed?
  4. Is it possible to define several Kubernetes objects in the same .yaml file? If yes, how?
  5. How does Kubernetes detect container faults?
  6. Why are persistent volume claims needed?
  7. What is the difference between a ReplicaSet and a StatefulSet?

Further reading

lock icon The rest of the chapter is locked
You have been reading a chapter from
Software Architecture with C# 12 and .NET 8 - Fourth Edition
Published in: Feb 2024 Publisher: Packt ISBN-13: 9781805127659
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 $15.99/month. Cancel anytime}