<p>I am new to Kubernetes and I am experimenting with some of these in my local development. Before I give my problem statement here is my environment and the state of my project.</p>
<ol>
<li>I have Windows 10 with WSL2 enable with Ubuntu running through VS Code.</li>
<li>I have enabled the required plugins in VS Code (like Kubernetes, Docker and such of those)</li>
<li>I have Docker desktop installed which has WSL2 + Ubuntu + Kubernetes enabled.</li>
<li>I have ASP.Net Core 5 working version from my local system + ubuntu through Docker</li>
<li>I have dockerfile + docker compose file and I have tested them all with and without SSL port and those are working with SSL and without SSL as well. (for that I have modified the program to accept non-SSL request).</li>
</ol>
<p>coming to docker file
-- It has required ports exposed like 5000 (for not SSL) and 5001 (for SSL)
coming to docker compose file
-- It has reuqired mapping like <code>5000:80</code> and <code>5000:443</code></p>
<p>-- It also has environment variable for URLs like</p>
<pre><code>ASPNETCORE_URLS=https://+5001;http://+5000
</code></pre>
<p>-- It also has environment variable for Certificate path like</p>
<pre><code>ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
</code></pre>
<p>-- It also has environment variable for Certificate password like</p>
<pre><code>ASPNETCORE_Kestrel__Certificates__Default__Password=SECRETPASSWORD
</code></pre>
<p>Now, when I says <code>docker compose up --build</code> It build the project and also start the containers.
I am able to access the site through https://localhost:5001 as well as http://localhost:5000</p>
<p>Now, coming to kubernets
-- I have used kompose tool to generate kubernetes specific yaml files
-- I haven't made any change in that. I ran the command <code>kompose convert -f docker-compose.yaml -o ./.k8</code>
-- finally, I ran <code>kubectl apply -f .k8</code></p>
<p>It starts the container but immediately failed. I checked the logs and it says the following:</p>
<pre><code>crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
      Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file
         at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)
         at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
         at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
         at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)
         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()
         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()
         at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
         at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file
</code></pre>

<p>In &quot;It has required mapping like <code>5000:80</code> and <code>5000:443</code>&quot;, actually it should be <code>5001:443</code> (as the port 5001 is used to map to the https 443 port).</p>
<p>Based on this error message</p>
<blockquote>
<p>&quot;nterop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file&quot;,</p>
</blockquote>
<p>It seems the certificate file doesn't exist in the following location: <code>/https/aspnetapp.pfx</code></p>
<p>Run the image, using the following Docker command:</p>
<pre><code>docker run -it --entrypoint sh &lt;image name&gt;
</code></pre>
<p>You will access the container without running the entrypoint, do a <code>cd /https/</code>, check if the certificate is located in this folder or not, if not this is probably the problem.</p>
