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:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS baseWORKDIR /appEXPOSE 5000FROM mcr.microsoft.com/dotnet/core/sdk:3.1 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.