Image for post
Image for post

In my previous article, I defined services as objects with a static IP that forwards the requests to pods whose selector contains a label described in its YAML description.

However, a service does not link straight to pods. When Kubernetes processes a service description, and if the service selector matches a pod label, Kubernetes will automatically create an Endpoints object with the same name as the service, which stores the pod’s IP address and port. Consequently, when the service receives a request, its proxy will redirect it to one of those IPs and ports.


Image for post
Image for post

In today’s article, I am going to talk about the Microsoft cloud Kubernetes service. If you are not familiar with Kubernetes, I highly recommend reading my previous article since I will refer to concepts related to it.

Imagine this scenario: your manager wants to develop an application using Kubernetes. You start setting-up several Virtual Machines (VMs) and networks, installing multiple components like etcd, certificates, and register agent nodes. This might take you hours or days, depending on the number of VMs. Once you have everything ready to go, you deploy your application. Everything seems to be working well until traffic increases. You must then provision new VMs and install more system components, once again registering nodes with the API server. This maintenance increases exponentially with the number of VMs and with your ecosystem’s complexity. Since agility is key and stand-up or tear-down of clusters is more critical than ever, a new service can rescue us from the monotony of these tasks. This service is Kubernetes-as-a-Service (KaaS). This service transfers the enterprise’s complexity and operational overhead to a Cloud Service Provider (CSP). For example, during the deployment process, the CSP will automatically configure all Kubernetes masters and nodes, usually in a matter of minutes. …


Image for post
Image for post

In this demo, I will explain how to create and deploy a .NET 5 API in a Kubernetes cluster and expose it via a service object.

Create and deploy a .NET 5 application

First, you need to create a new ASPNET Core application using the webapi project template. This template will already contain an example of a controller for a RESTful HTTP service. You can easily do it via dotnet CLI by using:

dotnet new sln
dotnet new webapi -o Training -f net5.0 --no-https
dotnet sln add Training/Training.csproj

Run your application by executing the following command:

dotnet run -p Training\Training.csproj
Building...
info: Microsoft.Hosting.Lifetime[0]
Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0] …


Image for post
Image for post

This article will explain Kubernetes more in-depth by introducing pods, services, and deployments. If you haven’t read my previous article, and this is your first time with Kubernetes, I highly recommend looking at it.

Introducing Pods

Previously, I explained that once the Kubernetes master node receives a description, it pulls the image from a container registry and runs a container with this image on one or more working nodes. However, Kubernetes doesn’t deal directly with these containers. Instead, tightly related containers are grouped in pods and the same Linux namespace.


Image for post
Image for post

Nowadays, when a client asks to create a highly available distributed system, Kubernetes has become the go-to choice. This resulted in a 69 percent use growth, according to the StackRox 2020 report. This article will give you a quick overview of Kubernetes. It’ll explain which problems it solves, how it works, and what its main components are. The concept behind Kubernetes is strictly related to Microservices, so I will summarize that as well to give you a bit of context.

Microservices

Imagine this scenario: Your company has decided to develop a new social network. After a detailed analysis of the customer needs, your team starts development and, once completed, the application is published. The project is a huge success, and the application grows. Bug fixes are alternated with the building of new features, and with each release the application becomes more intractable and delicate. Your team starts feeling fatigued from outages, anxious about releasing, and generally feel like they can’t deliver new features or fixes fast enough. You might be familiar with the expression, “If it works, don’t touch it.” This fear of change is related to a lack of flexibility that we usually find in Monolithic architectures. To our rescue comes the microservices architecture. This architecture breaks down a monolithic application into small, independently running components decoupled from each other. Each component is a microservice. This approach makes the entire system more maintainable and easier to adjust to today’s rapidly changing business requirements. Each piece can be developed, deployed, updated, and scaled individually, but they all work together with other pieces as part of running a stable and business-critical application. …


Image for post
Image for post

This article will talk about parallel jobs in Azure Pipelines and the guidelines to determine how many jobs you need in your organization.

What is a Job?

Each pipeline in Azure DevOps starts with a trigger and is composed of one or more stages. Each stage contains one or more jobs that run multiple tasks on an agent.


Image for post
Image for post

In this article, I’m going to show you how to create and manage Azure deployment slots using Azure CLI.

Creating an Azure Web App Resource

First, you need to login to you Azure account. To do so, execute the following command:

az login

Then you can procced with the creation ofthe resource group, app service plan and only then the web ap resource.

# Login to your Azure account
az login
# Create a new resource group
az group create -n training-rg -l westus
# Create a new app service plan
az appservice plan create -g training-rg -n training-plan --sku S1
# Create a new Web App resource
az webapp create -g training-rg -p training-plan -n…


Image for post
Image for post

This article will show you how to configure your Azure DevOps to run your build pipeline via a Raspberry Pi with Linux. By default, Azure DevOps doesn’t have an option to build a Raspberry solution, so you will have to make one from scratch.

Raspberry PI configuration

Download Ubuntu image

If you start with a brand-new Raspberry Pi, you need to install the Operative System in your Micro SD. However, you have a few limitations on the kind of distribution. Azure DevOps’s agent is based on .NET Core 2.1 and supports the following distributions:

x64

  • CentOS 7, 6
  • Debian 9
  • Fedora 30, 29
  • Linux Mint 18…


Image for post
Image for post

Every time you run a pipeline using Microsoft-hosted agents, Microsoft allocates a new virtual machine to it. One or more agents (a computing infrastructure with installed agent software) begin executing their jobs one at a time. After the pipeline is completed, the virtual machine is discarded, and its content removed. This means that in situations where your code needs some dependencies, the pipeline will have to download them repeatedly for each run.

This performance issue made many Azure Pipelines users ask for caching features. In July 2019, Microsoft released the public preview of pipeline caching in Azure Pipelines. This feature aims to improve the hosted build agents’ performance by adding caching for common scenarios like package restoration. The significant advantage of this feature is that it reduces the build time by allowing the downloaded dependencies from one run to be reused in later runs, thereby avoiding the cost to re-download the same files again. This is especially useful when you are using the Azure Pipelines Free Tier because you are limited to 1800 free minutes/month and if you want to increase that value, it will cost you 40$ or more to get unlimited minutes per Microsoft-hosted pipeline. …


Image for post
Image for post

Azure Deployment Slots is a feature that allows Web Apps, API Apps and Function Apps to run different instances of their application at the same time (known as slots). Slots are exposed via a publicly available endpoint. One instance is always mapped to the production slot, and you can re-route traffic between each instance or even swap instances assigned to a slot by simply clicking a button. When you create an App Service, it’s running on the default production slot.

About

Ivan Porta

Microsoft Certified DevOps Engineer Expert | MCT | .NET Developer | Public Speaker

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store