{"id":28034,"date":"2023-10-05T11:52:16","date_gmt":"2023-10-05T09:52:16","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=28034"},"modified":"2023-10-05T11:55:21","modified_gmt":"2023-10-05T09:55:21","slug":"running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/","title":{"rendered":"Running .NET applications in a Kubernetes cluster: A step-by-step guide"},"content":{"rendered":"\n<p>Kubernetes is a powerful container orchestration platform that allows you to deploy, manage, and scale containerized applications with ease. In this guide, we will walk you through the process of running .NET applications in a Kubernetes cluster. We will cover both console applications and web applications. Let&#8217;s get started!<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png\" alt=\"\" class=\"wp-image-28040\" style=\"width:322px;height:322px\" width=\"322\" height=\"322\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png 512w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28-300x300.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28-150x150.png 150w\" sizes=\"auto, (max-width: 322px) 100vw, 322px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-prerequisites\">Prerequisites<\/h2>\n\n\n\n<p>Before we begin, make sure you have the following prerequisites in place:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>.NET SDK<\/strong>: You&#8217;ll need .NET 6.0 or newer installed on your local machine. If you haven&#8217;t already, you can download and install it from the <a href=\"https:\/\/learn.microsoft.com\/fr-fr\/dotnet\/core\/install\/\">official .NET website<\/a>.<\/li>\n\n\n\n<li><strong>Docker<\/strong>: Ensure that Docker is installed on your local machine. You can download Docker Desktop for your operating system from the <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\">Docker website<\/a>.<\/li>\n\n\n\n<li><strong>Kubernetes Cluster<\/strong>: You should have a Kubernetes cluster up and running. If you don&#8217;t have one, you can set up a local Kubernetes cluster using tools like Minikube or use a cloud-based Kubernetes service.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-running-a-net-console-application-in-kubernetes\">Running a .NET console application in Kubernetes<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-1-create-a-net-console-application\">Step 1: Create a .NET console application<\/h3>\n\n\n\n<p>Let&#8217;s start by creating a simple .NET console application. Open your terminal and run the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmkdir helloworld &amp;&amp; cd helloworld\ndotnet new console -o App -n helloworld\n<\/pre><\/div>\n\n\n<p>The command <code>dotnet new console -o App -n helloworld<\/code> is used to create a new .NET console application project with specific settings and options. Let&#8217;s break down the command and explain each part:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>dotnet new<\/code>: This is the base command for creating new projects in the .NET ecosystem. It allows you to create various types of projects, including console applications, web applications, class libraries, and more.<\/li>\n\n\n\n<li><code>console<\/code>: This part of the command specifies the type of project template you want to use. In this case, it&#8217;s the &#8220;console&#8221; template, which is used for creating command-line applications.<\/li>\n\n\n\n<li><code>-o App<\/code>: The <code>-o<\/code> (or <code>--output<\/code>) option is used to specify the output directory for the new project. In this example, it&#8217;s set to &#8220;App,&#8221; which means that the new project files and folders will be created in a directory named &#8220;App&#8221; within the current working directory.<\/li>\n\n\n\n<li><code>-n helloworld<\/code>: The <code>-n<\/code> (or <code>--name<\/code>) option is used to specify the name of the new project. In this example, it&#8217;s set to &#8220;helloworld,&#8221; so the new project will be named &#8220;helloworld.&#8221;<\/li>\n<\/ol>\n\n\n\n<p>When you run this command, .NET will generate the necessary project files, including the project file (<code>.csproj<\/code>), source code files, and other project-related files, in the &#8220;App&#8221; directory with the name &#8220;helloworld.&#8221; This newly created project will be a basic console application template, which you can then customize and build upon to create your own command-line application in .NET.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"301\" height=\"117\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-26.png\" alt=\"\" class=\"wp-image-28038\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-2-modify-the-program-cs\">Step 2: Modify the Program.cs<\/h3>\n\n\n\n<p>Edit the <code>Program.cs<\/code> file in your project directory (<code>App<\/code>) and replace its contents with the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\nusing System;\nusing System.Threading.Tasks;\n\nvar counter = 0;\n\nwhile (true)\n{ \n    Console.WriteLine($&quot;Hello: {++counter}&quot;);\n    await Task.Delay(TimeSpan.FromMilliseconds(1_000));\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-3-run-the-application-in-debug-mode\">Step 3: Run the application in debug mode<\/h3>\n\n\n\n<p>You can run your application in debug mode using the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd App\ndotnet run\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"356\" height=\"149\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-27.png\" alt=\"\" class=\"wp-image-28039\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-27.png 356w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-27-300x126.png 300w\" sizes=\"auto, (max-width: 356px) 100vw, 356px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-4-build-a-release-version\">Step 4: Build a release version<\/h3>\n\n\n\n<p>Build a release version of your application by running:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndotnet publish -c Release\n<\/pre><\/div>\n\n\n<p>Let&#8217;s break down this command and explain each part:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>dotnet publish<\/code>: This is a .NET CLI (Command-Line Interface) command used to build and publish a .NET project. Publishing a project means generating the necessary files and assemblies that can be deployed and run on a target environment.<\/li>\n\n\n\n<li><code>-c Release<\/code>: The <code>-c<\/code> (or <code>--configuration<\/code>) option is used to specify the build configuration for the project. In this case, it is set to &#8220;Release.&#8221; The build configuration determines how the project is built, and it can typically be one of the following:\n<ul class=\"wp-block-list\">\n<li><strong>Debug<\/strong>: This configuration is optimized for debugging and includes additional debugging information. It is suitable for development and testing environments.<\/li>\n\n\n\n<li><strong>Release<\/strong>: This configuration is optimized for production deployment. It typically includes optimizations like code minification, removal of debug symbols, and other performance-related optimizations to make the application run efficiently in a production environment.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>When you run <code>dotnet publish -c Release<\/code>, the .NET CLI will perform the following steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Build the project: It compiles the source code, resolves dependencies, and generates intermediate build artifacts.<\/li>\n\n\n\n<li>Apply Release optimizations: The build process applies optimizations appropriate for a production environment. These optimizations may vary depending on the project type and the specific settings in the project file.<\/li>\n\n\n\n<li>Create a publish directory: It generates a directory (often named &#8220;publish&#8221; or &#8220;bin\/Release\/netX.X\/publish&#8221;) containing all the files necessary to run the application. This includes the compiled application code, dependencies, configuration files, and any other required assets.<\/li>\n<\/ol>\n\n\n\n<p>The output of the <code>dotnet publish<\/code> command is a self-contained, ready-to-deploy version of your .NET application, optimized for production use. You can then take the contents of the publish directory and deploy them to your production environment, whether it&#8217;s a server, container, or cloud platform.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-5-create-a-dockerfile\">Step 5: Create a Dockerfile<\/h3>\n\n\n\n<p>Create a Dockerfile named <code>Dockerfile<\/code> in the project directory with the following content:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nFROM mcr.microsoft.com\/dotnet\/sdk:7.0 AS build-env\nWORKDIR \/App\n\n# Copy everything\nCOPY . .\/ \n# Restore as distinct layers\nRUN dotnet restore\n# Build and publish a release\nRUN dotnet publish -c Release -o out\n\n# Build the runtime image\nFROM mcr.microsoft.com\/dotnet\/aspnet:7.0\nWORKDIR \/App\nCOPY --from=build-env \/App\/out .\nENTRYPOINT &#x5B;&quot;dotnet&quot;, &quot;helloworld.dll&quot;]\n<\/pre><\/div>\n\n\n<p>This Dockerfile is composed of two stages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Building stage: based on the official .NET 7.0 SDK image will build the released version of the project.<\/li>\n\n\n\n<li>Building runtime image stage: based on the official ASP.NET 7.0 image, copy the runtime files from the build stage and set the command <code>dotnet helloworld.dll<\/code> as entrypoint.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-6-build-and-push-the-docker-image\">Step 6: Build and push the Docker image<\/h3>\n\n\n\n<p>Build the Docker image for your application using the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker build -t counter-image -f Dockerfile .\n<\/pre><\/div>\n\n\n<p>Then we will push the image to a local container registry (Harbor for this exemple)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker tag counter-image harbor.dwi.local\/dotnet\/counter-image\ndocker push harbor.dwi.local\/dotnet\/counter-image\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-7-deploy-to-kubernetes\">Step 7: Deploy to Kubernetes<\/h3>\n\n\n\n<p>Deploy your application to the Kubernetes cluster with the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nkubectl run helloworld --image=harbor.dwi.local\/dotnet\/counter-image\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-8-check-the-logs\">Step 8: Check the logs<\/h3>\n\n\n\n<p>You can check the logs of your running application to see the counter increments:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nkubectl logs helloworld -f\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"507\" height=\"211\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image.png\" alt=\"\" class=\"wp-image-28439\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image.png 507w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image-300x125.png 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/figure>\n\n\n\n<p>Congratulations! You have successfully deployed a .NET console application to Kubernetes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-running-a-net-web-application-in-kubernetes\">Running a .NET web application in Kubernetes<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-1-create-a-net-web-application\">Step 1: Create a .NET web application<\/h3>\n\n\n\n<p>Let&#8217;s create a .NET web application. Open your terminal and run the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmkdir WebApp &amp;&amp; cd WebApp\ndotnet new webapp -n AspNetWebApp\ncd AspNetWebApp\n<\/pre><\/div>\n\n\n<p>The command <code>dotnet new webapp -n AspNetWebApp<\/code> is used to create a new ASP.NET web application project using the .NET CLI (Command-Line Interface). Let&#8217;s break down this command and explain each part:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>dotnet new<\/code>: This is the base command for creating new projects in the .NET ecosystem. It allows you to create various types of projects, including web applications, console applications, class libraries, and more.<\/li>\n\n\n\n<li><code>webapp<\/code>: This part of the command specifies the type of project template you want to use. In this case, it&#8217;s the &#8220;webapp&#8221; template, which is used for creating ASP.NET web applications.<\/li>\n\n\n\n<li><code>-n AspNetWebApp<\/code>: The <code>-n<\/code> (or <code>--name<\/code>) option is used to specify the name of the new project. In this example, it&#8217;s set to &#8220;AspNetWebApp,&#8221; so the new project will be named &#8220;AspNetWebApp.&#8221;<\/li>\n<\/ol>\n\n\n\n<p>When you run this command, the .NET CLI will generate the necessary project files and folders for an ASP.NET web application with the name &#8220;AspNetWebApp.&#8221; This includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A project file (usually named &#8220;AspNetWebApp.csproj&#8221;).<\/li>\n\n\n\n<li>Default source code files, including a Startup.cs file.<\/li>\n\n\n\n<li>A web configuration file (appsettings.json).<\/li>\n\n\n\n<li>Other project-related files and folders.<\/li>\n<\/ul>\n\n\n\n<p>The newly created ASP.NET web application project is based on the template and is ready for further customization and development. You can use it as a starting point to build web applications using the ASP.NET framework.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-2-create-a-dockerfile\">Step 2: Create a Dockerfile<\/h3>\n\n\n\n<p>Create a Dockerfile named <code>Dockerfile<\/code> in the project directory with the following content:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nFROM mcr.microsoft.com\/dotnet\/sdk:7.0 AS build-env\nWORKDIR \/app\n\n# Copy csproj and restore as distinct layers\nCOPY *.csproj .\/ RUN dotnet restore\n\n# Copy everything else and build\nCOPY . .\/\nRUN dotnet publish -c Release -o out\n\n# Build the runtime image\nFROM mcr.microsoft.com\/dotnet\/aspnet:7.0\nWORKDIR \/app\nCOPY --from=build-env \/app\/out .\nENTRYPOINT &#x5B;&quot;dotnet&quot;, &quot;AspNetWebApp.dll&quot;]\n<\/pre><\/div>\n\n\n<p>This Dockerfile is composed of two stages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Building stage: based on the official .NET 7.0 SDK image will build the released version of the project.<\/li>\n\n\n\n<li>Building runtime image stage: based on the official ASP.NET 7.0 image, copy the runtime files from the build stage and set the command <code>dotnet AspNetWebApp.dll<\/code> as entrypoint.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-3-build-and-push-the-docker-image\">Step 3: Build and push the Docker image<\/h3>\n\n\n\n<p>Build the Docker image for your web application and push it to your container registry using the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker build -t aspnetwebapp -f Dockerfile .\ndocker tag aspnetwebapp harbor.dwi.local\/dotnet\/aspnetwebapp\ndocker push harbor.dwi.local\/dotnet\/aspnetwebapp\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"h-step-4-deploy-to-kubernetes\">Step 4: Deploy to Kubernetes<\/h3>\n\n\n\n<p>Deploy your web application to the Kubernetes cluster with the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nkubectl run aspnetwebapp --image=harbor.dwi.local\/dotnet\/aspnetwebapp --image-pull-policy=Always\nkubectl expose pod aspnetwebapp --port=80 --name aspnetwebapp-service\nkubectl create ingress aspnetwebapp-ingress --rule=aspnetwebapp.dwi.local\/*=aspnetwebapp-service:80,tls --class=nginx\n<\/pre><\/div>\n\n\n<ol class=\"wp-block-list\">\n<li><code>kubectl run aspnetwebapp --image=harbor.dwi.local\/dotnet\/aspnetwebapp --image-pull-policy=Always<\/code>:\n<ul class=\"wp-block-list\">\n<li><code>kubectl run<\/code> is a command used to create a new deployment or pod in a Kubernetes cluster.<\/li>\n\n\n\n<li><code>aspnetwebapp<\/code> is the name given to the deployment or pod.<\/li>\n\n\n\n<li><code>--image=harbor.dwi.local\/dotnet\/aspnetwebapp<\/code> specifies the container image to use for the deployment. It tells Kubernetes where to find the Docker image for the ASP.NET web application. In this case, the image is hosted at &#8220;harbor.dwi.local&#8221; and tagged as &#8220;dotnet\/aspnetwebapp.&#8221;<\/li>\n\n\n\n<li><code>--image-pull-policy=Always<\/code> specifies that Kubernetes should always pull the latest version of the specified container image, even if a previous version is already cached. This ensures that the deployment uses the most up-to-date image.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>kubectl expose pod aspnetwebapp --port=80 --name aspnetwebapp-service<\/code>:\n<ul class=\"wp-block-list\">\n<li><code>kubectl expose pod<\/code> is a command used to expose a pod as a service within the cluster.<\/li>\n\n\n\n<li><code>aspnetwebapp<\/code> is the name of the pod that you want to expose.<\/li>\n\n\n\n<li><code>--port=80<\/code> specifies the port on which the service should listen within the cluster. Incoming traffic to this port will be directed to the pod.<\/li>\n\n\n\n<li><code>--name aspnetwebapp-service<\/code> assigns a name to the service, making it accessible within the cluster using this name.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>kubectl create ingress aspnetwebapp-ingress --rule=aspnetwebapp.dwi.local\/*=aspnetwebapp-service:80,tls --class=nginx<\/code>:\n<ul class=\"wp-block-list\">\n<li><code>kubectl create ingress<\/code> is a command used to create an ingress resource in Kubernetes. Ingress resources are used to configure external access to services within the cluster.<\/li>\n\n\n\n<li><code>aspnetwebapp-ingress<\/code> is the name assigned to the ingress resource.<\/li>\n\n\n\n<li><code>--rule=aspnetwebapp.dwi.local\/*=aspnetwebapp-service:80,tls<\/code> defines a routing rule for incoming traffic. It states that traffic arriving at the hostname &#8220;aspnetwebapp.dwi.local&#8221; should be directed to the service named &#8220;aspnetwebapp-service&#8221; on port 80, and it should use TLS (Transport Layer Security) encryption, as indicated by the &#8220;tls&#8221; option.<\/li>\n\n\n\n<li><code>--class=nginx<\/code> specifies the ingress controller class to use. In this case, it&#8217;s configured to use the Nginx ingress controller, which is a popular choice for managing ingress in Kubernetes.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Now, your .NET web application is up and running in Kubernetes, and it&#8217;s accessible via the specified ingress route.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"835\" height=\"385\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image-1.png\" alt=\"\" class=\"wp-image-28442\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image-1.png 835w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image-1-300x138.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/10\/image-1-768x354.png 768w\" sizes=\"auto, (max-width: 835px) 100vw, 835px\" \/><\/figure>\n\n\n\n<p>In this guide, we covered the steps to run both .NET console and web applications in a Kubernetes cluster. You can use these principles to containerize and deploy your .NET applications at scale. Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes is a powerful container orchestration platform that allows you to deploy, manage, and scale containerized applications with ease. In this guide, we will walk you through the process of running .NET applications in a Kubernetes cluster. We will cover both console applications and web applications. Let&#8217;s get started! Prerequisites Before we begin, make sure [&hellip;]<\/p>\n","protected":false},"author":107,"featured_media":28040,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1320],"tags":[261,3084,3087,3085,3086,601,2634],"type_dbi":[],"class_list":["post-28034","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-net","tag-net-7-0","tag-asp-net","tag-c","tag-csharp","tag-docker","tag-kubernetes-2"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Running .NET applications in a Kubernetes cluster: A step-by-step guide - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running .NET applications in a Kubernetes cluster: A step-by-step guide\" \/>\n<meta property=\"og:description\" content=\"Kubernetes is a powerful container orchestration platform that allows you to deploy, manage, and scale containerized applications with ease. In this guide, we will walk you through the process of running .NET applications in a Kubernetes cluster. We will cover both console applications and web applications. Let&#8217;s get started! Prerequisites Before we begin, make sure [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-05T09:52:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-10-05T09:55:21+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png\" \/>\n\t<meta property=\"og:image:width\" content=\"512\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Donovan Winter\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Donovan Winter\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\"},\"author\":{\"name\":\"Donovan Winter\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/e0f67a930d31485dd7adef9081496560\"},\"headline\":\"Running .NET applications in a Kubernetes cluster: A step-by-step guide\",\"datePublished\":\"2023-10-05T09:52:16+00:00\",\"dateModified\":\"2023-10-05T09:55:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\"},\"wordCount\":1550,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png\",\"keywords\":[\".NET\",\".NET 7.0\",\"ASP.NET\",\"c#\",\"csharp\",\"Docker\",\"kubernetes\"],\"articleSection\":[\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\",\"name\":\"Running .NET applications in a Kubernetes cluster: A step-by-step guide - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png\",\"datePublished\":\"2023-10-05T09:52:16+00:00\",\"dateModified\":\"2023-10-05T09:55:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/e0f67a930d31485dd7adef9081496560\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png\",\"contentUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png\",\"width\":512,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running .NET applications in a Kubernetes cluster: A step-by-step guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/e0f67a930d31485dd7adef9081496560\",\"name\":\"Donovan Winter\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/84afe8f5c9c68d608f6a5308ec644228931454d5360cfc771256d3cb602b6614?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/84afe8f5c9c68d608f6a5308ec644228931454d5360cfc771256d3cb602b6614?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/84afe8f5c9c68d608f6a5308ec644228931454d5360cfc771256d3cb602b6614?s=96&d=mm&r=g\",\"caption\":\"Donovan Winter\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/donovanwinter\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Running .NET applications in a Kubernetes cluster: A step-by-step guide - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/","og_locale":"en_US","og_type":"article","og_title":"Running .NET applications in a Kubernetes cluster: A step-by-step guide","og_description":"Kubernetes is a powerful container orchestration platform that allows you to deploy, manage, and scale containerized applications with ease. In this guide, we will walk you through the process of running .NET applications in a Kubernetes cluster. We will cover both console applications and web applications. Let&#8217;s get started! Prerequisites Before we begin, make sure [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/","og_site_name":"dbi Blog","article_published_time":"2023-10-05T09:52:16+00:00","article_modified_time":"2023-10-05T09:55:21+00:00","og_image":[{"width":512,"height":512,"url":"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png","type":"image\/png"}],"author":"Donovan Winter","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Donovan Winter","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/"},"author":{"name":"Donovan Winter","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/e0f67a930d31485dd7adef9081496560"},"headline":"Running .NET applications in a Kubernetes cluster: A step-by-step guide","datePublished":"2023-10-05T09:52:16+00:00","dateModified":"2023-10-05T09:55:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/"},"wordCount":1550,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png","keywords":[".NET",".NET 7.0","ASP.NET","c#","csharp","Docker","kubernetes"],"articleSection":["DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/","url":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/","name":"Running .NET applications in a Kubernetes cluster: A step-by-step guide - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png","datePublished":"2023-10-05T09:52:16+00:00","dateModified":"2023-10-05T09:55:21+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/e0f67a930d31485dd7adef9081496560"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/09\/image-28.png","width":512,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/running-net-applications-in-a-kubernetes-cluster-a-step-by-step-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Running .NET applications in a Kubernetes cluster: A step-by-step guide"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/e0f67a930d31485dd7adef9081496560","name":"Donovan Winter","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/84afe8f5c9c68d608f6a5308ec644228931454d5360cfc771256d3cb602b6614?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/84afe8f5c9c68d608f6a5308ec644228931454d5360cfc771256d3cb602b6614?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/84afe8f5c9c68d608f6a5308ec644228931454d5360cfc771256d3cb602b6614?s=96&d=mm&r=g","caption":"Donovan Winter"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/donovanwinter\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28034","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/107"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=28034"}],"version-history":[{"count":6,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28034\/revisions"}],"predecessor-version":[{"id":28445,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/28034\/revisions\/28445"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/28040"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=28034"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=28034"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=28034"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=28034"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}