Reputation: 71
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.
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
Service yml file:
apiVersion: v1
kind: Service
metadata:
name: testapp1-service
spec:
type: NodePort
selector:
app: testapp1
ports:
- protocol: TCP
port: 80
targetPort: 80
Upvotes: 1
Views: 1366
Reputation: 71
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.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY *.csproj ./ RUN dotnet restore
COPY . ./ RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "aspnetapp.dll"]
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.
Upvotes: 1