Deploying our application services to Kubernetes

Before we can use the sample services we created earlier and deploy them to Kubernetes, we must create Docker images for them and push them to a container registry. In our case, we will just push them to Docker Hub.

Let's start with the .NET Core sample:

  1. Locate the Program.cs file in the .NET project and open it.
  2. Modify the CreateHostBuilder method so it looks like this:
Host.CreateDefaultBuilder(args)    .ConfigureWebHostDefaults(webBuilder =>    {        webBuilder.UseStartup<Startup>();        webBuilder.UseUrls("http://*:5000");    });
  1. Add Dockerfile with the following content to the ch17/dotnet/sample-api project folder:

Get Learn Docker - Fundamentals of Docker 19.x - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.