<p>Hello Im new to minikube and I cant connect to an exposed service. I created an Api .Net Core, I builded the image, go it into my private registry and then i created an deployment with an yml file that works.
But i cant expose that deployment as service. Everytime after I expose it its all fine but I cant connect to it via the port and the minikube ip adress.
If I try to connect to the ipadress:port I get connection refused.</p>
<h2>Deployment yml file:</h2>
<pre><code>kind: Deployment
apiVersion: apps/v1
metadata:
  name: testapp1-deployment
  labels:
    app: testapp1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: testapp1
  template:
    metadata:
      labels:
        app: testapp1
        version: v0.1
    spec:
      containers:
      - name: testapp1-deployment
        image: localhost:5000/testapp1
        imagePullPolicy: Never
        resources:
          requests:
            cpu: 120m
        ports:
        - containerPort: 80
</code></pre>
<p>Service yml file:</p>
<pre><code>    apiVersion: v1
    kind: Service
    metadata:
      name: testapp1-service
    spec:
      type: NodePort
      selector:
          app: testapp1
      ports:
      - protocol: TCP
        port: 80  
        targetPort: 80
</code></pre>

<p>The problem was my dockerfile and I wasn't enabling docker support in my app in ASP .NET Core. I enabled the docker support and changed the dockerfile a bit then I rebuild it and it worked for me.</p>
<blockquote>
<p>FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env</p>
<p>WORKDIR /app</p>
<p>COPY *.csproj ./
RUN dotnet restore</p>
<p>COPY . ./
RUN dotnet publish -c Release -o out</p>
<p>FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT [&quot;dotnet&quot;, &quot;aspnetapp.dll&quot;]</p>
</blockquote>
<p>that's the dockerfile Im using for my app at the moment so if someone else face the same problem as me try to use the dockerfile. If it still won't work look up in previous comments.</p>
