deployed .net core web api and not able to access application through kubernetes cluster using node port

8/9/2021
<pre>i have deployed .net core webapi through jenkins to kubernetes in local system using vagrant box. now issue is docker have build the image and pushed to docker hub and also able to deploy to the kubernetes cluster and able to see .yml file also tried <code>kubectl get deployment</code> command and out put is this NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE augmento-springboot NodePort 10.233.17.204 101.0.0.2 80:30424/TCP 12h demo-service ClusterIP 10.233.59.234 <none> 8080/TCP 12h dotnet-webapi-service ClusterIP 10.233.3.143 <none> 8080/TCP 13h kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 11d mahesh-dotnet-core-api-app NodePort 10.233.50.18 <none> 80:30462/TCP 20s YML file is below:- apiVersion: apps/v1 kind: Deployment metadata: name: mahesh-dotnet-core-api-app spec: replicas: 3 selector: matchLabels: app: mahesh-dotnet-core-api-app template: metadata: labels: app: mahesh-dotnet-core-api-app spec: containers: - name: dotnetapi image: 9535236403/dotnet-api-docker-demo:dotnet-api-docker-demo ports: - containerPort: 8080 env: - name: PORT value: "8080" --- apiVersion: v1 kind: Service metadata: name: mahesh-dotnet-core-api-app spec: type: NodePort ports: - port: 80 targetPort: 8080 selector: app: mahesh-dotnet-core-api-app now issue is when trying to access application "mahesh-dotnet-core-api-app" "curl HTTP://101.0.0.02:30462/weatherforecast" it is showing error as "Failed to connect to 101.0.02 port 30462: Connection refused" Please fine github URL for dotnet web API code:- <a href="https://github.com/Mahesh-Rajpurohit/dotnet-core-api">https://github.com/Mahesh-Rajpurohit/dotnet-core-api</a> following is docker file:- FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base WORKDIR /app EXPOSE 80 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["WebApiProject/WebApiProject.csproj", "WebApiProject/"] RUN dotnet restore "WebApiProject/WebApiProject.csproj" COPY . . WORKDIR "/src/WebApiProject" RUN dotnet build "WebApiProject.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "WebApiProject.csproj" -c Release -o /app/publish FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "WebApiProject.dll"] </pre>
-- Mahesh Rajpurohit
.net-core
jenkins
kubernetes
kubernetes-ingress
vagrant

0 Answers