title
stringlengths
3
46
content
stringlengths
0
1.6k
22:350
You can verify that the application is properly running by inspecting the data in the dbo.Purchases database table, by right-clicking on the dbo.Purchases table in SQL Server Object Explorer and choosing View Data:
22:351
22:352
Figure 22.10: dbo.Purchases table
22:353
Each time you click the table refresh button, you should see new rows added to the database table. If new rows do not appear after several refreshes, your microservice is probably experiencing some communication problem, or some exception was thrown before data was computed.
22:354
You can discover what the problem is just by debugging the application. The next section explains how to verify in detail what is happening in the application, with the help of Bridge to Kubernetes. Please do not delete all Kubernetes objects created with minkubedeploy.yaml because we need the running application to attach Bridge to Kubernetes.
22:355
Remote debugging a Kubernetes application
22:356
As a final step, we will debug GrpcMicroService with Bridge to Kubernetes. Let’s set GrpcMicroService as a starting project and change the project start from Docker to Bridge to Kubernetes, as shown in the image below:
22:357
22:358
Figure 22.11: Debugging GrpcMicroService with Bridge to Kubernetes
22:359
Let’s place a breakpoint in the GrpcMicroService->HostedServices-> ProcessPurchases.cs file inside of the if block, as shown below:
22:360
if (toProcess.Count > 0)
22:361
{
22:363
}
22:364
22:365
Then, start debugging. As soon as you click the run button, a window appears that prompts you to configure Bridge to Kubernetes:
22:366
22:367
Figure 22.12: Configuring Bridge to Kubernetes
22:368
If the window above doesn’t open, or you can’t see any Minikube node, Kubectl is probably not working or configured for Minikube. Try issuing a Kubectl command like kubectl get all. If you face any issues, try stopping and restarting Minikube with minikube stop, followed by minikube start.
22:369
Bridge to Kubernetes prompts us to select a namespace—in our case, default—and then choose a specific service within that namespace—in our case, grpmicroservice. All communications to that service will be forwarded to the GrpcMicroService code running on our development machine. Let’s set up the configuration window, as shown in the screenshot above. As soon as you submit your Bridge to Kubernetes configuration, debugging will automatically start. In a short time, the breakpoint will be hit, and our local copy of the microservice will start interacting with the remainder of the code that is running in Minikube!
22:370
After you finish debugging, please restore the project start to Docker, and restore the simultaneous start of both microservices so that you can continue working with the Docker virtual network.
22:371
After having finished working with Minikube, you need to remove all objects created by minkubedeploy.yaml with the command below:
22:372
kubectl delete -f minkubedeploy.yaml
22:373
22:374
It is important to free up resources as soon as you don’t need them anymore; otherwise, they will continue wasting CPU time and memory, and if you constantly add more and more applications, sooner or later, you will experience performance problems on your development machine.
22:375
If you want to free up Minikube disk space, you can also remove the microservices images previously loaded in the Minikube cache with the commands below:
22:376
minikube image rm fakesource:latest
22:377
minikube image rm grpcmicroservice:latest
22:378
22:379
Finally, you need to stop Minikube with:
22:380
minikube stop
22:381
22:382
Summary
22:383
In this chapter, we explained how to prepare a developer workstation for .NET Kubernetes development and how to organize code testing and bug-fix cycles.
22:384
We also explained how to define a Docker virtual network to ensure microservices communication during development and name conventions for hostnames and Kubernetes services, enabling the same code to run both on the Docker virtual network, Minikube, and any other Kubernetes cluster.
22:385
Finally, we explained all the steps needed to run an application in Minikube and how to test it with Bridge to Kubernetes.
22:386
We’ve now reached the end of our journey through this book, and what a journey it has been!
22:387
Packed with numerous new and challenging ideas, this book is sure to be your good friend on your journey as a software architect.
22:388
These learnings will not only empower you to craft innovative solutions but also support your growth in the dynamic world of software projects. We sincerely hope you’ve enjoyed the adventure as much as we have creating this latest edition for you.
22:389
Questions
22:390
22:391
Why can’t the SQL Server installation that comes with Visual Studio be used for Kubernetes development?
22:392
What is Bridge to Kubernetes?
22:393
Is it true that Bridge to Kubernetes works just with Minikube?
22:394
How do you load the Minikube images cache?
22:395
How do we define Minikube as the Kubectl default cluster?
22:396
22:397
Further reading
22:398
Most of the references in this chapter are the same as those previously listed in Chapter 11, Applying a Microservice Architecture to Your Enterprise Application, and Chapter 14, Implementing Microservices with .NET. Here, it is worth adding the link to the official documentation about Bridge to Kubernetes: https://learn.microsoft.com/en-us/visualstudio/bridge/
22:399
22:400
22:401
22:402
Learn more on Discord
22:403
To join the Discord community for this book – where you can share feedback, ask questions to the authors, and learn about new releases – follow the QR code below:
22:404
https://packt.link/SoftwareArchitectureCSharp12Dotnet8
22:405
22:406
22:407
Answers:1
Chapter 1
Answers:2
Answers:3
A software architect needs to be aware of any technology that can help them solve problems faster and ensure they can create better quality software.
Answers:4
Azure helps software architects by providing scalable cloud infrastructure, diverse development tools, and services for building, deploying, and managing enterprise applications efficiently, with strong support for security and compliance.
Answers:5
The best software development process model depends on the kind of project, team, and budget you have. As a software architect, you need to consider all these variables and understand different process models so that you can fit the environment’s needs.
Answers:6
A software architect pays attention to any user or system requirement that can influence performance, security, usability, system architecture, structure, organization, and so on.
Answers:7
A software architect should verify both functional and non-functional requirements, with a special focus on system architecture, performance, scalability, security, maintainability, and compatibility in the requirements specification.
Answers:8
Design thinking and design sprint help a software architect to understand user needs deeply and rapidly prototyping solutions, ensuring the requirements gathered align closely with user expectations and project goals.
Answers:9
User stories are good when we want to define functional requirements. They can be written quickly and commonly deliver not only the feature required but also the acceptance criteria for the solution.
Answers:10
Effective techniques for developing high-performance software include optimizing code, using efficient algorithms, leveraging parallel processing, and implementing effective memory management.
Answers:11
To check that the implementation is correct, a software architect compares it with models and prototypes that have already been designed and validated.
Answers:12
Answers:13
Chapter 2
Answers:14
Answers:15
Vertically and horizontally.
Answers:16
Yes, you can deploy automatically to an already-defined web app or create a new one directly using Visual Studio.
Answers:17
To take advantage of available hardware resources by minimizing the time they remain idle.
Answers:18
Code behavior is deterministic, so it is easy to debug. The execution flow mimics the flow of sequential code, which means it is easier to design and understand.
Answers:19
Because the right order minimizes the number of gestures that are needed to fill in a form.
Answers:20
Because it allows for the manipulation of path files in a way that is independent of the operating system.
Answers:21
It can be used with several .NET Core versions, as well as with several versions of the classic .NET Framework.
Answers:22
Console, .NET Core, .NET (5+), and .NET Standard class libraries; ASP.NET Core, test projects, microservices, and much more.
Answers:23
Answers:24
Chapter 3
Answers:25
Answers:26
No, it is available for several platforms.
Answers:27
Automatic, manual, and load test plans.
Answers:28
Yes, they can – through Azure DevOps feeds.
Answers:29
To manage requirements and organize the whole development process.
Answers:30
Epic work items represent higher-level system subparts that are made up of several features.
Answers:31
A parent-child relationship.
Answers:32
They can organize projects using the same concept we have in Azure DevOps.
Answers:33
Both options are great tools for running agile projects. The best option depends on your team’s experience.
Answers:34
Answers:35
Chapter 4
Answers:36
Answers:37
Maintainability gives you the opportunity to deliver the software you designed quickly. It also allows you to fix bugs easily.
Answers:38
Cyclomatic complexity is a measure of code complexity based on the control flow graph. It detects the number of nodes a method has. The higher the number, the worse the effect.
Answers:39
A version control system will guarantee the integrity of your source code, giving you the opportunity to analyze the history of each modification that you’ve made. It offers the possibility of branching your code development, then merging different branches, and much more.
Answers:40
A garbage collector is a system in .NET Core, .NET (5+), and .NET Framework that monitors your application and detects objects that you aren’t using anymore. It disposes of these objects to free up memory.
Answers:41
The IDisposable interface is important firstly because it is a good pattern for deterministic cleanup. Secondly, it is required in classes that instantiate objects that need to be disposed of by the programmer, since the garbage collector cannot dispose of them.
Answers:42
.NET 8 encapsulates some key design patterns in some of its libraries, such as dependency injection and the Builder pattern, in a way that can guarantee safer, more reliable code.
Answers:43
Well-written code is code that any person skilled in that programming language can handle, modify, and evolve.